gpt4 book ai didi

node.js - AWS STS 担任角色 - InvalidClientTokenId : The security token included in the request is invalid

转载 作者:行者123 更新时间:2023-12-05 04:58:57 26 4
gpt4 key购买 nike

我正在尝试使用 aws-sdk 担任 IAM 角色...

var sts = new AWS.STS();
sts.assumeRole({
RoleArn: 'arn:aws:iam::xxxxxx:root',
RoleSessionName: 'awssdk'
}, function(err, data) {
if (err) { // an error occurred
console.log('Cannot assume role');
console.log(err, err.stack);
}
else { // successful response
AWS.config.update({
accessKeyId: data.Credentials.AccessKeyId,
secretAccessKey: data.Credentials.SecretAccessKey,
sessionToken: data.Credentials.SessionToken
});
}
});

但我不断得到...

InvalidClientTokenId: The security token included in the request is invalid

但是,如果我只使用以下内容,我可以连接...

AWS.config.update({ accessKeyId: process.env.ID, secretAccessKey: process.env.SECRET });

我有什么理由不能担任角色?

最佳答案

以下内容

RoleArn: 'arn:aws:iam::xxxxxx:root',

不是 IAM 角色。您似乎正在尝试假设为 IAM root 用户。角色的正确 ARN 具有 form

arn:aws:iam::account-id:role/role-name-with-path

关于node.js - AWS STS 担任角色 - InvalidClientTokenId : The security token included in the request is invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63746285/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com