Class: AWS::EC2::InternetGateway::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/ec2/internet_gateway/attachment.rb

Overview

Represents the attachment between an internet gateway and a VPC.

Creating Attachments

To create an attachment, just assign an internet gateway to a VPC or visa versa.

# attaches a gateway to a vpc
internet_gateway.vpc = vpc

# this can also be done in reverse
vpc.internet_gateway = internet_gateway

Enumerating Attachments

You can enumerate the attachments for an AWS::EC2::InternetGateway like so:

internet_gateway.attachments.each do |attachment|
   puts "#{attachment.internet_gateway.id} => #{attachment.vpc.id}"
end

Deleting Attachments

You can delete an attachment from the Attachment object:

internet_gateway.attachments.each(&:delete)

You can also delete an attachment by assigning a nil value:

# removes the current attachment to the vpc is one exists
internet_gateway.vpc = nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#internet_gatewayInternetGateway (readonly)

Returns:



60
61
62
# File 'lib/aws/ec2/internet_gateway/attachment.rb', line 60

def internet_gateway
  @internet_gateway
end

#stateSymbol (readonly)

Returns:

  • (Symbol)


66
67
68
# File 'lib/aws/ec2/internet_gateway/attachment.rb', line 66

def state
  @state
end

#vpcVPC (readonly)

Returns:



63
64
65
# File 'lib/aws/ec2/internet_gateway/attachment.rb', line 63

def vpc
  @vpc
end

Instance Method Details

#deletenil Also known as: detach

Deletes this attachment.

Returns:

  • (nil)


70
71
72
# File 'lib/aws/ec2/internet_gateway/attachment.rb', line 70

def delete
  internet_gateway.detach(vpc)
end