I am able to send simple commands to some of my Amazon ec2 instances. For example:
aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids "${instanceid}" --parameters commands=["cd /home/ec2-user","mkdir -p test"]
aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids "${instanceid}" --parameters commands=["cd /home/ec2-user","sudo chmod 777 test"]
I can also echo text to a sample file:
aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids "${instanceid}" --parameters commands=["cd /home/ec2-user","echo thisvalue = temp >> test/sample.txt"]
However, if I use a bracket as part of the command / text, for example:
aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids "${instanceid}" --parameters commands=["cd /home/ec2-user","echo [default] > test/sample.txt"]
I get the following error:
Error parsing parameter '--parameters': Expected: ',', received: '>' for input:
When the text is wrapped in brackets [] the issue is thrown. Therefore, the question boils down to: how am I able to pass 'special' characters through the aws ssm send-command function?