dan*_*mcc 36 javascript amazon-web-services node.js amazon-dynamodb
亚马逊为其Dynamodb产品提供本地模拟器,但示例仅在PHP中.
这些示例提到传递参数"base_url"以指定您正在使用本地Dynamodb,但是在Node中返回此错误:
{ [UnrecognizedClientException: The security token included in the request is invalid.]
message: 'The security token included in the request is invalid.',
code: 'UnrecognizedClientException',
name: 'UnrecognizedClientException',
statusCode: 400,
retryable: false }
Run Code Online (Sandbox Code Playgroud)
如何让Dynamodb_local在Node中工作?
aaa*_*sto 50
您应该按照此博客文章来设置DynamoDB Local,然后您可以使用以下代码:
var AWS= require('aws-sdk'),
dyn= new AWS.DynamoDB({ endpoint: new AWS.Endpoint('http://localhost:8000') });
dyn.listTables(function (err, data)
{
console.log('listTables',err,data);
});
Run Code Online (Sandbox Code Playgroud)
小智 5
对于节点,请执行以下操作:
const AWS = require('aws-sdk');
const AWSaccessKeyId = 'not-important';
const AWSsecretAccessKey = 'not-important';
const AWSregion = 'local';
const AWSendpoint = 'http://localhost:8000' // This is required
AWS.config.update({
accessKeyId: AWSaccessKeyId,
secretAccessKey: AWSsecretAccessKey,
region: AWSregion,
endpoint: AWSendpoint
});
Run Code Online (Sandbox Code Playgroud)
确保 DynamodDB 在端口 8000 上运行。
| 归档时间: |
|
| 查看次数: |
17510 次 |
| 最近记录: |