[英]AWS STS Assume Role - InvalidClientTokenId: The security token included in the request is invalid
I am trying to assume an IAM
role using aws-sdk
as so...我正在尝试使用
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
});
}
});
But I keep getting...但我一直在...
InvalidClientTokenId: The security token included in the request is invalid
InvalidClientTokenId:请求中包含的安全令牌无效
However, I can connect if I just use the following...但是,如果我只使用以下内容,我可以连接...
AWS.config.update({ accessKeyId: process.env.ID, secretAccessKey: process.env.SECRET });
Any reason why I cannot assume a role?我不能担任角色的任何原因?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.