AWS CLI - No JSON object could be decoded

DataGuy picture DataGuy · Jan 18, 2016 · Viewed 12.1k times · Source

Im using the CLI for AWS to create a cluster and use the parameters from a json file. Here is the CLI command string Im using:

aws emr create-cluster --name "Big Matrix Re Run 1" --ami-version 3.1.0 --steps file://Segmentgroup1.json --release-label --instance-groups InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m3.xlarge InstanceGroupType=CORE,InstanceCount=2,InstanceType=m3.xlarge --auto-terminate

My json file (Segmentgroup1.json) is in the same folder in which Im running the AWS command string from, but I keep getting the following error:

No JSON object could be decoded

Based on what Ive found its not finding the json file. Any ideas?

Answer

nybon picture nybon · Apr 10, 2017

I ran into the same problem under my Mac, and I found the cause is the path for the json file instead of the content of the json file. To make it right:

  • You need to append file:// protocol as the prefix for your path
  • and use absolute path to your JSON file as parameter

Try something like this:

aws ecs register-task-definition --cli-input-json file://<absolute_path_to_json>/your_json.json

If you don't want to hard code the file path, you may use command like pwd to do this:

aws ecs register-task-definition --cli-input-json file://`pwd`/your_json.json