Amazon aws cli:承担的角色返回访问被拒绝错误

发布于 2025-01-14 05:44:00 字数 1301 浏览 2 评论 0原文

我正在尝试使用 aws cli 运行一些命令。我在目标区域没有用户帐户,但我尝试使用名为“AssumedAdministrator”的角色,该角色具有 sts:assumerole。 我可以使用“切换角色”选项登录 aws Web 控制台。

但是当我运行如下 CLI 命令时:

aws --profile $profile sts get-caller-identity --region $region

我收到以下错误:

An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:iam::111111111111:user/john.smith is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/AssumedAdministrator

这是与该角色相关的受信任实体:

AssumedAdministrator role
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111111111111:root"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "Bool": {
                    "aws:MultiFactorAuthPresent": "false"
                }
            }
        }
    ]
}

我做错了什么?如何

在凭证文件中运行 aws cli 命令我的部分:

[default]
aws_access_key_id = ##########################
aws_secret_access_key = ############################
region = ##########

[assumed-#####-admin]
role_arn = arn:aws:iam::222222222222:role/AssumedAdministrator
source_profile = default

谢谢

I am trying to use aws cli to run some commands. I do not have a user account in the target region, but I am trying to use a role called "AssumedAdministrator" which has sts:assumerole.
I can log into the aws web console OK using the "switch role" option.

but when I run a CLI command like :

aws --profile $profile sts get-caller-identity --region $region

I am getting the following error:

An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:iam::111111111111:user/john.smith is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::222222222222:role/AssumedAdministrator

Here's the Trusted Entities tied to that role:

AssumedAdministrator role
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::111111111111:root"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "Bool": {
                    "aws:MultiFactorAuthPresent": "false"
                }
            }
        }
    ]
}

What am I doing wrong? How can I run aws cli commands

my sections in the credentials file:

[default]
aws_access_key_id = ##########################
aws_secret_access_key = ############################
region = ##########

[assumed-#####-admin]
role_arn = arn:aws:iam::222222222222:role/AssumedAdministrator
source_profile = default

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文