Class: AWS::EC2::VPNGateway

Inherits:
Resource show all
Includes:
TaggedItem
Defined in:
lib/aws/ec2/vpn_gateway.rb,
lib/aws/ec2/vpn_gateway/attachment.rb

Defined Under Namespace

Classes: Attachment

Instance Attribute Summary collapse

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from TaggedItem

#add_tag, #cached_tags, #clear_tags, #tagging_resource_type, #tags

Methods inherited from Core::Resource

attribute_providers, attribute_providers_for, attributes, #attributes_from_response, define_attribute_type, #eql?, #inspect, new_from

Methods included from Core::Cacheable

included, #retrieve_attribute

Methods included from Core::Model

#client, #config_prefix, #inspect

Constructor Details

#initialize(vpn_gateway_id, options = {}) ⇒ VPNGateway

Returns a new instance of VPNGateway.



23
24
25
26
# File 'lib/aws/ec2/vpn_gateway.rb', line 23

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

Instance Attribute Details

#vpn_gateway_idString (readonly) Also known as: id

Returns:

  • (String)


29
30
31
# File 'lib/aws/ec2/vpn_gateway.rb', line 29

def vpn_gateway_id
  @vpn_gateway_id
end

Instance Method Details

#attach(vpc) ⇒ Attachment

Attaches this vpn gateway to the given VPC.

Parameters:

Returns:



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/aws/ec2/vpn_gateway.rb', line 67

def attach vpc

  client_opts = {}
  client_opts[:vpn_gateway_id] = vpn_gateway_id
  client_opts[:vpc_id] = vpc_id(vpc)

  resp = client.attach_vpn_gateway(client_opts)

  Attachment.new(self, resp.attachment)

end

#attachmentsArray<VPNGateway::Attachment>

Returns:



52
53
54
# File 'lib/aws/ec2/vpn_gateway.rb', line 52

def attachments
  attachment_set.map {|details| Attachment.new(self, details) }
end

#deletenil

Deletes this vpn gateway.

Returns:

  • (nil)


99
100
101
102
103
104
# File 'lib/aws/ec2/vpn_gateway.rb', line 99

def delete
  client_opts = {}
  client_opts[:vpn_gateway_id] = vpn_gateway_id
  client.delete_vpn_gateway(client_opts)
  nil
end

#detach(vpc) ⇒ nil

Detaches this vpn gateway from the given VPC.

Parameters:

Returns:

  • (nil)


82
83
84
85
86
87
88
# File 'lib/aws/ec2/vpn_gateway.rb', line 82

def detach vpc
  client_opts = {}
  client_opts[:vpn_gateway_id] = vpn_gateway_id
  client_opts[:vpc_id] = vpc_id(vpc)
  client.detach_vpn_gateway(client_opts)
  nil
end

#exists?Boolean

Returns true if the gateway exists.

Returns:

  • (Boolean)

    Returns true if the gateway exists.



107
108
109
110
111
112
113
114
# File 'lib/aws/ec2/vpn_gateway.rb', line 107

def exists?
  begin
    client.describe_vpn_gateways(:vpn_gateway_ids => [id])
    true
  rescue Errors::InvalidVPNGatewayID::NotFound
    false
  end
end

#vpcVPC?

Returns the currently attached VPC, or nil if this gateway has not been attached.

Returns:

  • (VPC, nil)

    Returns the currently attached VPC, or nil if this gateway has not been attached.



58
59
60
61
62
# File 'lib/aws/ec2/vpn_gateway.rb', line 58

def vpc
  if attachment = attachments.first  
    attachment.vpc
  end
end

#vpn_connectionsVPNConnectionCollection

Returns a collection of VPC connections for this gateway.

Returns:



92
93
94
95
# File 'lib/aws/ec2/vpn_gateway.rb', line 92

def vpn_connections
  connections = VPNConnectionCollection.new(:config => config)
  connections.filter('vpn-gateway-id', id)
end