Class: AWS::EC2::VPC

Inherits:
Resource
  • Object
show all
Includes:
TaggedItem
Defined in:
lib/aws/ec2/vpc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TaggedItem

#add_tag, #clear_tags, #tags

Constructor Details

#initialize(vpc_id, options = {}) ⇒ VPC



25
26
27
28
# File 'lib/aws/ec2/vpc.rb', line 25

def initialize vpc_id, options = {}
  @vpc_id = vpc_id
  super
end

Instance Attribute Details

#cidr_blockString (readonly)



21
22
23
# File 'lib/aws/ec2/vpc.rb', line 21

def cidr_block
  @cidr_block
end

#dhcp_options_idString (readonly)



21
22
23
# File 'lib/aws/ec2/vpc.rb', line 21

def dhcp_options_id
  @dhcp_options_id
end

#instance_tenancySymbol (readonly)



21
22
23
# File 'lib/aws/ec2/vpc.rb', line 21

def instance_tenancy
  @instance_tenancy
end

#stateSymbol (readonly)



21
22
23
# File 'lib/aws/ec2/vpc.rb', line 21

def state
  @state
end

#vpc_idString (readonly) Also known as: id



31
32
33
# File 'lib/aws/ec2/vpc.rb', line 31

def vpc_id
  @vpc_id
end

Instance Method Details

#deletenil

Deletes the current VPC. The VPC must be empty before it can be deleted.



54
55
56
57
# File 'lib/aws/ec2/vpc.rb', line 54

def delete
  client.delete_vpc(:vpc_id => vpc_id)
  nil
end

#dhcp_optionsDHCPOptions



141
142
143
# File 'lib/aws/ec2/vpc.rb', line 141

def dhcp_options
  DHCPOptions.new(dhcp_options_id, :config => config)
end

#dhcp_options=(dhcp_options) ⇒ Object

Associates the given dhcp options with this VPC.

vpc.dhcp_optinos = ec2.dhcp_options['dopt-a1234abc']

You can also specify the string ‘default’ to use Amazon’s default dhcp options.

vpc.dhcp_optinos = 'default'


157
158
159
160
161
162
# File 'lib/aws/ec2/vpc.rb', line 157

def dhcp_options= dhcp_options
  unless dhcp_options.is_a?(DHCPOptions) 
    dhcp_options = DHCPOptions.new(dhcp_options, :config => config)
  end
  dhcp_options.associate(self)
end

#instancesInstanceCollection



61
62
63
# File 'lib/aws/ec2/vpc.rb', line 61

def instances
  InstanceCollection.new(:config => config).filter('vpc-id', vpc_id)
end

#internet_gatewayInternetGateway?



98
99
100
101
# File 'lib/aws/ec2/vpc.rb', line 98

def internet_gateway
  gateways = InternetGatewayCollection.new(:config => config)
  gateways.filter('attachment.vpc-id', vpc_id).first
end

#internet_gateway=(internet_gateway) ⇒ Object

Attaches the given internet gateway to this VPC. If there is already an internet gateway attached, it will be detached from this VPC first. If you pass nil, this will leave the current VPC without an attached internet gateway.

vpc.internet_gateway = gateway_1
vpc.internet_gateway = gateway_2 # detaches gateway_1 first
vpc.internet_gateway = nil # detaches gateway_2


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/aws/ec2/vpc.rb', line 115

def internet_gateway= internet_gateway

  # remove currently attached internet gateway
  gateway = self.internet_gateway
  gateway.detach(self) if gateway

  if internet_gateway
    unless internet_gateway.is_a?(InternetGateway)
      internet_gateway = InternetGateway.new(internet_gateway, 
        :config => config)
    end
    internet_gateway.attach(self)
  end
  
end

#network_aclsNetworkACLCollection



79
80
81
# File 'lib/aws/ec2/vpc.rb', line 79

def network_acls
  NetworkACLCollection.new(:config => config).filter('vpc-id', vpc_id)
end

#network_interfacesNetworkInterfaceCollection



91
92
93
# File 'lib/aws/ec2/vpc.rb', line 91

def network_interfaces
  NetworkInterfaceCollection.new(:config => config).filter('vpc-id', id)
end

#route_tablesRouteTableCollection



85
86
87
# File 'lib/aws/ec2/vpc.rb', line 85

def route_tables
  RouteTableCollection.new(:config => config).filter('vpc-id', vpc_id)
end

#security_groupsSecurityGroupCollection



67
68
69
# File 'lib/aws/ec2/vpc.rb', line 67

def security_groups
  SecurityGroupCollection.new(:config => config).filter('vpc-id', vpc_id)
end

#subnetsSubnetCollection



73
74
75
# File 'lib/aws/ec2/vpc.rb', line 73

def subnets
  SubnetCollection.new(:config => config).filter('vpc-id', vpc_id)
end

#vpn_gatewayVPNGateway?



134
135
136
137
# File 'lib/aws/ec2/vpc.rb', line 134

def vpn_gateway
  gateways = VPNGatewayCollection.new(:config => config)
  gateways.filter('attachment.vpc-id', vpc_id).first
end