How to reference input parameters in cloudformation template inside 'AWS::SSM::Association' command?

0

Hi there, I have asked this similar question earlier and that got resolved. But still I am not sure on how to achieve this.

I am stuck with the following problem:- I am creating asking an input parameter in my template like this:-

 Name:
    Type: String
    Description: Enter your name
Location:
    Type: String
    Description: Enter your country

Now, I want to get the value of this parameter in my AWS::SSM::Association resource:-

RunCommandAssociation1:
    Type: 'AWS::SSM::Association'
    Properties:
      Name: 'AWS-RunShellScript'
      Targets:
        - Key: InstanceIds
          Values:
            - !Ref Instance1
      Parameters:
        commands:
            name=${Name}
            location=${Location}

The above does not seems to be working. Can someone please help me how can I get multiple such parameters referenced in my AWS::SSM::Association commands.

Thanks in advance!

已提问 8 个月前369 查看次数
1 回答
1

Use either !Ref or !Sub as part of a string, example below for SSM::Association

Parameters:
 MyName:
    Type: String
    Description: Enter your name
 MyLocation:
    Type: String
    Description: Enter your country

Resources:
    Type: AWS::SSM::Association
    Properties:
      Parameters:
        commands:
        - !Sub "name=${MyName}"
        - !Sub "location=${MyLocation}"
AWS
专家
Mike_L
已回答 8 个月前
profile pictureAWS
专家
已审核 8 个月前
  • I want to use the input parameters in my AWS::SSM::Association command.

  • updated. Can test?

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则