aws – iterate instances across all regions

By polfilm,

  Filed under: AWS, Bash
  Comments: None

describe_all_instances.sh

for region in `aws ec2 describe-regions --output text | cut -f3`
do
     echo -e "\nListing Instances in region:'$region'..."
     aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, name: .KeyName, type: .InstanceType, key: .KeyName})'
done

describe_all_stacks.sh

for region in `aws ec2 describe-regions --output text | cut -f3`
do
     echo -e "\nListing Stacks in region:'$region'..."
     aws cloudformation describe-stacks --region $region | jq '( .Stacks[] | {stackid: .StackId, status: .StackStatus})'
done

Comments are closed for this post.