好的,我正在尝试将Dynamo DB表名作为参数发送。我已经定义了以下Lambda:
'use strict';
const AWS = require('aws-sdk');
const DOC = require('dynamodb-doc');
const docClient = new AWS.DynamoDB.DocumentClient({ region: 'eu-west-1' });
exports.handler = function(event, context, callback) {
// Set local variables to passed in variables
var dynamoDBReadFromTableName = event.dynamoDBReadFromTableName;
var dynamoDBReadFromPrimaryKeyValue = event.dynamoDBReadFromPrimaryKeyValue;
var dynamoDBTablePrimaryKeyName = event.dynamoDBTablePrimaryKeyName;
// Read MCP SKU data from MCPSKU-CustomsPartKey
// Create the Parameters that are used by the GET call
let dynamoDBTableReadFromParameters = {
TableName: dynamoDBReadFromTableName,
Key: {
dynamoDBTablePrimaryKeyName: dynamoDBReadFromPrimaryKeyValue
},
AttributesToGet: [
'CustomsPartKey',
'EffectiveDateCountryOfOrigin',
'ItemWeightLbs'
],
};
//Use the GET call to read the MCP SKU data
docClient.get(dynamoDBTableReadFromParameters, function(err, dataReadFromDynamoDbtable) {
if (err) {
console.log(err, err.stack);
} else {
console.log(dataReadFromDynamoDbtable)
}
});
};
我在没有传递AWS Dynamo DB表名的情况下测试了这一点 - 即dynamoDBTablePrimaryKeyName
并且已经过了
"footer": dynamoDBReadFromPrimaryKeyValue
foobar实际上是一个Dynamo DB名称,它只是花花公子。
当我尝试使用参数(具有相同/正确的名称)替换Dynamo DB名称时,出现以下错误:
START RequestId: 835fa87b-fdde-11e6-9b5d-a35457d4e835 Version: $LATEST
2017-02-28T17:51:21.575Z 835fa87b-fdde-11e6-9b5d-a35457d4e835 { [ValidationException: The provided key element does not match the schema]
message: 'The provided key element does not match the schema',
code: 'ValidationException',
time: Tue Feb 28 2017 17:51:21 GMT+0000 (UTC),
requestId: 'T37SQIF62TFUFCQUMJM7DL4AJBVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 0 } 'ValidationException: The provided key element does not match the schema
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:43:27)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:671:14)
at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:673:12)
at Request.callListeners (/var/runtime/node_modules/aws- sdk/lib/sequential_executor.js:115:18)'
END RequestId: 835fa87b-fdde-11e6-9b5d-a35457d4e835
REPORT RequestId: 835fa87b-fdde-11e6-9b5d-a35457d4e835 Duration: 236.73 ms Billed Duration: 300 ms Memory Size: 512 MB Max Memory Used: 30 MB
有人有想法吗? AWS Lambda是否不允许传递表名?
答案 0 :(得分:0)