I am trying to run AWS CLI in Powershell 7 with a JSON string as parameter. AWS docs make it seem straightforward:
aws route53 ... --change-batch '{"Changes":[{"Action":"UPSERT"}]}'
however, I get an error:
Error parsing parameter '--change-batch': Invalid JSON: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) JSON received: {Changes:[{Action:UPSERT ...
So, it looks like double quotes are stripped at some point.
If I escape the quotes, command works:
aws route53 ... --change-batch '{\"Changes\":[{\"Action\":\"UPSERT\"}]}'
Now, I am trying to use a variable:
aws route53 ... --change-batch '{\"Changes\":[{\"Action\":\"UPSERT\", \"Value\":\"$MY_IP\"}]}'
but the variable is not resolved; that is, $MY_IP
is passed to the server. I tried putting the whole string in double-quotes - but it looks like with double quotes internal quotes are removed even if I escape them. Also with backticks - it works as command continuation. I am looking at Microsoft docs - but the results I am getting are clearly different.
I don't think the problem has anything to do with AWS, but AWS CLI gave me a super twisted test case.