【问题标题】:Aws Error Could not load credentials from any providersAws 错误无法从任何提供程序加载凭据
【发布时间】:2021-10-05 19:35:50
【问题描述】:

我有一个节点服务,它使用 sts.assumeRole(params) 创建临时 AWS 凭证。如果我在环境中设置 accessKeyId,secretAccessKey,region。凭证生成成功。如果我将它们存储在 Mongo 并阅读它们。我收到以下错误。

错误

Error Could not load credentials from any providers

Error region is missing

代码

const params = {
        RoleArn: `arn:aws:iam::${db.awsAccountId}:role/${db.awsRole}`,
        RoleSessionName: `Assumed-${db.awsRole}-Role-${timestamp}`,
        accessKeyId: db.accessId,
        secretAccessKey: db.accessToken,
        region: db.awsRegion,
      };

sts.assumeRole(params, (err, data) => {
    if(err) console.log(err);
    else console.log(data);
});

我不明白,遵循相同的程序。有什么想法吗?

【问题讨论】:

    标签: node.js mongodb amazon-web-services aws-sts


    【解决方案1】:

    您似乎错误地设置了 STS 服务的 AWS 凭证。您应该查看at the user guide 以获得完整说明。

    设置凭据的方法有多种,因此请选择最适合您情况的一种。当您使用环境变量时,它们会自动获取,但如果您从其他地方读取它们,则必须创建一个 Credentials 对象并将其手动添加到 AWS.config

    有关Credentials 对象的更多信息可以在hereAWS.config here 上找到。

    【讨论】:

      猜你喜欢
      • 2018-01-17
      • 2019-10-01
      • 2021-08-08
      • 2020-07-25
      • 2017-06-15
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多