Amazon Lambda Java 函数不向 DynamoDB 插入数据
Amazon Lambda Java Function not insert data to DynamoDB
目前我正在使用 Amazon Webservices。
我使用 Eclipse IDE
.
创建了一个 Java lambda 函数
在 eclipse 中创建函数后,我使用 JUnit Test 测试函数 eclipse。
Lambda 函数成功执行并且也成功插入数据到 DynamoDB
.
但问题是:
我 运行 使用 运行 函数在 AWS Lambda 功能上从 Eclipse 在 lambda 上运行。
数据未插入并抛出异常。
我也使用 API Gateway
测试了这个方法,但得到了同样的异常。
异常: java.lang.IllegalArgumentException: AWS credential profiles file not found in the given path: /home/sbx_user1051/.aws/credentials
请各位朋友帮我解决这个问题
NOTE : I already added full permission for both Lambda Function and
DynamoDB.
我正在使用以下代码将数据插入 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){
}
请尝试在没有配置文件的情况下创建 DynamoDB 对象。
DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient());
目前我正在使用 Amazon Webservices。
我使用 Eclipse IDE
.
在 eclipse 中创建函数后,我使用 JUnit Test 测试函数 eclipse。
Lambda 函数成功执行并且也成功插入数据到 DynamoDB
.
但问题是:
我 运行 使用 运行 函数在 AWS Lambda 功能上从 Eclipse 在 lambda 上运行。
数据未插入并抛出异常。
我也使用 API Gateway
测试了这个方法,但得到了同样的异常。
异常: java.lang.IllegalArgumentException: AWS credential profiles file not found in the given path: /home/sbx_user1051/.aws/credentials
请各位朋友帮我解决这个问题
NOTE : I already added full permission for both Lambda Function and DynamoDB.
我正在使用以下代码将数据插入 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){
}
请尝试在没有配置文件的情况下创建 DynamoDB 对象。
DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient());