Class: AWS::EC2::VPNGateway

Inherits:
Resource
  • Object
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

Instance Method Summary collapse

Methods included from TaggedItem

#add_tag, #clear_tags, #tags

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