无法通过lambda从nodejs代码访问dynamodb

我一直试图从lambdatesting这个,但无法继续。

var Alexa = require("alexa-sdk"); var dynamoDBConfiguration = { "accessKeyId": "useraccess", "secretAccessKey": "usersecretkey", "region": "us-east-1" }; var AWS = require("aws-sdk"); AWS.config.update(dynamoDBConfiguration); var promisify = require("es6-promisify"); var dynClient = new AWS.DynamoDB.DocumentClient({"region":"us-east- 1"}); //convert callback style functions to promises const dbGet = promisify(dynClient.get,dynClient); const dbPut = promisify(dynClient.put,dynClient); const dbDelete = promisify(dynClient.delete,dynClient); var startStateHandlers = (GAME_STATES.STARt, { "StartGame": function (isNewGame,context) { const dynamoParams = { TableName: "Userdata", Key: { "UserId":"test" } } dbGet(dynamoParams) .then(data => { console.log('Get user succeeded', data); const userId = data.UserId; if (userId != null) { console.log(data.UserName); } else { // no match, add the user return dbPut(dynamoParams); } }) .then(data => { console.log('Add user succeeded', data); }) .catch(err => { console.error(err); }); this.emit(":tell", speechOutput, speechOutput); } }); var handlers = { "LaunchRequest": function () { var speechOutput = "hello"; this.emit(":tell", speechOutput, speechOutput); } }; var handler = (function () { function handler(event, context, callback) { var alexa = Alexa.handler(event, context); alexa.appId = "appid"; alexa.registerHandlers(handlers, startStateHandlers); alexa.execute(); } return handler; })(); exports.handler = handler; 

它不会在lamda日志中引发任何错误,也无法在Cloudwatch中看到任何日志。 它只是执行其他代码行。

我已将所有权限策略附加到用户,并将lamda函数设置为lambda_dynamo。

无法理解它是什么问题。

感谢你的帮助。

       

网上收集的解决方案 "无法通过lambda从nodejs代码访问dynamodb"

 var dynamoDBConfiguration = { "accessKeyId": "useraccess", "secretAccessKey": "usersecretkey", "region": "us-east-1" }; var AWS = require("aws-sdk"); // update the AWS.Config global configuration object AWS.config.update(dynamoDBConfiguration) // Create DynamoDB document client var dynClient = new AWS.DynamoDB.DocumentClient()