Skip to content

Instantly share code, notes, and snippets.

@santhosh007K
Forked from junaidk/ec2.sh
Created January 19, 2020 06:06
Show Gist options
  • Save santhosh007K/e4f0c9ba53cd276addf658a8166cf1e2 to your computer and use it in GitHub Desktop.
Save santhosh007K/e4f0c9ba53cd276addf658a8166cf1e2 to your computer and use it in GitHub Desktop.
Get List of EC2 instances from All regions
# install aws cli first and configure it with credentials and default region
# the script will iterate over all regions of AWS
for region in `aws ec2 describe-regions --output text | cut -f4`
do
echo -e "\nListing Instances in region:'$region'..."
aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table --region $region
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment