SSM parameter in cli is evaluating string as an api request

Viewed 663

I am trying to store an ssm parameter using AWS cli

URL='https://gatewayurl.com/dev'

aws ssm put-parameter --name "/dev/app/HOSTNAME" --value $URL --type String --overwrite

SSM parameter is being uploaded however it does not store value https://gatewayurl.com/dev. Insteads it stores the value Hello World which is the response for the URL provided. Is there a way that I can store the URL as a string without it being evaluated as a HTTP request and thus string the response instead of the URL?

2 Answers

To define a variable in bash should use URL not $URL.

For url values, you need to use json way of providing params:

URL='https://gatewayurl.com/dev'

json_params='{' 
json_params+='"Name": "/dev/app/HOSTNAME",'
json_params+='"Value": "'${URL}'",'
json_params+='"Type": "String",'
json_params+='"Overwrite": true'
json_params+='}'


aws ssm put-parameter --cli-input-json "${json_params}"

More info here.

Related