AWS Dynamodb配置中缺少凭据,如果使用AWS_CONFIG_FILE,请设置AWS_SDK_LOAD_CONFIG = 1

时间:2020-07-03 20:47:44

标签: javascript node.js database amazon-web-services amazon-dynamodb

我试图在 dynamodb 添加元素,如下面的示例所示,但是在运行它时出现此错误消息:Missing credentials in the config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

aws.config.update({
   region: "eu-west-1",
   endpoint: "http://localhost:8080",})


  let ddb = new aws.DynamoDB.DocumentClient({
    apiVersion: "2012-08-10",
  });

  let params = {
    TableName: "NameOfTheTable",
    Item: {
      uuid: JSON.stringify(132), // random number for testing
      name: JSON.stringify(req.query.mod), //data i'm passing in
    },
  };

const addMod = ddb.put(params, function (err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data);
  }
});
return res.send(addMod);

});

我认为我可能缺少了accessKeyIdaccessSecretKey,但是说实话,我不知道如何设置它们

1 个答案:

答案 0 :(得分:2)

您似乎在查询本地凭据,因为SDK会检查它们,看来raised as an issue

您可以通过指定任何字符串来解决问题。尝试以下代码段。

aws.config.update({
    region: "eu-west-1",
    endpoint: "http://localhost:8080",
    accessKeyId: “xxxxxx”,
    secretAccessKey: “xxxxxx”
});