问题
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