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!

asked 8 months ago352 views
1 Answer
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
EXPERT
Mike_L
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago
  • I want to use the input parameters in my AWS::SSM::Association command.

  • updated. Can test?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions