AWS EC2 RunCommand parsing issue

317 Views Asked by At

When I try to use the shorthand for this it fails with the following error. I'm obviously not escaping correctly but I can't seem to work out how to do so. It happens in PowerShell and Command Prompt.

Unknown options: ) aws s3 cp s3://sourcebucket/file1.csv /opt/local/file1.csv;docker exec $(docker ps | grep "solr" | cut -f1 -d" ") aws s3 cp s3://sourcebucket/file2.csv /opt/local/file2.csv;curl http://localhostreloadfiles' --timeout-seconds 600 --region eu-west-10

Shorthand invalid:

aws ssm send-command --document-name "AWS-RunShellScript" --targets Key=tag:Name,Values=instancename --parameters commands='docker exec $(docker ps grep "solr" | cut -f1 -d" ") aws s3 cp s3://sourcebucket/file1.csv /opt/local/file1.csv;docker exec $(docker ps | grep "solr" | cut -f1 -d" ") aws s3 cp s3://sourcebucket/file2.csv /opt/local/file2.csv;curl http://localhostreloadfiles' --timeout-seconds 600 --region eu-west-10

JSON input valid:

aws ssm send-command --document-name "AWS-RunShellScript" --targets Key=tag:Name,Values=instancename --parameters '{\"commands\":[\"docker exec $(docker ps | grep \\"containername\\" | cut -f1 -d\\" \\") bash -c ''aws s3 cp s3://sourcebucket/file1.csv /opt/local/file1.csv''\",\"docker exec $(docker ps | grep \\"solr\\" | cut -f1 -d\\" \\") bash -c ''aws s3 cp s3://sourcebucket/file2.csv /opt/local/file2.csv''\",\"curl http://localhost/reloadfiles\"]}' --timeout-seconds 600 --region eu-west-1

The guide and walkthrough both suggest it's possible and I'd like to make it much more readable and understandable for my team.

http://docs.aws.amazon.com/cli/latest/reference/ssm/send-command.html http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/walkthrough-cli.html

0

There are 0 best solutions below