class AWS::Core::RegionCollection

@see Region
This collection enumerates and returns {Region} objects.
s3 = AWS.regions.s3
a service interface with a given region.
You can also use this collection as a shortcut for creating
end
resp = region.ec2.client.describe_instances
AWS.regions.each do |region|
# call the EC2 DescribeInstances operation in each region
you want to perform an operation for a service in every region.
Provides a mechnasim to discover available regions. This can useful if

def [] name

Returns:
  • (Region) - Returns a {Region} with the given name.

Parameters:
  • name (String) --
def [] name
  Region.new(name, :config => config)
end

def clear!

Other tags:
    Api: - private

Returns:
  • (nil) -
def clear!
  @data = nil
end

def data

Other tags:
    Api: - private

Returns:
  • (Hash) - Returns a hash of region metadata.
def data
  @data ||= load_data
end

def each &block

Other tags:
    Yieldparam: Region -
def each &block
  public_regions.each do |region_name|
    yield(self[region_name])
  end
end

def initialize options = {}

Other tags:
    Api: - private

Options Hash: (**options)
  • :service (ServiceInterface) --
  • :config (Configuration) --
def initialize options = {}
  @config = options[:config] || AWS.config
  @service = options[:service]
end

def load_data

Returns:
  • (Hash) -
def load_data
  #return JSON.parse(File.read(File.join(AWS::ROOT, 'endpoints.json')))
  host = 'aws-sdk-configurations.amazonwebservices.com'
  path = '/endpoints.json'
  http = Net::HTTP
  proxy = AWS.config.proxy_uri
  http = Net::HTTP::Proxy(proxy.host, proxy.port) unless proxy.nil?
  JSON.parse(http.get(host, path))
end

def public_regions

Returns:
  • (Array) - Returns an array of non-gov-cloud region names.
def public_regions
  return ['us-east-1'] if @service and @service.global_endpoint?
  data = self.class.data
  regions = @service ?
    data['services'][@service.endpoint_prefix] :
    data['regions'].keys
  regions.reject{|r| r =~ /us-gov/ }
end