2

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?

Edwin
  • 461
  • 1
  • 5
  • 14

2 Answers2

0

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.

Marcin
  • 215,873
  • 14
  • 235
  • 294
0

I've just bumped into this one - there is special handling in the CLI to treat URL values as a feed, you can disable it by running this before your command aws configure set cli_follow_urlparam false. The information is hard to find and hidden away in the documentation here: https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#general-options

Oly Dungey
  • 1,603
  • 19
  • 20