Amazon Lambda Java Function not insert data to DynamoDB

血红的双手。 提交于 2020-01-04 22:24:52

问题


Currently I am working with Amazon Webservices.
I create one Java lambda function using Eclipse IDE.

After created function in eclipse I test function eclipse using JUnit Test.
Lambda function execute successfully and also inserted data successfully to DynamoDB.

But problem is :

I run function on lambda from Eclipse using Run Function on AWS Lambda functionality.

Data is not inserting and its throwing exception.

I also test this method using API Gateway but get same exception.

Exception : java.lang.IllegalArgumentException: AWS credential profiles file not found in the given path: /home/sbx_user1051/.aws/credentials

Please Friends Help me to solve this problem.

NOTE : I already added full permission for both Lambda Function and DynamoDB.

I am using below code to insert Data to DynamoDB.

DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient(new ProfileCredentialsProvider("my_default_profile")));

Table table = dynamoDB.getTable(TABLE_NAME);

String login_id = (String) inputHashMap.get("login_id");
String password = (String) inputHashMap.get("password");
String type = (String) inputHashMap.get("type");
String device_id = (String) inputHashMap.get("device_id");

try {
    Exception eItem item = new Item().withPrimaryKey("login_id", login_id)
        .withString("device_id", device_id)
        .withBoolean("isUserVerified", false)
        .withString("password", password)
        .withString("type", type);

    table.putItem(item);
}
catch(Exception e){

}

回答1:


Please try creating the DynamoDB object without a profile.

DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient());



来源:https://stackoverflow.com/questions/37067054/amazon-lambda-java-function-not-insert-data-to-dynamodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!