2016-10-20 23 views
2

我有一个快速的节点应用程序,将上传一个json文件发电机数据库,但我不断收到missing credentials in config错误。缺少凭据在aws配置为发电机上传

这是我上传的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文件,但为什么他们没有被已接?

回答

2

看看the documentation

accesskey应该是accessKeyId

secretkey应该secretAccessKey

而且,你并不需要,如果你使用的是默认设置端点的端点。设置区域是你需要做的。

相关问题