Command:
aws sqs set-queue-attributes --cli-input-json '{ "QueueUrl": "https://sqs.us-east-1.amazonaws.com/102278607205/permissiontest", "Attributes": { "RedrivePolicy": "{\"maxReceiveCount\":\"1\",\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:102278607204:dev-dead-letter-queue\"}" }}'
Error:
Error parsing parameter 'cli-input-json': Invalid JSON: Expecting property name enclosed in double quotes: line 1 column 6 (char 5) JSON received: { QueueUrl: https://sqs.us-east-.amazonaws.com/102278607205/permissiontest, Attributes: { RedrivePolicy: {"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:us-east-1:102278607204:dev-dead-letter-queue"} }}
This is probably powershell's fault...but what am I missing here?
I shouldn't have to do any crazy powershell "
escaping since the parameter is single quoted. The same command works fine on OSX/linux. Powershell escaping the double quotes with a backtick does nothing. Replacing all "
with ""
actually looks right in the error output, but throws up some new weird error that can't be accurate.
CLI Version: aws-cli/1.7.26 Python/2.7.9 Windows/7
Debug Output:
2015-05-12 13:28:50,115 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.7.26 Python/2.7.9 Windows/7, botocore version: 0.107.0
2015-05-12 13:28:50,115 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--debug', 'sqs', 'set-queue-attributes', '--cli-input-json', '{ QueueUrl: https://sqs.us-east-1.amazonaws.com/102278607205/permissiontest, Attributes: { RedrivePolicy: {"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:us-east-1:102278607204:dev-dead-letter-queue"} }}']
2015-05-12 13:28:50,115 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x00000000035B3A58>
2015-05-12 13:28:50,115 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider at 0x000000000353BA58>
2015-05-12 13:28:50,115 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.sqs: calling handler <function register_retries_for_service at 0x0000000002FC8F28>
2015-05-12 13:28:50,131 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: sqs
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event building-command-table.sqs: calling handler <function add_waiters at 0x0000000003542668>
2015-05-12 13:28:50,131 - MainThread - awscli.clidriver - DEBUG - OrderedDict([(u'queue-url', <awscli.arguments.CLIArgument object at 0x0000000003712128>), (u'attributes', <awscli.arguments.CLIArgument object at 0x0000000003712278>)])
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.sqs.set-queue-attributes:calling handler <function add_streaming_output_arg at 0x0000000003250A58>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.sqs.set-queue-attributes:calling handler <function add_cli_input_json at 0x0000000003533E48>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.sqs.set-queue-attributes:calling handler <function unify_paging_params at 0x000000000326E7B8>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.sqs.set-queue-attributes:calling handler <function add_generate_skeleton at 0x000000000353B208>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.sqs.set-queue-attributes: calling handler <bound method CliInputJSONArgument.override_required_args of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x00000000037121D0>>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.sqs.set-queue-attributes: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x00000000037122B0>>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.sqs.set-queue-attributes.queue-url: calling handler <function uri_param at 0x000000000321FE48>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.sqs.set-queue-attributes.attributes:calling handler <function uri_param at 0x000000000321FE48>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.sqs.set-queue-attributes.cli-input-json: calling handler <function uri_param at 0x000000000321FE48>
2015-05-12 13:28:50,131 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.sqs.set-queue-attributes.generate-cli-skeleton: calling handler <function uri_param at 0x000000000321FE48>
2015-05-12 13:28:50,145 - MainThread - botocore.hooks - DEBUG - Event calling-command.sqs.set-queue-attributes: callinghandler <bound method GenerateCliSkeletonArgument.generate_json_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x00000000037122B0>>
2015-05-12 13:28:50,145 - MainThread - botocore.hooks - DEBUG - Event calling-command.sqs.set-queue-attributes: callinghandler <bound method CliInputJSONArgument.add_to_call_parameters of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x00000000037121D0>>
2015-05-12 13:28:50,145 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
File "awscli\clidriver.pyc", line 183, in main
File "awscli\clidriver.pyc", line 369, in __call__
File "awscli\clidriver.pyc", line 517, in __call__
File "awscli\clidriver.pyc", line 614, in _emit_first_non_none_response
File "botocore\session.pyc", line 760, in emit_first_non_none_response
File "botocore\hooks.pyc", line 226, in emit
File "botocore\hooks.pyc", line 209, in _emit
File "awscli\customizations\cliinputjson.pyc", line 74, in add_to_call_parameters
ParamError: Error parsing parameter 'cli-input-json': Invalid JSON: Expecting property name enclosed in double quotes: l
ine 1 column 6 (char 5)
JSON received: { QueueUrl: https://sqs.us-east-1.amazonaws.com/102278607205/permissiontest, Attributes: { R
edrivePolicy: {"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:us-east-1:102278607204:dev-dead-letter-queue"}
}}
2015-05-12 13:28:50,145 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255
Error parsing parameter 'cli-input-json': Invalid JSON: Expecting property name enclosed in double quotes: line 1 column
6 (char 5)
JSON received: { QueueUrl: https://sqs.us-east-1.amazonaws.com/102278607205/permissiontest, Attributes: { R
edrivePolicy: {"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:us-east-1:102278607204:dev-dead-letter-queue"}
}}
@jdc0589
Based on the debug logs, it looks like there is some quotes missing thus making invalid JSON like there needs to be quotes around QueueUrl
, https://sqs.us-east-1.amazonaws.com/102278607205/permissiontest
, and Attributes
to say the least.
Windows powershell can differ a little from Linux and OSX when taking arguments from the command line. I would suggest using the file://
notation whenever using --cli-input-json
because it is a lot easier to keep track of the formatting of the JSON, and it is consistent across platforms.
Let me know if that helps.
Didn't know file://
was supported everywhere (haven't needed it before). Good to know.
Thanks.
file:// does indeed work, not sure why it's not in the docs...
Below is my code to run json with aws-cli (inside terraform) but getting a parsing error. I tried file:\filename.json, but it is not working.I am running my terraform via powershell.It works fine on linux but I am running my terraform via powershell then i m getting error.
resource "null_resource" "Scaling_Policy_write" {
provisioner "local-exec" {
command = "aws application-autoscaling put-scaling-policy --service-namespace dynamodb --resource-id 'table/${var.tablename}' --scalable-dimension 'dynamodb:table:WriteCapacityUnits' --policy-name 'MyScalingPolicy' --policy-type 'TargetTrackingScaling' --target-tracking-scaling-policy-configuration '{"PredefinedMetricSpecification":{"PredefinedMetricType":"DynamoDBWriteCapacityUtilization"},"ScaleOutCooldown":60,"ScaleInCooldown":60,"TargetValue":50}'"
}
}
error:
Error parsing parameter '--target-tracking-scaling-policy-configuration': Expected: '=', received: ''' for input:
'{"PredefinedMetricSpecification":{"PredefinedMetricType":"DynamoDBWriteCapacityUtilization"},"ScaleOutCooldown":60,"Sca
leInCooldown":60,"TargetValue":50}'
if you are giving command using powershell or bash script then remove the single quotes in json .
I also got the same error and was able to resolve with this
Steps in bash script or powershell:
Remove single quotes in json
donot escape quotes present inside json
there should be no space present inside that json
@jdc0589 try this , this should definately work:
aws sqs set-queue-attributes --cli-input-json {"QueueUrl": "https://sqs.us-east-1.amazonaws.com/102278607205/permissiontest","Attributes": {"RedrivePolicy": "{"maxReceiveCount":"1","deadLetterTargetArn":"arn:aws:sqs:us-east-1:102278607204:dev-dead-letter-queue"}" }}
@kyleknap suggested using
Most helpful comment
Didn't know
file://
was supported everywhere (haven't needed it before). Good to know.Thanks.