我有一个快速节点应用程序,它会将json文件上传到dynamo db,但我一直收到missing credentials in config
错误。
这是我的上传js
var AWS = require("aws-sdk");
var fs = require('fs');
AWS.config.update({
region: "us-east-1",
endpoint: "dynamodb.us-east-1.amazonaws.com",
accesskey: "Axxxxxx",
secretkey: "QQhxxxxxxxxx"
});
var docClient = new AWS.DynamoDB.DocumentClient();
console.log("Importing ach into DynamoDB. Please wait.");
var allACH = JSON.parse(fs.readFileSync('ach.json', 'utf8'));
allACH.forEach(function(movie) {
var params = {
TableName: "ACH",
Item: {
"lastname": movie.lastname,
"firstname": movie.firstname,
"employeeid": movie.employeeid,
"hrs": movie.hrs
}
};
docClient.put(params, function(err, data) {
if (err) {
console.error("Unable to add item", movie.employeeid, ". Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("PutItem succeeded:", movie.employeeid);
}
});
});
然后我得到的错误就是:
Importing ach into DynamoDB. Please wait.
Unable to add item 78 . Error JSON: {
"message": "Missing credentials in config",
"code": "CredentialsError",
"time": "2016-10-20T18:14:26.314Z",
"retryable": true,
"originalError": {
"message": "Could not load credentials from any providers",
"code": "CredentialsError",
"time": "2016-10-20T18:14:26.314Z",
"retryable": true,
"originalError": {
"message": "Connection timed out after 1000ms",
"code": "TimeoutError",
"time": "2016-10-20T18:14:26.313Z",
"retryable": true
}
}
}
我认为我的凭据位于upload.js文件中,但为什么它们没有被提取?
答案 0 :(得分:2)
Look at the documentation.
accesskey
should be accessKeyId
secretkey
should be secretAccessKey
Also, you don't need to set the endpoint if you are using the default endpoint. Setting the region is all you need to do.