我試圖使用Lambda(節點)更新DynamoDB中的記錄。我可以更改params
的結構並獲得類似Expected params.ExpressionAttributeValues[':done'] to be a structure
的錯誤,所以我相信它正在與DynamoDB進行通信。使用AWS Lambda的AWS DynamoDB中的UpdateItem(節點)
這是PARAMS:
{
"TableName": "test_table",
"Key": {
"id": {
"S": "90c31f23-96e3-4d5d-b08d-95aafb9bed2e"
}
},
"UpdateExpression": "SET done = :done",
"ExpressionAttributeValues": {
":done": {
"S": "t"
}
},
"ReturnValues": "UPDATED_NEW"
}
從那裏它只是超時,所以很難知道問題是什麼。
這是完整的lambda函數:
var aws = require('aws-sdk');
var dynamodb = new aws.DynamoDB({
apiVersion: '2012-08-10',
accessKeyId: 'xxx',
secretAccesskey: 'xxx',
region: 'us-west-2'
})
exports.handler = (event, context, callback) => {
console.log('Incoming: ', event);
var table = "test_table";
event.Records.forEach((record) => {
console.log('DynamoDB Record: %j', record.dynamodb);
var params = {
TableName: table,
Key: {
"id": record.dynamodb.Keys.id
},
UpdateExpression: "SET done = :done",
ExpressionAttributeValues: {
":done": { "S": "t" }
},
ReturnValues: "UPDATED_NEW"
};
console.log("params: %j", params);
dynamodb.updateItem(params, function(err, data) {
if (err) console.log("Unable to update item. Error: ", JSON.stringify(err, null, 2));
else console.log("Updated item succeeded: ", JSON.stringify(data, null, 2));
});
});
callback(null, "Successfully processed ${event.Records.length} records.");
};
是正確的,該消息不是爲了創建表格,而是將文檔更新爲預先存在的表格?如果是這樣,你會請包括創建表info – aug2uag
我正在使用與創建表的動態軌道。有沒有特別想知道的東西? – Archonic
Schemas是嚴格的,根據外觀來判斷它需要完全匹配..檢查[低級別類型系統](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.LowLevel .Walkthrough.html) – aug2uag