简体   繁体   中英

How to escape curly bracket in AWS CLI Bash

I'm trying to use AWS CLI Lambda to replace environment variables. However the value I want to replace has a pair of curly braces in it and CLI complaints about json format even when I already put the whole thing in single quote. Here's my command:

aws lambda update-function-configuration --function-name myFunc --environment Variables={URL='http://example.com/api/{0}'}

Here's the error:

Error parsing parameter '--environment': Expected: ',', received: '}' for input:

The funny thing is that if I removed the closing bracket } , it worked:

aws lambda update-function-configuration --function-name myFunc --environment Variables={URL='http://example.com/api/{0'}

Please help!!!

Enclose in double quotes:

Variables="{URL='http://example.com/api/{0}'}"

aws lambda update-function-configuration --function-name myFunc --environment Variables="{URL='http://example.com/api/{0}'}"

An error occurred (ResourceNotFoundException) when calling the UpdateFunctionConfiguration operation: Function not found: arn:aws:lambda:us-west-1:1234567890:function:myFunc

aws lambda update-function-configuration --function-name myFunc --environment "Variables={URL='http://example.com/api/{0}'}"

这是有关aws cli中双引号的详细问题https://github.com/aws/aws-cli/issues/2638

This worked, my command is different though.

aws apigateway update-resource \
    --rest-api-id <rest_api_id> \
    --resource-id <resource_id> \
    --patch-operations 'op=replace,path=/pathPart,value="{something}"'

The points are:

  • Single quote to for the whole argument,
  • Double quote to for the outer curly bracket.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM