I'm using aws ssm to perform operation task. when executing command similar to the following (details are replaced), The value of variable i is not set correctly when being used in remote execution
What's wrong with my code?
aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids $instance_id \
--parameters '{"commands":["count=4; for i in { 1..$count }; do echo $i; ssh $(server_$i) bash -c '"'echo $i && echo $(date +%Y-%m-%d)'"'; done;"],"executionTimeout":["3600"]}' \
--timeout-seconds 600 --region us-west-2
- the first echo will return 1, 2, 3, 4
- however the second echo will return 4, 4, 4, 4
Expect: both should return 1,2,3,4