【问题标题】:how to allow IAM role to assume another IAM role, via cloudformation?如何允许 IAM 角色通过 cloudformation 承担另一个 IAM 角色?
【发布时间】:2022-01-07 06:48:04
【问题描述】:

通过 cloudformation 添加 IAM 角色,我想在其中添加信任策略,以便来自另一个 aws 账户的另一个 IAM 角色 (arn:aws:iam::123456789:role/otherrole) 可以担任我的角色。但我收到错误“已禁止字段资源(服务:AmazonIdentityManagement;状态代码:400 .....

AWSTemplateFormatVersion: "2010-09-09"
Resources:
  SomeRole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Resource: arn:aws:iam::123456789:role/otherrole
            Action:
              - 'sts:AssumeRole'
      Path: /
      Policies:
      ...

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-iam


    【解决方案1】:

    AssumeRolePolicyDocument 没有Resource。应该是Principal:

    AWSTemplateFormatVersion: "2010-09-09"
    Resources:
      SomeRole:
        Type: 'AWS::IAM::Role'
        Properties:
          AssumeRolePolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect: Allow
                Principal: 
                  AWS: arn:aws:iam::123456789:role/otherrole
                Action:
                  - 'sts:AssumeRole'
          Path: /
          Policies:
          ...
    

    【讨论】:

    • 谢谢。一个后续问题。 AssumeRolePolicyDocument 下的部分是 IAM 角色的信任策略部分?
    • @ozil 是的,这是一项信任政策。
    猜你喜欢
    • 2022-12-08
    • 1970-01-01
    • 2019-07-09
    • 2018-01-15
    • 2017-06-17
    • 1970-01-01
    • 2017-06-18
    • 2020-11-08
    • 2022-07-28
    相关资源
    最近更新 更多