简体   繁体   中英

how to allow IAM role to assume another IAM role, via cloudformation?

adding an IAM role via cloudformation, where I want to add a trust policy such that, another IAM role (arn:aws:iam::123456789:role/otherrole) from another aws account can assume my role. but I get an error "Has prohibited field resource ( service: AmazonIdentityManagement; status Code: 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:
      ...

AssumeRolePolicyDocument do not have Resource . It should be 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:
      ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM