Class: VPC::VpnConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/etude_for_aws/vpc/vpn_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, gateway, vpn_connection_id = nil) ⇒ VpnConnection

Returns a new instance of VpnConnection.



5
6
7
8
9
# File 'lib/etude_for_aws/vpc/vpn_connection.rb', line 5

def initialize(config,gateway,vpn_connection_id=nil)
  @config = config
  @gateway = gateway
  @vpn_connection_id = vpn_connection_id
end

Instance Attribute Details

#vpn_connection_idObject (readonly)

Returns the value of attribute vpn_connection_id.



3
4
5
# File 'lib/etude_for_aws/vpc/vpn_connection.rb', line 3

def vpn_connection_id
  @vpn_connection_id
end

Instance Method Details

#creat(customer_gateway_id, vpn_gateway_id, vpn_connection_info) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/etude_for_aws/vpc/vpn_connection.rb', line 11

def creat(customer_gateway_id, vpn_gateway_id, vpn_connection_info)
  type = vpn_connection_info['TYPE']
  static_routes_only = vpn_connection_info['OPTIONS']['STATIC_ROUTES_ONLY']
  @vpn_connection = @gateway.create_vpn_connection(type, customer_gateway_id, vpn_gateway_id, static_routes_only)
  @vpn_connection_id = @vpn_connection[0].vpn_connection_id
  resources = [@vpn_connection_id]
  vpn_connection_tags = vpn_connection_info['TAGS']
  tag = {key: vpn_connection_tags['NAME']['KEY'], value: vpn_connection_tags['NAME']['VALUE']}
  tags = [tag, @config.vpc_group_tag]
  @gateway.create_tags(resources, tags)
end

#deleteObject



23
24
25
# File 'lib/etude_for_aws/vpc/vpn_connection.rb', line 23

def delete
  @gateway.delete_vpn_connection(@vpn_connection_id)
end