I'm trying to run a command using AWS CLI to get some values from a Postgres table, but the command I write is changed when it reaches AWS Run Command.
So, the command I'm running through CLI is:
aws ssm send-command \
--document-name 'AWS-RunShellScript' \
--parameters commands='PGPASSWORD=xxx psql -h db-instance-xxx.rds.amazonaws.com -U user -d db -c '"select * from database.table"'' \
--instance-ids instanceID \
--profile profile
The command I see when I check the command history in the AWS Console:
"PGPASSWORD=xxx psql -h db-instance-xxx.rds.amazonaws.com -U user -d db -c select * from database.table"
This is failing because it's missing the single quotes after -c, I mean it should look like this:
(...) -c 'select * from database.table'"
How can I solve this?