Skip to content

Instantly share code, notes, and snippets.

@snandam
Last active March 15, 2024 16:33
Show Gist options
  • Save snandam/4776360c58ceec6b7754c0e6ccc3a8f5 to your computer and use it in GitHub Desktop.
Save snandam/4776360c58ceec6b7754c0e6ccc3a8f5 to your computer and use it in GitHub Desktop.
Identify AWS regions a particular instance type is available
####################
# IAM user need to have "ec2:DescribeInstanceTypeOfferings" permission to be able to run this
####################
#!/bin/bash
instance_type=g5g.2xlarge
echo "Region $instance_type Availability"
echo "------ -------------------------"
aws ec2 describe-regions --query "Regions[].RegionName" --output text | tr '\t' '\n' | while read region; do
availability=$(aws ec2 describe-instance-type-offerings --region "$region" --location-type region --filters Name=instance-type,Values=$instance_type --query "InstanceTypeOfferings[]" --output text)
if [[ -z $availability ]]; then
echo "$region False"
else
echo "$region True"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment