class AWS::EC2::Region

Represents an EC2 region. You can use this to find the endpoint for a given region:

ec2.regions["us-west-1"].endpoint

Region also responds to all of the methods of {EC2} except {EC2#regions}; for example, to list instance IDs by region, you can do:

ec2.regions.inject({}) do |h,region|
  h[region.name] = region.instances.map(&:id)
  h
end

@attr_reader [String] endpoint The endpoint to use for this region

(e.g. "ec2.eu-west-1.amazonaws.com").

Constants

PROXIED_METHODS

Attributes

client[R]

@return [Client]

config[R]

@return [Core::Configuration]

endpoint[R]

@return [String]

name[R]

@return [String] The name of the region (e.g. “us-west-2”).

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/aws/ec2/region.rb, line 36
def initialize name, options = {}
  @name = name
  @endpoint = options[:endpoint] || "ec2.#{name}.amazonaws.com"
  @client = Client.new(options.merge(:endpoint => endpoint))
  @config = @client.config
end

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source

@param [Region] other @return [Boolean]

# File lib/aws/ec2/region.rb, line 66
def eql? other
  other.is_a?(Region) and
  other.name == name and
  other.endpoint == endpoint
end
Also aliased as: ==
exists?() click to toggle source

@return [Boolean] True if the region is available for this

account.
# File lib/aws/ec2/region.rb, line 57
def exists?
  client.describe_regions(:region_names => [name])
  true
rescue Errors::InvalidParameterValue
  false
end