Coexistence of Pseudo-Parameter and Policy Variables

Asked 2 years ago, Updated 2 years ago, 91 views

1 Answers

I think it is possible to use the CloudFormation Fn::Join function.

cfn-iam-group.yml

AWSTemplateFormatVersion: "2010-09-09"
Description:Asample template
Parameters:
  IAMUserArn:
    Type: String
    Default: arn:aws:iam::1234567890:user/user-name

Resources:
  IAMGroup:
    Type: "AWS::IAM::Group"
    Properties:
      GroupName: "Users"
      Policies:
        - PolicyName—group-user-policy
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect—Allow
                Action:
                  - "iam: GetAccountPasswordPolicy"
                Resource: "*"
              - Effect—Allow
                Action:
                  - "iam: ChangePassword"
                Resource: !Join
                  - ''
                  - - 'arn:aws:iam::'
                    - !Sub"${AWS::AccountId}:"
                    - 'user/${aws:username}'
aws cloud information deploy
    --template-file./cfn-iam-group.yml 
    -- stack-name cfn-iam-group 
    --capabilities CAPABILITY_NAMED_IAM 
    --parameter-overrides IAMUserArn="arn:aws:iam::1234567890:user/user-name"
  • Fn::JoinConnect string arrays given by the function
  • See pseudo-parameter AWS::AccountId using the Fn::Sub function for elements in the array

The IAM Group has been created and we have verified that the following policies are attached:

IAM Group Policy


2022-09-30 19:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.