Class: AWS::EC2::Region
- Inherits:
-
Resource
- Object
- Resource
- AWS::EC2::Region
- Defined in:
- lib/aws/ec2/region.rb
Overview
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 AWS::EC2 except #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
Constant Summary collapse
- PROXIED_METHODS =
[:instances, :security_groups, :key_pairs, :elastic_ips, :tags, :availability_zones, :images, :volumes, :snapshots, :reserved_instances, :reserved_instances_offerings]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the region (e.g. “us-east-1”).
Instance Method Summary collapse
-
#endpoint ⇒ String
The endpoint to use for this region.
-
#exists? ⇒ Boolean
True if the region is available for this account.
-
#initialize(name, options = {}) ⇒ Region
constructor
A new instance of Region.
Constructor Details
#initialize(name, options = {}) ⇒ Region
Returns a new instance of Region.
37 38 39 40 |
# File 'lib/aws/ec2/region.rb', line 37 def initialize(name, = {}) @name = name super() end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the region (e.g. “us-east-1”)
35 36 37 |
# File 'lib/aws/ec2/region.rb', line 35 def name @name end |
Instance Method Details
#endpoint ⇒ String
Returns The endpoint to use for this region.
43 |
# File 'lib/aws/ec2/region.rb', line 43 def endpoint; end |
#exists? ⇒ Boolean
Returns True if the region is available for this account.
48 49 50 51 52 |
# File 'lib/aws/ec2/region.rb', line 48 def exists? !client.describe_regions(:filters => [{ :name => "region-name", :values => [name] }]). region_info.empty? end |