【问题标题】:Unable to assumerole to access the EC2 instance in AWS无法承担访问 AWS 中的 EC2 实例的角色
【发布时间】:2021-07-29 05:01:24
【问题描述】:

我正在使用 AWS Control Tower 和 AWS Organization 的多账户架构。我有一个主账户,其中有一个名为 agent 的 IAM 用户(没有附加策略,只有 CLI 访问权限),然后我有另一个名为 dev 的 AWS 账户,我在其中创建了一个名为工作负载部署者的新角色 (ARN -> arn :aws:iam::809348927750:role/workload-deployer) 具有以下信任关系:-

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::185288728304:user/agent"
      },
      "Action": "sts:AssumeRole",
      "Condition": {}
    }
  ]
}

当我尝试担任此角色时,我收到以下错误:-

An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:iam::185288728304:user/agent is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::809348927750:role/workload-deployer

我正在运行以承担角色的命令:-

aws sts assume-role --role-arn arn:aws:iam::809348927750:role/workload-deployer --role-session-name "RoleSession1" --duration-seconds 900  --profile zm

【问题讨论】:

  • 您需要在您的 agent 上制定一项政策,以允许 sts:AssumeRole 担任任何其他角色。

标签: amazon-web-services amazon-iam aws-sts


【解决方案1】:

为了担任角色,您需要在两个地方存在权限:

  1. 您开始使用的角色需要获得担任角色的权限。所以它必须有一个授予sts:AssumeRole 权限的策略。
  2. 您要代入的角色必须有一个信任策略,授予调用角色代入该角色的权限。

听起来您缺少#1 的权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-07
    • 2023-02-18
    • 2020-08-27
    • 2017-11-20
    • 2020-04-29
    • 2019-12-31
    • 1970-01-01
    • 2019-01-26
    相关资源
    最近更新 更多