こんな感じで、シングルクォーテーションを含んだコマンドを実行するとエラーになります。
$ CMD="sudo su - ec2-user -c 'ls -l /'" $ aws ssm send-command \ --document-name "AWS-RunShellScript" \ --comment "test" \ --instance-ids i-0f70020feb5f861ce \ --parameters commands="$CMD" Error parsing parameter '--parameters': Expected: ',', received: ''' for input: commands=sudo su - ec2-user -c 'ls -l /'
これを、下記のように --parameters の引数をjson形式にすると実行できました。
$ aws ssm send-command \ --document-name "AWS-RunShellScript" \ --comment "test" \ --instance-ids i-0f70020feb5f861ce \ --parameters "{\"commands\":[\"$CMD\"]}"