我正在尝试将硬编码的数据项放入 DynamoDB。我正在使用 AWS 开发工具包对象来执行此更新。下面代码中的所有调试“Console.log”都被打印出来,但最终它会在 3.00 秒后打印 Task timed out
没有更新 DynamoDB
function updatedb(intent, session, callback) {
let country;
const repromptText = null;
const sessionAttributes = {};
let shouldEndSession = false;
console.log("In the function");
const AWS = require("aws-sdk");
const docClient = new AWS.DynamoDB.DocumentClient({ region: 'eu-west-1' });
var params = {
TableName: "Location",
Item: {
"LocationID": { "S": "11" },
"Country": { "S": "10" },
"Description": { "S": "10" },
"Name": { "S": "10" }
}
};
console.log("Param loaded & executing the DocClient Put");
docClient.put(params, function (err, data) {
if (err) {
speechOutput = 'Update failed';
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
callback(sessionAttributes,
buildSpeechletResponse(intent.name, speechOutput, repromptText, shouldEndSession));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
speechOutput = 'Update successful';
callback(sessionAttributes,
buildSpeechletResponse(intent.name, speechOutput, repromptText, shouldEndSession));
}
});
}
以下项目已被检查
1) DynamoDB 中有一个名为“Location”的表 2) DynamoDB 和这个 lambda 函数都在 ue-west-1 (Ireland) 3) 分配给这个 Lambda 函数的角色可以对这个表执行所有操作。请参阅下面的政策详情
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1510603004000",
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": [
"arn:aws:dynamodb:eu-west-1:752546663632:table/Location"
]
}
]
}
我的 Lambda 函数如何仅通过区域定位表“位置”?- 代码似乎没有端点等?- 只是根据教程开发的。
那是我想念的吗?
请问你能帮忙吗?