Casper
Casper

Reputation: 1723

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!!!

Upvotes: 1

Views: 2732

Answers (3)

snowpeak
snowpeak

Reputation: 867

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.

Upvotes: 0

owais
owais

Reputation: 4922

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

Here is the detailed issue regarding double quotes in aws cli https://github.com/aws/aws-cli/issues/2638

Upvotes: 2

helloV
helloV

Reputation: 52423

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

Upvotes: 4

Related Questions