Cloudformation和Roles ......但主要是角色

时间:2017-09-26 01:15:05

标签: amazon-web-services user-roles

我是AWS的新手我创建了一个角色,现在我发现我需要另一个角色了。有没有可以加入多个角色来制作另一个角色,还是只需要构建一些新角色?

Resources:
  ECROLE:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - ec2.amazonaws.com
            Action:
              - sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser

  EXTRAROLE:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
          Service:
            - ec2.amazonaws.com
        Action:
          - sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly

  ECROLEINSTANCEPROFILE:
    Type: "AWS::IAM::InstanceProfile"
    Properties:
      Path: /
      Roles:
        - !Ref ECROLE
 I'd like to just add something here ...          - !Ref EXTRAROLE
      InstanceProfileName: ECROLEINSTANCEPROFILE

Outputs:
  ECROLEKEY:
   Description: Role to be used for interacting with ECR.
   Value: !Ref ECROLE
   Export:
    Name: ECROLEOUTPUT

在AWS :: IAM :: InstanceProfile“节中,我提出了一些我在想的事情......

由于

1 个答案:

答案 0 :(得分:0)

Roles中的AWS::IAM::InstanceProfile属性目前仅限于1个角色(请参阅AWS::IAM::InstanceProfile Roles

创建新角色将是您最好的选择。

如果您发现您在多个不同角色之间共享权限,那么创建可重复使用的托管策略将有助于此。也就是说,在您的示例中,您已经在使用现有的托管策略。