class AWS::Core::RegionCollection
Provides a mechnasim to discover available regions. This can useful if you want to perform an operation for a service in every region.
# call the EC2 DescribeInstances operation in each region AWS.regions.each do |region| resp = region.ec2.client.describe_instances end
You can also use this collection as a shortcut for creating a service interface with a given region.
s3 = AWS.regions['us-west-1'].s3
This collection enumerates and returns {Region} objects.
@see Region
Attributes
config[R]
@return [Configuration]
Public Class Methods
new(options = {})
click to toggle source
@option options [Configuration] :config (AWS.config) @option options [ServiceInterface] :service (nil) @api private
# File lib/aws/core/region_collection.rb, line 44 def initialize options = {} @config = options[:config] || AWS.config @service = options[:service] end
Public Instance Methods
[](name)
click to toggle source
@param [String] name @return [Region] Returns a {Region} with the given name.
# File lib/aws/core/region_collection.rb, line 54 def [] name Region.new(name, :config => config) end
each() { |self| ... }
click to toggle source
Enumerates public regions (non US Gov regions). @yieldparam [region] Region
# File lib/aws/core/region_collection.rb, line 60 def each &block public_regions.each do |region_name| yield(self[region_name]) end end
Private Instance Methods
public_regions()
click to toggle source
@return [Array<String>] Returns an array of non-gov-cloud region names.
# File lib/aws/core/region_collection.rb, line 69 def public_regions return ['us-east-1'] if @service and @service.global_endpoint? data = Endpoints.endpoints regions = @service ? data['services'][@service.endpoint_prefix] : data['regions'].keys regions.reject{ |r| r =~ /us-gov/ }.reject{ |r| r =~ /^cn-/ } end