【问题标题】:Grant Use-STSRole (sts:AssumeRole) permission to any CodeBuild project向任何 CodeBuild 项目授予 Use-STSRole (sts:AssumeRole) 权限
【发布时间】:2021-07-21 10:08:04
【问题描述】:

我有几个 AWS CodeBuild 项目使用 Use-STSRoleAssume Role 的更特权角色 (readwrite) 以便从 Secrets Manager 中读取密钥。

我已将readwrite 角色的信任关系配置为:

{
  "Version": "2012-10-17",
  "Statement": [    
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "codebuild.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

当我的 CodeBuild 项目运行时出现错误:

Use-STSRole: C:\example-stack-overflow-question\common\utility.psm1:6
Line |
   6 |      Use-STSRole -RoleArn $RoleArn -RoleSessionName $RoleSessionName | …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | User:
     | arn:aws:sts::112233445566:assumed-role/aws-lambda-dotnet-powershe-SignProjectRole5EF6D320-X2IF2P0P1J4/AWSCodeBuild-0d189fc5-f3b6-440a-bed6-ab54ed5f6c08 
     | is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::112233445566:role/readwrite

如何配置我的 IAM 角色 readwrite 以允许任何 CodeBuild 项目通过 Use-STSRole 担任该角色?

【问题讨论】:

    标签: amazon-web-services amazon-iam aws-codebuild aws-powershell


    【解决方案1】:

    我无法获得代码构建工作的限制。相反,我最终允许 AssumeRole 对我帐户中的任何内容执行操作:

       {
          "Effect": "Allow",
          "Principal": {
            "AWS": "arn:aws:iam::112233445566:root"
          },
          "Action": "sts:AssumeRole"
        }
    

    所以现在我的 CodeBuild 项目可以使用 Use-STSRole cmdlet

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-03
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 2016-08-10
      • 2011-04-20
      • 1970-01-01
      • 2017-11-23
      相关资源
      最近更新 更多