Class: AWS::EC2::InternetGateway
- Inherits:
-
Resource
- Object
- Core::Resource
- Resource
- AWS::EC2::InternetGateway
- Includes:
- TaggedItem
- Defined in:
- lib/aws/ec2/internet_gateway.rb,
lib/aws/ec2/internet_gateway/attachment.rb
Defined Under Namespace
Classes: Attachment
Instance Attribute Summary collapse
- #internet_gateway_id ⇒ String (also: #id) readonly
Instance Method Summary collapse
-
#attach(vpc) ⇒ nil
Attaches this internet gateway to the given VPC.
- #attachments ⇒ Array<InternetGateway::Attachment>
-
#delete ⇒ nil
Deletes this internet gateway.
-
#detach(vpc) ⇒ nil
Detaches this internet gateway from the given VPC.
-
#exists? ⇒ Boolean
Returns true if the gateway exists.
-
#initialize(internet_gateway_id, options = {}) ⇒ InternetGateway
constructor
A new instance of InternetGateway.
-
#vpc ⇒ VPC?
Returns the currently attached VPC, or nil if this gateway has not been attached.
-
#vpc=(vpc) ⇒ Object
Attaches this internet gateway to the given VPC.
Methods included from TaggedItem
Constructor Details
#initialize(internet_gateway_id, options = {}) ⇒ InternetGateway
Returns a new instance of InternetGateway.
23 24 25 26 |
# File 'lib/aws/ec2/internet_gateway.rb', line 23 def initialize internet_gateway_id, = {} @internet_gateway_id = internet_gateway_id super end |
Instance Attribute Details
#internet_gateway_id ⇒ String (readonly) Also known as: id
29 30 31 |
# File 'lib/aws/ec2/internet_gateway.rb', line 29 def internet_gateway_id @internet_gateway_id end |
Instance Method Details
#attach(vpc) ⇒ nil
Attaches this internet gateway to the given VPC.
77 78 79 80 81 82 83 |
# File 'lib/aws/ec2/internet_gateway.rb', line 77 def attach vpc client_opts = {} client_opts[:internet_gateway_id] = internet_gateway_id client_opts[:vpc_id] = vpc_id_option(vpc) client.attach_internet_gateway(client_opts) nil end |
#attachments ⇒ Array<InternetGateway::Attachment>
46 47 48 |
# File 'lib/aws/ec2/internet_gateway.rb', line 46 def .map {|details| Attachment.new(self, details) } end |
#delete ⇒ nil
Deletes this internet gateway.
98 99 100 101 102 103 |
# File 'lib/aws/ec2/internet_gateway.rb', line 98 def delete client_opts = {} client_opts[:internet_gateway_id] = internet_gateway_id client.delete_internet_gateway(client_opts) nil end |
#detach(vpc) ⇒ nil
Detaches this internet gateway from the given VPC.
88 89 90 91 92 93 94 |
# File 'lib/aws/ec2/internet_gateway.rb', line 88 def detach vpc client_opts = {} client_opts[:internet_gateway_id] = internet_gateway_id client_opts[:vpc_id] = vpc_id_option(vpc) client.detach_internet_gateway(client_opts) nil end |
#exists? ⇒ Boolean
Returns true if the gateway exists.
106 107 108 109 110 111 112 113 |
# File 'lib/aws/ec2/internet_gateway.rb', line 106 def exists? begin get_resource true rescue Errors::InvalidInternetGatewayID::NotFound false end end |
#vpc ⇒ VPC?
Returns the currently attached VPC, or nil if this gateway has not been attached.
52 53 54 55 56 |
# File 'lib/aws/ec2/internet_gateway.rb', line 52 def vpc if = .first .vpc end end |
#vpc=(vpc) ⇒ Object
Attaches this internet gateway to the given VPC. If this gateway is already attached to a different VPC, it will be detached from that one first. If you pass nil, then this internet gateway will
internet_gateway.vpc = 'vpc-123'
67 68 69 70 71 72 |
# File 'lib/aws/ec2/internet_gateway.rb', line 67 def vpc= vpc if = .first .delete end attach(vpc) if vpc end |