aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Error parsing parameter '--targets': Expected: '=', received: ''' for input: '{"Key":"tag:Name","Values":["LDAPHost_env-sandbox"]}'

Open hapx101 opened this issue 8 years ago • 3 comments

I am using AWS EC2 SSM for doing an automated deployment from Jenkins build pipeline. A SSM document to run a shell script is provided in the SSM document. The jenkins pipeline form the following command:

aws ssm send-command --document-name "Testdeployment" --targets '{"Key":"tag:Name","Values":["LDAPHost_env-sandbox"]}' --max-concurrency "1" --max-errors "1" --parameters '{"bucketName":["s3://testBucket"],"workingDirectory":["/tmp/"],"releaseName":["sandbox-v1"]}' --timeout-seconds 3600 --output-s3-bucket-name "testBucket" --output-s3-key-prefix "sandbox-v1/test/ssm/log" --region eu-west-1

Error message:

Error parsing parameter '--targets': Expected: '=', received: ''' for input:
'{"Key":"tag:Name","Values":["LDAPHost_env-sandbox"]}'

Configuration: OS: Ubuntu 16.04.2 LTS AWS CLI: 1.11.122 Python: 2.7.12 Linux: 4.4.0-1044-aws botocore:1.5.85

hapx101 avatar Jan 04 '18 16:01 hapx101

This looks like a quoting issue with jenkins. When I run your command directly in the terminal I don't get that error:

$ aws ssm send-command --document-name "Testdeployment" --targets '{"Key":"tag:Name","Values":["LDAPHost_env-sandbox"]}' --max-concurrency "1" --max-errors "1" --parameters '{"bucketName":["s3://testBucket"],"workingDirectory":["/tmp/"],"releaseName":["sandbox-v1"]}' --timeout-seconds 3600 --output-s3-bucket-name "testBucket" --output-s3-key-prefix "sandbox-v1/test/ssm/log" --region eu-west-1

An error occurred (InvalidDocument) when calling the SendCommand operation:

To debug this issue, run the command with --debug and you'll see the exact string that the CLI is receiving:

2018-01-04 13:27:37,186 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.14.18 Python/2.7.14 Darwin/16.7.0 botocore/1.8.22
2018-01-04 13:27:37,186 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['ssm', 'send-command', '--document-name', 'Testdeployment', '--targets', '{"Key":"tag:Name","Values":["LDAPHost_env-sandbox"]}', '--max-concurrency', '1', '--max-errors', '1', '--parameters', '{"bucketName":["s3://testBucket"],"workingDirectory":["/tmp/"],"releaseName":["sandbox-v1"]}', '--timeout-seconds', '3600', '--output-s3-bucket-name', 'testBucket', '--output-s3-key-prefix', 'sandbox-v1/test/ssm/log', '--region', 'eu-west-1', '--debug']

I suspect what you'll see is that the single quote is being passed along to the CLI, whereas normally when you run the command interactively you're shell will strip out the single quotes before passing it to python.

If you're still seeing the issue, please post your debug logs with the "Arguments entered to CLI" line and I'll take another look.

jamesls avatar Jan 04 '18 21:01 jamesls

Thanks. That solved the issue.

hapx101 avatar Jan 05 '18 11:01 hapx101

Same issue, this is outddated -

Iorek73 avatar Nov 19 '19 02:11 Iorek73