, , - :
$ for ID in $(aws ec2 describe-instances --region eu-west-1 --query "Reservations[].Instances[].InstanceId" --output text); do echo $ID ; echo $(aws ec2 describe-instances --region eu-west-1 --query "Reservations[].Instances[?InstanceId==\`$ID\`].Tags[]") done
i-60****2a
[ [ { "Value": "SB", "Key": "Name" } ] ]
i-1a****56
[ [ { "Value": "Course and Schedule on Apache 2.4", "Key": "Name" } ] ]
i-88eff3cb
[ [ { "Value": "secret.com", "Key": "Name" } ] ]
i-e7****a5
[ [ { "Value": "2014.03 + Docker", "Key": "Name" } ] ]
I could not find a way to do this with just one AWS CLI call. If someone comes up with a shorter solution, I would like to hear from you.
If you want to filter only those key / value tags, you can edit aws ec2 describe-instancesto add a parameter --filter.
For instance:
aws ec2 describe-instances --region eu-west-1 --filter "Name=tag:Name,Values=SB"
- seb
source
share