Question

I am trying to get all available zones of EC2 servers but api call returns only availability zones of one region

AWS::EC2.new.availability_zones.to_a.map(&:name)
=> ["us-east-1b", "us-east-1c", "us-east-1d"]
Was it helpful?

Solution

Amazon distinguishes between "regions" and "Availability zones". From Amazon documentation:

Each Region contains multiple distinct locations called Availability Zones. Each Availability Zone is engineered to be isolated from failures in other Availability zones and to provide inexpensive, low-latency network connectivity to other zones in the same Region

You can use the Ruby SDK to see which regions are available for your account:

AWS::EC2.new.regions.map(&:name)

The default region is us-east-1; you can access other regions like this:

ec2 = AWS::EC2.new(:region => "us-west-1")
ec2.instances.create(:image_id => 'ami-3bc9997e')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top