2

I can't seem to create a tag on a resource if the value contains a quote. For example:

aws ec2 create-tags --resource $someResource --tags 'Key=mykey,Value={"json":"value"}'

fails with:

Error parsing parameter '--tags': should be: Key value pairs, with multiple values separated by a space.

But if I run it without the quotes in the value, it succeeds:

aws ec2 create-tags --resource $someResource --tags 'Key=mykey,Value={json:value}'

I've tried a few different combinations of quoting/escaping, but I just can't seem to set the JSON value from the CLI.

For completeness, I updated my tools yesterday:

aws --version
aws-cli/1.3.6 Python/2.7.5 Darwin/13.1.0

Thanks!

  • Are you using Windows? – Céline Aussourd Apr 17 '14 at 11:20
  • Negative, this is from a Mac running 10.9.2 – Gary Richardson Apr 18 '14 at 16:17
  • In a similar environment (OSX, Python 2.7, aws-cli 1.3.7), I can use the JSON syntax this way: aws ec2 create-tags --resource $someResource --tags '{"Key":"myKey","Value":"myvalue"}' Does it answer your question? I'm not sure how you want to use JSON... – Céline Aussourd Apr 23 '14 at 11:43
  • I believe this issue is more general, in that you can't have a double-quote in the value from the command line. – Parker Oct 30 '14 at 16:29
2

Bumped into the same problem, and found a way to circumvent this unexpected behaviour I think: aws ec2 create-tags --resource $someResource --tags Key=mykey,Value='"{\"json\":\"value\"}"'

A bit overdue maybe, but someone might find it useful. The matter is that the awscli seems to try to parse what's inside the quotes to a variable, and if it is not default to a string, it will give an error. So within the quotes, another set of quotes needs to be used, so that it will default to a string.

| improve this answer | |
  • This didn't directly solve the issue that I was having, but it lead to it. I already had some escaped quotes ( \" ) in the string that I was needing to pass. I doubly escaped them with ( \\\") and it worked for me. I was AWS CLI to call SQS. – Itsme2003 Feb 13 '17 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.