在使用AWS SAM CLI进行本地测试时,可以远程使用dynamodb而非本地使用吗?

时间:2019-11-05 04:37:16

标签: amazon-web-services amazon-dynamodb command-line-interface

在许多情况下,问题是如何将aws sam cli与“本地”动力发电机一起使用

我的问题是关于:如何使用生产中的dynamodb,而不是本地的。

例如,

我的本​​地nodejs脚本如下:

const doc = require('dynamodb-doc');
const dynamo = new doc.DynamoDB();
dynamo.query(queryParams, function(err, data) {
             if (err) console.log(err, err.stack); // an error occurred
             else     console.log('data: '+ data);           // successful response
         });

我以sam local invoke --no-event开始脚本-查询表时,如何使用特定的AWS远程资源?

1 个答案:

答案 0 :(得分:0)

如果在调用lambda时希望​​使用特定的远程资源(例如DynamoDB),则可以使用所需的配置文件运行invoke命令,例如:production。

sam local invoke --no-event --profile production

您将需要在AWS凭证文件中配置生产配置文件。如果您还没有这样做,可以按照以下步骤进行:

aws configure --profile production