aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

ssm put-parameter fetches external URLs if value is URL

Open otanner opened this issue 8 years ago • 9 comments

Hi,

When the value of the parameter contains URL, aws-cli fetches the URL and tries to insert the source code as the value. When setting the same value via console it can be stored as is.

Example: aws ssm put-parameter --type 'SecureString' --key-id 'alias/mykey' --name '/myservice/url' --value 'https://google.com/' returns the source code of https://google.com/ and an error failed to satisfy constraint: Member must have length less than or equal to 4096.

Is this a bug or a feature with missing documentation? Is there a possibility to put raw values containing URLs without this magic?

Version information: aws-cli/1.14.19 Python/2.7.10 Darwin/16.7.0 botocore/1.8.23

otanner avatar Jan 08 '18 18:01 otanner

It's a documented feature, but it's definitely a feature we've found to cause a lot of surprise. The easiest way around this is probably to use --cli-input-json like so:

aws ssm put-parameter --cli-input-json '{"Type": "SecureString", "KeyId": "alias/mykey", "Name": "/myservice/url", "Value": "https://google.com/"}'

We intend to add an option somehow for users to opt out of this.

joguSD avatar Jan 08 '18 18:01 joguSD

Thanks for the reply. This feature is actually really useful especially when used with file:// but only after running the command with debug mode and looking more into the source code I understood this is done to almost all the parameters.

Would it be possible to add a command line parameter for setting no_paramfile temporarily true?

otanner avatar Jan 08 '18 18:01 otanner

I've just encountered this too, it was very unexpected behaviour - especially as the documentation on this page https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_PutParameter.html does not express this clearly, or link to the page @joguSD linked to above

FYI I am using this to put a webhook URL in the parameter store

djhworld avatar Jan 22 '18 11:01 djhworld

This is not a good feature and definitely is surprising....

$ aws-vault exec home -- aws ssm put-parameter --name /ops/jenkins/jenkins_url --type String --value "http://ci.redact.us:8080"

Error parsing parameter '--value': Unable to retrieve http://ci.redact.us:8080: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

myoung34 avatar Jan 28 '18 20:01 myoung34

As you already have a list of commands that this feature is disbled for can ssm.put-parameter.value (this is probably not the correct nomenclature) be added to the PARAMFILE_DISABLED list in awscli/paramfile.py

There is a slight inconsistency in the documentation here as though the README.rst specifically mentions the file and uri params feature, the individual example file for SSM put-parameter also states that putting values in single quotes leaves them unchanged (I suspect you just mean that the shell doesn't expand them, not that they are immune to further processing).

ccdale avatar Jun 03 '18 05:06 ccdale

I've created a patch and tested it against python2.7, python3.5 and python3.6 - sorry, as I don't have access to python2.6/3.3/3.4 I can't test it against those, so haven't created a pull request. ssm-not-expand-param-value.patch.txt

ccdale avatar Jun 04 '18 11:06 ccdale

maybe if the single quotes themselves were part of the value, and not eaten by the shell, that would work ?

farrellit avatar Jun 15 '18 21:06 farrellit

Closing due to #3398

stealthycoin avatar Jul 02 '18 20:07 stealthycoin

Heads up to any future googlers, this is the fix:

aws configure set cli_follow_urlparam false

See: https://github.com/aws/aws-cli/pull/3384

twelvelabs avatar Apr 10 '20 18:04 twelvelabs