从cloudformation将多个IAM内联策略附加到同一角色

时间:2018-08-06 14:40:18

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

我正在检查是否可以在云形成方面附加多个IAM策略。 我已经附加了托管策略,并且能够附加和内联策略,但是想检查我是否可以附加多个内联策略。

我想担任相同的角色

1)托管策略 2)内联政策-1 3)内联政策-2

谢谢 娜塔拉吉

1 个答案:

答案 0 :(得分:2)

这是完全可能的。相关字段将为ManagedPolicyArnsPolicies

Resources: 
  RootRole: 
    Type: "AWS::IAM::Role"
    Properties: 
      AssumeRolePolicyDocument: 
        Version: "2012-10-17"
        Statement: 
          - 
            Effect: "Allow"
            Principal: 
              Service: 
                - "ec2.amazonaws.com"
            Action: 
              - "sts:AssumeRole"
      Path: "/"
      ManagedPolicyArns:
        - 'arn:aws:iam::ACCOUNT_ID:policy/myname/ManagedPolicy'
      Policies: 
        - 
          PolicyName: "Inline Policy 1"
          PolicyDocument: 
            Version: "2012-10-17"
            Statement: 
              - 
                Effect: "Allow"
                Action: "*"
                Resource: "*"
        - 
          PolicyName: "Inline Policy 2"
          PolicyDocument: 
            Version: "2012-10-17"
            Statement: 
              - 
                Effect: "Allow"
                Action: "*"
                Resource: "*"

有关更多详细信息/标注,请查看文档:{​​{3}}