I am trying to pass a list of values from a aws cli query to another command. Even though I have seen plenty of examples in AWS, when I try all the values come together:
policy_versions=`aws iam list-policy-versions --query "Versions[].VersionId" --policy-arn $POLICY_ARN --output text`
echo "policy_versions=$policy_versions"
for ver in $policy_versions; do
echo "first version: $ver"
done
Which then prints out:
policy_versions=v3 v2 v1
first version: v3 v2 v1
My value of ver
is the entire string, it should be v3
then v2
and v1
. But It is instead:
v3 v2 v1
.
I cannot figure out what is wrong.