Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CLI - No JSON object could be decoded

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?

like image 726
DataGuy Avatar asked Jan 18 '16 22:01

DataGuy


People also ask

How do I run a JSON file in AWS CLI?

Those same commands helpfully provide the --generate-cli-skeleton parameter to generate a file in either JSON or YAML format with all of the parameters that you can edit and fill in. Then you can run the command with the relevant --cli-input-json or --cli-input-yaml parameter and point to the filled-in file.

How do I change the default output format in AWS CLI?

How to select the output format. As explained in the configuration topic, you can specify the output format in three ways: Using the output option in a named profile in the config file – The following example sets the default output format to text .

What command can be used to have the output in JSON format?

json/array. This option produces raw JSON wrapped in a JSON array. You can select these output formats by starting MySQL Shell with the --result-format= value command line option, or setting the MySQL Shell configuration option resultFormat .

Which is not output format of AWS CLI?

Output format The value can be any of the values in the following list. If you don't specify an output format, json is used as the default. json – The output is formatted as a JSON string. yaml – The output is formatted as a YAML string.


2 Answers

Here is an example command that works on Windows, where the file path syntax is a little different:

aws cloudwatch put-metric-data --namespace "EC2 Memory Usage" --metric-data file://C:\Users\Joe\mycode\metric.json
like image 53
Franke Avatar answered Sep 17 '22 15:09

Franke


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

like image 30
nybon Avatar answered Sep 21 '22 15:09

nybon