【问题标题】:AWS Dynamodb Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1AWS Dynamodb 配置中缺少凭证,如果使用 AWS_CONFIG_FILE,则设置 AWS_SDK_LOAD_CONFIG=1
【发布时间】:2022-01-17 16:58:09
【问题描述】:

我正在尝试在 dynamodb 中的 table添加元素,如下例所示,但是当我运行它时出现此错误留言: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 但老实说,我不明白如何设置它们

【问题讨论】:

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


    【解决方案1】:

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

    你可以通过指定任何字符串来解决。试试下面的 sn-p。

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

    【讨论】:

    • 嗯,您的代码库中似乎有一个循环引用,stackoverflow.com/questions/4816099/…。您是否通过尝试访问 dynamo dB 主机收到任何回复?
    • 我已经看到第二个问题但我没有解决,我不知道循环引用来自哪里,我也尝试传递一个字符串而不是变量但没有任何改变
    • 错误似乎与这个问题无关,我相信是putitem。可能值得作为一个单独的问题提出:)
    • 如你所见,除了 putItems 之外,我还尝试了 put
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2020-11-28
    • 1970-01-01
    • 2022-01-12
    • 2020-12-04
    • 1970-01-01
    • 2022-09-28
    相关资源
    最近更新 更多