0

I'm trying to run the following command to create a custom integration request body mapping template from the cli, but as the JSON output shows, it is removing values with a $ before them. How do I get around this?

Command:

aws apigateway update-integration --rest-api-id aoi84daah3 --resource-id jh5tps --http-method POST --patch-operations "op='add',path='/requestTemplates/application~1json',value='{"api_name" : "$context.resourcePath","http-method" :"$context.httpMethod"}'"

Output:

"requestTemplates": {
    "application/json": "{api_name : .resourcePath,http-method :.httpMethod}"
Ludo
  • 2,307
  • 2
  • 27
  • 58
  • [How to escape quotes in shell?](https://unix.stackexchange.com/q/30903/56041), [How to escape a double quote inside double quotes?](https://stackoverflow.com/q/3834839/608639), [How does bash deal with nested quotes?](https://stackoverflow.com/q/25941394/608639), etc. – jww May 19 '18 at 08:19

1 Answers1

0

It's also removing your quotes. In the shell, both $ and " inside a string also quoted with " must be escaped with \.

 "op='add',path='/requestTemplates/application~1json',value='{\"api_name\" : \"\$context.resourcePath\",\"http-method\" :\"\$context.httpMethod\"}'"
Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427