Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::EC2::RegionCollection

Inherits:
Collection show all
Defined in:
lib/aws/ec2/region_collection.rb

Overview

Represents all the regions available to your account.

Examples:

Getting a map of endpoints by region name

ec2.regions.inject({}) { |m, r| m[r.name] = r.endpoint; m }

Instance Method Summary collapse

Methods included from FilteredCollection

#filter, #initialize

Instance Method Details

#[](name) ⇒ Region

Returns The region identified by the given name (e.g. "us-west-2").

Returns:

  • (Region)

    The region identified by the given name (e.g. "us-west-2").

[View source]

38
39
40
# File 'lib/aws/ec2/region_collection.rb', line 38

def [](name)
  super
end

#each {|Region| ... } ⇒ nil

Yields:

  • (Region)

    Each region that is available to your account.

Returns:

  • (nil)
[View source]

25
26
27
28
29
30
31
32
33
34
# File 'lib/aws/ec2/region_collection.rb', line 25

def each
  response = filtered_request(:describe_regions)
  response.region_info.each do |r|
    region = Region.new(r.region_name,
                        :endpoint => r.region_endpoint,
                        :config => config)
    yield(region)
  end
  nil
end