【发布时间】:2019-03-10 14:24:18
【问题描述】:
我正在使用 sails js(最新版本 1.0)和 DynamoDB(我在本地机器上安装了 Sails js 框架),但是当我尝试从 aws dynamodb 读取记录时,它给出了错误。我尝试过以下情况,每次都遇到不同的错误。
var AWS = require("aws-sdk");
AWS.config.update({
region: "ap-southeast-2",
endpoint: "http://localhost:1337"
});
var docClient = new AWS.DynamoDB.DocumentClient();
var table = "SMSGateway_User";
var email = 'yoursptc@gmail.com';
var params = {
TableName: table,
Key:{
"userEmail": email
}
};
docClient.get(params, function(err, data) {
if (err) {
console.log("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});
我得到的错误:
无法读取项目。错误 JSON:{“消息”:“缺少凭据 在配置中”,“errno”:“ETIMEDOUT”,“代码”:“CredentialsError”,
“系统调用”:“连接”,“地址”:“169.254.169.254”,“端口”:80,
“时间”:“2018-10-05T05:05:26.002Z”,“原始错误”:{ "message": "无法从任何提供者加载凭据", "errno": "ETIMEDOUT", "code": "CredentialsError", “系统调用”:“连接”, “地址”:“169.254.169.254”, “端口”:80, "时间": "2018-10-05T05:05:26.001Z", “原始错误”:{ "errno": "ETIMEDOUT", “代码”:“ETIMEDOUT”, “系统调用”:“连接”, “地址”:“169.254.169.254”, “端口”:80, “消息”:“连接 ETIMEDOUT 169.254.169.254:80” } } }
当我更改并添加以下配置代码时:
AWS.config.update({
accessKeyId: 'XXXXXXXXXXXX',
secretAccessKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
region: "ap-southeast-2",
endpoint: "http://localhost:1337"
});
然后出现以下错误:
无法读取项目。错误 JSON:{“消息”:“未找到”,“代码”: “未知错误”,“状态代码”:404,“时间”: “2018-10-05T06:08:28.707Z”,“可重试”:假,“重试延迟”: 47.4917958614573 }
当我改变终点并放入 ARN
AWS.config.update({
accessKeyId: 'XXXXXXXXXXXX',
secretAccessKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
region: "ap-southeast-2",
endpoint: "arn:aws:dynamodb:ap-southeast-2:420344081058:table/SMSGateway_User"
});
错误是:
无法读取项目。错误 JSON:{“消息”:“无法访问的主机:
arn'. This service may not be available in theap-southeast-2' region.", "code": "UnknownEndpoint", "region": "ap-southeast-2",
“主机名”:“arn”,“可重试”:true,“originalError”:{ “消息”:“getaddrinfo ENOTFOUND arn arn:443”, "errno": "ENOTFOUND", "code": "NetworkingError", “系统调用”:“getaddrinfo”, “主机名”:“arn”, “主机”:“arn”, “端口”:443, “地区”:“ap-southeast-2”, “可重试”:是的, “时间”:“2018-10-05T06:17:21.352Z”},“时间”:“2018-10-05T06:17:21.352Z”}
谁能告诉我哪个是读取、创建、更新和删除 dynamoDB 中数据的正确端点。
任何帮助将不胜感激。
【问题讨论】:
标签: node.js amazon-dynamodb sails.js