How to see all running Amazon EC2 instances across all regions?

前端 未结 17 1276
囚心锁ツ
囚心锁ツ 2021-01-29 23:03

I switch instances between different regions frequently and sometimes I forget to turn off my running instance from a different region. I couldn\'t find any way to see all the r

17条回答
  •  心在旅途
    2021-01-29 23:06

    I don't think you can currently do this in the AWS GUI. But here is a way to list all your instances across all regions with the AWS CLI:

    for region in `aws ec2 describe-regions --region us-east-1 --output text | cut -f4`
    do
         echo -e "\nListing Instances in region:'$region'..."
         aws ec2 describe-instances --region $region
    done
    

    Taken from here (If you want to see full discussion)

    Also, if you're getting a

    You must specify a region. You can also configure your region by running "aws configure"

    You can do so with aws configure set region us-east-1, thanks @Sabuncu for the comment.

    Update

    Now (in 2019) the cut command should be applied on the 4th field: cut -f4

提交回复
热议问题