Saving a url to AWS parameter store with aws-cli

This is happening because of a questionable behavior by awscli v1. When it sees a URL, it invokes an HTTP GET for a result. This does not happen in awscli v2.

You can work around this behavior as follows:

aws ssm put-parameter --cli-input-json '{
  "Name": "/dev/someStore",
  "Value": "https://google.com",
  "Type": "String"
}'

Or you can store the JSON in a file named params.json and invoke:

aws ssm put-parameter --cli-input-json file://params.json

The underlying issue was reported at aws/aws-cli/issues/2507.


Another option to make this work is to not include the https protocol in the value and just the domain name or the path. After retrieval add the protocol appropriate. some times we wanted to use https or http or even ssh. Take git url for example. Multiple protocols for accessing the resource with appropriate ports where the path is the required value


By default AWS CLI follows any string parameters that start with https:// or http://. These URLs are fetched, and the downloaded content is used as the parameter instead of URL.

To make CLI not treat strings prefixed with https:// or http:// any differently than normal string parameters run:

aws configure set cli_follow_urlparam false

cli_follow_urlparam controls whether or not the CLI will attempt to follow URL links in parameters that start with either prefix https:// or http://.

See https://docs.aws.amazon.com/cli/latest/topic/config-vars.html

Problem:

aws ssm put-parameter --name /config/application/some-url --value http://google.com --type String --region eu-central-1 --overwrite

Error parsing parameter '--value': Unable to retrieve http://google.com: received non 200 status code of 301

Solution:

aws configure set cli_follow_urlparam false
aws ssm put-parameter --name /config/application/some-url --value http://google.com --type String --region eu-central-1 --overwrite

{
    "Version": 1
}

The GitHub discussion on this topic, linked by @jarmod, also had another solution for this. I'll replicate it here for others to avoid scanning through the whole thread.

Add the following to your ~/.aws/config along with any other settings present.

[default]
cli_follow_urlparam = false

P.S. Seems that it is also mentioned in the AWS documentation under "Loading Parameters from a File" section.