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

Created on 4 Jan 2018  ·  3Comments  ·  Source: aws/aws-cli

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

closing-soon

Most helpful comment

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.

All 3 comments

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.

Thanks. That solved the issue.

Same issue, this is outddated -

Was this page helpful?
0 / 5 - 0 ratings