1
私は最初のラムダ関数を動作させようとしていますが、私はdynamoDBに書き込むテストを得ることができません。私はこの時点までAWSチュートリアルに従ってきました。ここでラムダ関数テストは決してパスしません
は、私のラムダ関数(私のDBを合わせてチュートリアルから若干の変更)である:ここでは
'use strict';
console.log('Loading function');
const doc = require('dynamodb-doc');
const dynamo = new doc.DynamoDB();
/**
* Provide an event that contains the following keys:
*
* - operation: one of the operations in the switch statement below
* - tableName: required for operations that interact with DynamoDB
* - payload: a parameter to pass to the operation being performed
*/
exports.handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
console.log('\nPayload:', event.Item);
console.log('event table', event.TableName);
console.log('\nEvent:', event);
const operation = event.operation;
const payload = event.Item;
// if (event.tableName) {
// payload.TableName = event.tableName;
// }
switch (operation) {
case 'create':
dynamo.putItem(payload, callback);
break;
case 'read':
dynamo.getItem(payload, callback);
break;
case 'update':
dynamo.updateItem(payload, callback);
break;
case 'delete':
dynamo.deleteItem(payload, callback);
break;
case 'list':
dynamo.scan(payload, callback);
break;
case 'echo':
callback(null, payload);
break;
case 'ping':
callback(null, 'pong');
break;
default:
callback(new Error(`Unrecognized operation "${operation}"`));
}
};
は私のテストペイロードである:
{
"TableName": "EVENTS",
"operation": "create",
"Item" : {
"userID": "2",
"kidNo": 2,
"note": "Testing",
"timeStamp": "timer1"
}
}
そして、ここでは私が得る応答の一つであります:
{
"errorMessage": "There were 6 validation errors:\n* MissingRequiredParameter: Missing required key 'TableName' in params\n* MissingRequiredParameter: Missing required key 'Item' in params\n* UnexpectedParameter: Unexpected key 'userID' found in params\n* UnexpectedParameter: Unexpected key 'kidNo' found in params\n* UnexpectedParameter: Unexpected key 'timeStamp' found in params\n* UnexpectedParameter: Unexpected key 'note' found in params",
"errorType": "MultipleValidationErrors",
"stackTrace": [
"* MissingRequiredParameter: Missing required key 'TableName' in params",
"* MissingRequiredParameter: Missing required key 'Item' in params",
"* UnexpectedParameter: Unexpected key 'userID' found in params",
"* UnexpectedParameter: Unexpected key 'kidNo' found in params",
"* UnexpectedParameter: Unexpected key 'timeStamp' found in params",
"* UnexpectedParameter: Unexpected key 'note' found in params",
"ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:40:28)",
"Request.VALIDATE_PARAMETERS (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:125:42)",
"Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)",
"callNextListener (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:95:12)",
"/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:85:9",
"finish (/var/runtime/node_modules/aws-sdk/lib/config.js:315:7)",
"/var/runtime/node_modules/aws-sdk/lib/config.js:333:9",
"EnvironmentCredentials.get (/var/runtime/node_modules/aws-sdk/lib/credentials.js:126:7)",
"getAsyncCredentials (/var/runtime/node_modules/aws-sdk/lib/config.js:327:24)",
"Config.getCredentials (/var/runtime/node_modules/aws-sdk/lib/config.js:347:9)"
]
}
私はそれが私に言っていることを理解していますが、私はそれを修正することもできません!私はエラーの中ですべての提案を試みました、そして、彼らは遠ざかりません。私は何か基本的なことを逃しているように感じる。
を試すことができ、簡単なハック私は気づいたが、それはDynamoDBのに行くことになっていたことすべてだと思いました。ありがとう!私は、その間は分からなかった。 – Siriss