Reference Parameter Value in UserData in AWS Cloudformation

后端 未结 2 1690
粉色の甜心
粉色の甜心 2021-01-22 13:16

I have this under parameter section ,

Parameters:
  PlatformSelect:
    Description: Cockpit platform Select.
    Type: String
    Default: qa-1
    AllowedValue         


        
相关标签:
2条回答
  • 2021-01-22 13:40

    What about a combination of Fn::Join and Ref

    UserData:
            Fn::Base64:
              Fn::Join:
                - ''
                - - '#!/bin/bash\n'
                  - 'print: echo'
                  - !Ref 'PlatformSelect' 
                  - '>>test.txt\n'
    
    0 讨论(0)
  • 2021-01-22 13:56

    Is there a reason why you are using Mapping in between?

    You could easily use !Sub instead

    Resources:
      EC2Instance:
        Type: AWS::EC2::Instance
        Properties:
          InstanceType: !Ref InstanceType
          KeyName: !Ref KeyName
          Tags:
            - Key: Name
              Value: Test
          UserData:
            Fn::Base64:
              !Sub |
                #!/bin/bash
                ${PlatformSelect}
    
    0 讨论(0)
提交回复
热议问题