调用 AssumeRole 操作时发生错误 (InvalidClientTokenId):请求中包含的安全令牌无效 [英] An error occurred (InvalidClientTokenId) when calling the AssumeRole operation: The security token included in the request is invalid

查看:41
本文介绍了调用 AssumeRole 操作时发生错误 (InvalidClientTokenId):请求中包含的安全令牌无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到此错误:

An error occurred (InvalidClientTokenId) when calling the AssumeRole operation: The security token included in the request is invalid.

当我运行这个 Assume Role 命令时:

when I run this Assume Role command:

aws sts assume-role --role-arn <arn role i want to assume> --role-session-name dev --serial-number <my arn> --token-code <keyed in token code>

这以前是有效的,所以我不确定会发生什么变化.并且不知如何调试.

This was working previously so I'm not sure what could have changed. And at a loss at how to debug this.

有什么建议吗?

推荐答案

我遇到了同样的问题.在运行 sts 命令之前,您可能需要取消设置 AWS 环境变量:

I had the same problem. You may need to unset your AWS env variables before running the sts command:

unset AWS_SECRET_ACCESS_KEY
unset AWS_SECRET_KEY
unset AWS_SESSION_TOKEN

然后是您的命令:

aws sts assume-role --role-arn <arn role i want to assume> --role-session-name dev --serial-number <my arn> --token-code <keyed in token code>

在这里,您将获得新凭据.然后再次运行导出:

Here you'll get new credentials. Then run the exports again:

export AWS_ACCESS_KEY_ID=<access key>
export AWS_SECRET_ACCESS_KEY=<secret access key>
export AWS_SESSION_TOKEN=<session token>

希望能帮到你!

这篇关于调用 AssumeRole 操作时发生错误 (InvalidClientTokenId):请求中包含的安全令牌无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆