Search code examples
amazon-web-servicesshellaws-cliamazon-connect

How can I read in a JSON file and pass it in the command line?


I'm implementing a script that will be used to update a contact flow in AWS Connect. I have a JSON file definining the flow, which is managed separately in source control. I want to implement a script using the aws connect api to update the flow using the AWS CLI endpoint.

INSTANCE_ID=123456-789
CONTACT_ID=9876-1234
aws connect update-contact-flow-content \
  --instance-id $INSTANCE_ID \
  --contact-flow-id $CONTACT_ID \
  --content '$(cat contactflow.json | jq -c )'

However, reading it in like this doesn't properly escape the JSON. How can I read in this data in a way that properly escapes it, or otherwise passes the full JSON file to AWS?


Solution

  • Based on the comments.

    The solution is to use file:// notation to read json form the file as explained in aws format docs here:

    --content file://contactflow.json