cfn-vpn 0.5.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build-gem.yml +25 -0
- data/.github/workflows/release-gem.yml +34 -0
- data/.github/workflows/release-image.yml +33 -0
- data/Gemfile.lock +33 -39
- data/README.md +1 -247
- data/cfn-vpn.gemspec +4 -4
- data/docs/README.md +44 -0
- data/docs/certificate-users.md +89 -0
- data/docs/getting-started.md +128 -0
- data/docs/modifying.md +67 -0
- data/docs/routes.md +98 -0
- data/docs/scheduling.md +32 -0
- data/docs/sessions.md +27 -0
- data/lib/cfnvpn.rb +31 -27
- data/lib/cfnvpn/{client.rb → actions/client.rb} +5 -6
- data/lib/cfnvpn/{embedded.rb → actions/embedded.rb} +15 -15
- data/lib/cfnvpn/actions/init.rb +144 -0
- data/lib/cfnvpn/actions/modify.rb +169 -0
- data/lib/cfnvpn/actions/params.rb +73 -0
- data/lib/cfnvpn/{revoke.rb → actions/revoke.rb} +6 -6
- data/lib/cfnvpn/actions/routes.rb +196 -0
- data/lib/cfnvpn/{sessions.rb → actions/sessions.rb} +5 -5
- data/lib/cfnvpn/{share.rb → actions/share.rb} +10 -10
- data/lib/cfnvpn/actions/subnets.rb +78 -0
- data/lib/cfnvpn/certificates.rb +5 -5
- data/lib/cfnvpn/clientvpn.rb +49 -65
- data/lib/cfnvpn/compiler.rb +23 -0
- data/lib/cfnvpn/config.rb +34 -78
- data/lib/cfnvpn/{cloudformation.rb → deployer.rb} +47 -19
- data/lib/cfnvpn/log.rb +26 -26
- data/lib/cfnvpn/s3.rb +34 -4
- data/lib/cfnvpn/s3_bucket.rb +48 -0
- data/lib/cfnvpn/string.rb +33 -0
- data/lib/cfnvpn/templates/helper.rb +14 -0
- data/lib/cfnvpn/templates/lambdas.rb +35 -0
- data/lib/cfnvpn/templates/lambdas/auto_route_populator/app.py +175 -0
- data/lib/cfnvpn/templates/lambdas/scheduler/app.py +36 -0
- data/lib/cfnvpn/templates/vpn.rb +449 -0
- data/lib/cfnvpn/version.rb +1 -1
- metadata +73 -23
- data/lib/cfnvpn/cfhighlander.rb +0 -49
- data/lib/cfnvpn/init.rb +0 -109
- data/lib/cfnvpn/modify.rb +0 -103
- data/lib/cfnvpn/routes.rb +0 -84
- data/lib/cfnvpn/templates/cfnvpn.cfhighlander.rb.tt +0 -27
data/lib/cfnvpn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-vpn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guslington
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -45,25 +45,25 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '2'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: cfndsl
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '1'
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '2'
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '1'
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '2'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: netaddr
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +78,20 @@ dependencies:
|
|
78
78
|
- - '='
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: 2.0.4
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rubyzip
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.3'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '2.3'
|
81
95
|
- !ruby/object:Gem::Dependency
|
82
96
|
name: aws-sdk-ec2
|
83
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,6 +172,26 @@ dependencies:
|
|
158
172
|
- - "<"
|
159
173
|
- !ruby/object:Gem::Version
|
160
174
|
version: '2'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: aws-sdk-ssm
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '1'
|
182
|
+
- - "<"
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '2'
|
185
|
+
type: :runtime
|
186
|
+
prerelease: false
|
187
|
+
version_requirements: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - "~>"
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '1'
|
192
|
+
- - "<"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '2'
|
161
195
|
- !ruby/object:Gem::Dependency
|
162
196
|
name: bundler
|
163
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,14 +212,14 @@ dependencies:
|
|
178
212
|
requirements:
|
179
213
|
- - "~>"
|
180
214
|
- !ruby/object:Gem::Version
|
181
|
-
version: '
|
215
|
+
version: '13.0'
|
182
216
|
type: :development
|
183
217
|
prerelease: false
|
184
218
|
version_requirements: !ruby/object:Gem::Requirement
|
185
219
|
requirements:
|
186
220
|
- - "~>"
|
187
221
|
- !ruby/object:Gem::Version
|
188
|
-
version: '
|
222
|
+
version: '13.0'
|
189
223
|
description: creates and manages resources for the aws client vpn
|
190
224
|
email:
|
191
225
|
- guslington@gmail.com
|
@@ -194,6 +228,9 @@ executables:
|
|
194
228
|
extensions: []
|
195
229
|
extra_rdoc_files: []
|
196
230
|
files:
|
231
|
+
- ".github/workflows/build-gem.yml"
|
232
|
+
- ".github/workflows/release-gem.yml"
|
233
|
+
- ".github/workflows/release-image.yml"
|
197
234
|
- ".gitignore"
|
198
235
|
- ".travis.yml"
|
199
236
|
- Dockerfile
|
@@ -203,32 +240,46 @@ files:
|
|
203
240
|
- README.md
|
204
241
|
- Rakefile
|
205
242
|
- cfn-vpn.gemspec
|
243
|
+
- docs/README.md
|
244
|
+
- docs/certificate-users.md
|
245
|
+
- docs/getting-started.md
|
246
|
+
- docs/modifying.md
|
247
|
+
- docs/routes.md
|
248
|
+
- docs/scheduling.md
|
249
|
+
- docs/sessions.md
|
206
250
|
- exe/cfn-vpn
|
207
251
|
- lib/cfnvpn.rb
|
208
252
|
- lib/cfnvpn/acm.rb
|
253
|
+
- lib/cfnvpn/actions/client.rb
|
254
|
+
- lib/cfnvpn/actions/embedded.rb
|
255
|
+
- lib/cfnvpn/actions/init.rb
|
256
|
+
- lib/cfnvpn/actions/modify.rb
|
257
|
+
- lib/cfnvpn/actions/params.rb
|
258
|
+
- lib/cfnvpn/actions/revoke.rb
|
259
|
+
- lib/cfnvpn/actions/routes.rb
|
260
|
+
- lib/cfnvpn/actions/sessions.rb
|
261
|
+
- lib/cfnvpn/actions/share.rb
|
262
|
+
- lib/cfnvpn/actions/subnets.rb
|
209
263
|
- lib/cfnvpn/certificates.rb
|
210
|
-
- lib/cfnvpn/cfhighlander.rb
|
211
|
-
- lib/cfnvpn/client.rb
|
212
264
|
- lib/cfnvpn/clientvpn.rb
|
213
|
-
- lib/cfnvpn/
|
265
|
+
- lib/cfnvpn/compiler.rb
|
214
266
|
- lib/cfnvpn/config.rb
|
215
|
-
- lib/cfnvpn/
|
267
|
+
- lib/cfnvpn/deployer.rb
|
216
268
|
- lib/cfnvpn/globals.rb
|
217
|
-
- lib/cfnvpn/init.rb
|
218
269
|
- lib/cfnvpn/log.rb
|
219
|
-
- lib/cfnvpn/modify.rb
|
220
|
-
- lib/cfnvpn/revoke.rb
|
221
|
-
- lib/cfnvpn/routes.rb
|
222
270
|
- lib/cfnvpn/s3.rb
|
223
|
-
- lib/cfnvpn/
|
224
|
-
- lib/cfnvpn/
|
225
|
-
- lib/cfnvpn/templates/
|
271
|
+
- lib/cfnvpn/s3_bucket.rb
|
272
|
+
- lib/cfnvpn/string.rb
|
273
|
+
- lib/cfnvpn/templates/helper.rb
|
274
|
+
- lib/cfnvpn/templates/lambdas.rb
|
275
|
+
- lib/cfnvpn/templates/lambdas/auto_route_populator/app.py
|
276
|
+
- lib/cfnvpn/templates/lambdas/scheduler/app.py
|
277
|
+
- lib/cfnvpn/templates/vpn.rb
|
226
278
|
- lib/cfnvpn/version.rb
|
227
279
|
homepage: https://github.com/base2services/aws-client-vpn
|
228
280
|
licenses:
|
229
281
|
- MIT
|
230
282
|
metadata:
|
231
|
-
allowed_push_host: https://rubygems.org
|
232
283
|
homepage_uri: https://github.com/base2services/aws-client-vpn
|
233
284
|
source_code_uri: https://github.com/base2services/aws-client-vpn
|
234
285
|
post_install_message:
|
@@ -246,8 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
297
|
- !ruby/object:Gem::Version
|
247
298
|
version: '0'
|
248
299
|
requirements: []
|
249
|
-
|
250
|
-
rubygems_version: 2.7.6
|
300
|
+
rubygems_version: 3.1.6
|
251
301
|
signing_key:
|
252
302
|
specification_version: 4
|
253
303
|
summary: creates and manages resources for the aws client vpn
|
data/lib/cfnvpn/cfhighlander.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'cfhighlander.publisher'
|
2
|
-
require 'cfhighlander.factory'
|
3
|
-
require 'cfhighlander.validator'
|
4
|
-
|
5
|
-
require 'cfnvpn/version'
|
6
|
-
|
7
|
-
module CfnVpn
|
8
|
-
class CfHiglander
|
9
|
-
|
10
|
-
def initialize(region, name, config, output_dir)
|
11
|
-
@component_name = name
|
12
|
-
@region = region
|
13
|
-
@config = config
|
14
|
-
@cfn_output_format = 'yaml'
|
15
|
-
ENV['CFHIGHLANDER_WORKDIR'] = output_dir
|
16
|
-
end
|
17
|
-
|
18
|
-
def render()
|
19
|
-
component = load_component(@component_name)
|
20
|
-
compiled = compile_component(component)
|
21
|
-
validate_component(component,compiled.cfn_template_paths)
|
22
|
-
cfn_template_paths = compiled.cfn_template_paths
|
23
|
-
return cfn_template_paths.select { |path| path.match(@component_name) }.first
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def load_component(component_name)
|
29
|
-
factory = Cfhighlander::Factory::ComponentFactory.new
|
30
|
-
component = factory.loadComponentFromTemplate(component_name)
|
31
|
-
component.config = @config
|
32
|
-
component.version = CfnVpn::VERSION
|
33
|
-
component.load()
|
34
|
-
return component
|
35
|
-
end
|
36
|
-
|
37
|
-
def compile_component(component)
|
38
|
-
component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
|
39
|
-
component_compiler.compileCloudFormation(@cfn_output_format)
|
40
|
-
return component_compiler
|
41
|
-
end
|
42
|
-
|
43
|
-
def validate_component(component,template_paths)
|
44
|
-
component_validator = Cfhighlander::Cloudformation::Validator.new(component)
|
45
|
-
component_validator.validate(template_paths, @cfn_output_format)
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
data/lib/cfnvpn/init.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'cfnvpn/cloudformation'
|
4
|
-
require 'cfnvpn/certificates'
|
5
|
-
require 'cfnvpn/cfhighlander'
|
6
|
-
require 'cfnvpn/cloudformation'
|
7
|
-
require 'cfnvpn/log'
|
8
|
-
require 'cfnvpn/clientvpn'
|
9
|
-
require 'cfnvpn/globals'
|
10
|
-
|
11
|
-
module CfnVpn
|
12
|
-
class Init < Thor::Group
|
13
|
-
include Thor::Actions
|
14
|
-
include CfnVpn::Log
|
15
|
-
|
16
|
-
argument :name
|
17
|
-
|
18
|
-
class_option :profile, aliases: :p, desc: 'AWS Profile'
|
19
|
-
class_option :region, aliases: :r, default: ENV['AWS_REGION'], desc: 'AWS Region'
|
20
|
-
class_option :verbose, desc: 'set log level to debug', type: :boolean
|
21
|
-
|
22
|
-
class_option :server_cn, required: true, desc: 'server certificate common name'
|
23
|
-
class_option :client_cn, desc: 'client certificate common name'
|
24
|
-
class_option :easyrsa_local, type: :boolean, default: false, desc: 'run the easyrsa executable from your local rather than from docker'
|
25
|
-
class_option :bucket, required: true, desc: 's3 bucket'
|
26
|
-
|
27
|
-
class_option :subnet_id, required: true, desc: 'subnet id to associate your vpn with'
|
28
|
-
class_option :cidr, default: '10.250.0.0/16', desc: 'cidr from which to assign client IP addresses'
|
29
|
-
class_option :dns_servers, desc: 'DNS Servers to push to clients.'
|
30
|
-
|
31
|
-
class_option :split_tunnel, type: :boolean, default: false, desc: 'only push routes to the client on the vpn endpoint'
|
32
|
-
class_option :internet_route, type: :boolean, default: true, desc: 'create a default route to the internet'
|
33
|
-
class_option :protocol, type: :string, default: 'udp', enum: ['udp','tcp'], desc: 'set the protocol for the vpn connections'
|
34
|
-
|
35
|
-
|
36
|
-
def self.source_root
|
37
|
-
File.dirname(__FILE__)
|
38
|
-
end
|
39
|
-
|
40
|
-
def set_loglevel
|
41
|
-
Log.logger.level = Logger::DEBUG if @options['verbose']
|
42
|
-
end
|
43
|
-
|
44
|
-
def create_build_directory
|
45
|
-
@build_dir = "#{CfnVpn.cfnvpn_path}/#{@name}"
|
46
|
-
Log.logger.debug "creating directory #{@build_dir}"
|
47
|
-
FileUtils.mkdir_p(@build_dir)
|
48
|
-
end
|
49
|
-
|
50
|
-
def initialize_config
|
51
|
-
@config = {}
|
52
|
-
@config['parameters'] = {}
|
53
|
-
@config['parameters']['EnvironmentName'] = @name
|
54
|
-
@config['parameters']['AssociationSubnetId'] = @options['subnet_id']
|
55
|
-
@config['parameters']['ClientCidrBlock'] = @options['cidr']
|
56
|
-
@config['parameters']['DnsServers'] = @options['dns_servers']
|
57
|
-
@config['parameters']['SplitTunnel'] = @options['split_tunnel'].to_s
|
58
|
-
@config['parameters']['InternetRoute'] = @options['internet_route'].to_s
|
59
|
-
@config['parameters']['Protocol'] = @options['protocol']
|
60
|
-
@config['template_version'] = '0.2.0'
|
61
|
-
end
|
62
|
-
|
63
|
-
def stack_exist
|
64
|
-
@cfn = CfnVpn::Cloudformation.new(@options['region'],@name)
|
65
|
-
if @cfn.does_cf_stack_exist()
|
66
|
-
Log.logger.error "#{@name}-cfnvpn stack already exists in this account in region #{@options['region']}"
|
67
|
-
exit 1
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# create certificates
|
72
|
-
def generate_server_certificates
|
73
|
-
Log.logger.info "Generating certificates using openvpn easy-rsa"
|
74
|
-
cert = CfnVpn::Certificates.new(@build_dir,@name,@options['easyrsa_local'])
|
75
|
-
@client_cn = @options['client_cn'] ? @options['client_cn'] : "client-vpn.#{@options['server_cn']}"
|
76
|
-
cert.generate_ca(@options['server_cn'],@client_cn)
|
77
|
-
end
|
78
|
-
|
79
|
-
def upload_certificates
|
80
|
-
cert = CfnVpn::Certificates.new(@build_dir,@name,@options['easyrsa_local'])
|
81
|
-
@config['parameters']['ServerCertificateArn'] = cert.upload_certificates(@options['region'],'server','server',@options['server_cn'])
|
82
|
-
@config['parameters']['ClientCertificateArn'] = cert.upload_certificates(@options['region'],@client_cn,'client')
|
83
|
-
s3 = CfnVpn::S3.new(@options['region'],@options['bucket'],@name)
|
84
|
-
s3.store_object("#{@build_dir}/certificates/ca.tar.gz")
|
85
|
-
end
|
86
|
-
|
87
|
-
def deploy_vpn
|
88
|
-
template('templates/cfnvpn.cfhighlander.rb.tt', "#{@build_dir}/#{@name}.cfhighlander.rb", @config, force: true)
|
89
|
-
Log.logger.debug "Generating cloudformation from #{@build_dir}/#{@name}.cfhighlander.rb"
|
90
|
-
cfhl = CfnVpn::CfHiglander.new(@options['region'],@name,@config,@build_dir)
|
91
|
-
template_path = cfhl.render()
|
92
|
-
Log.logger.debug "Cloudformation template #{template_path} generated and validated"
|
93
|
-
Log.logger.info "Launching cloudformation stack #{@name}-cfnvpn in #{@options['region']}"
|
94
|
-
cfn = CfnVpn::Cloudformation.new(@options['region'],@name)
|
95
|
-
change_set, change_set_type = cfn.create_change_set(template_path, @config['parameters'])
|
96
|
-
cfn.wait_for_changeset(change_set.id)
|
97
|
-
cfn.execute_change_set(change_set.id)
|
98
|
-
cfn.wait_for_execute(change_set_type)
|
99
|
-
Log.logger.debug "Changeset #{change_set_type} complete"
|
100
|
-
end
|
101
|
-
|
102
|
-
def finish
|
103
|
-
vpn = CfnVpn::ClientVpn.new(@name,@options['region'])
|
104
|
-
@endpoint_id = vpn.get_endpoint_id()
|
105
|
-
Log.logger.info "Client VPN #{@endpoint_id} created. Run `cfn-vpn config #{@name}` to setup the client config"
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
end
|
data/lib/cfnvpn/modify.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'cfnvpn/cloudformation'
|
4
|
-
require 'cfnvpn/certificates'
|
5
|
-
require 'cfnvpn/cfhighlander'
|
6
|
-
require 'cfnvpn/cloudformation'
|
7
|
-
require 'cfnvpn/log'
|
8
|
-
require 'cfnvpn/clientvpn'
|
9
|
-
require 'cfnvpn/globals'
|
10
|
-
|
11
|
-
module CfnVpn
|
12
|
-
class Modify < Thor::Group
|
13
|
-
include Thor::Actions
|
14
|
-
include CfnVpn::Log
|
15
|
-
|
16
|
-
argument :name
|
17
|
-
|
18
|
-
class_option :profile, aliases: :p, desc: 'AWS Profile'
|
19
|
-
class_option :region, aliases: :r, default: ENV['AWS_REGION'], desc: 'AWS Region'
|
20
|
-
class_option :verbose, desc: 'set log level to debug', type: :boolean
|
21
|
-
|
22
|
-
class_option :subnet_id, desc: 'subnet id to associate your vpn with'
|
23
|
-
class_option :cidr, desc: 'cidr from which to assign client IP addresses'
|
24
|
-
class_option :dns_servers, desc: 'DNS Servers to push to clients.'
|
25
|
-
|
26
|
-
class_option :split_tunnel, type: :boolean, desc: 'only push routes to the client on the vpn endpoint'
|
27
|
-
class_option :internet_route, type: :boolean, desc: 'create a default route to the internet'
|
28
|
-
class_option :protocol, type: :string, enum: ['udp','tcp'], desc: 'set the protocol for the vpn connections'
|
29
|
-
|
30
|
-
def self.source_root
|
31
|
-
File.dirname(__FILE__)
|
32
|
-
end
|
33
|
-
|
34
|
-
def set_loglevel
|
35
|
-
Log.logger.level = Logger::DEBUG if @options['verbose']
|
36
|
-
end
|
37
|
-
|
38
|
-
def create_build_directory
|
39
|
-
@build_dir = "#{CfnVpn.cfnvpn_path}/#{@name}"
|
40
|
-
Log.logger.debug "creating directory #{@build_dir}"
|
41
|
-
FileUtils.mkdir_p(@build_dir)
|
42
|
-
end
|
43
|
-
|
44
|
-
def initialize_config
|
45
|
-
@config = {}
|
46
|
-
@config['parameters'] = {}
|
47
|
-
@config['parameters']['AssociationSubnetId'] = @options['subnet_id'] unless @options['subnet_id'].nil?
|
48
|
-
@config['parameters']['ClientCidrBlock'] = @options['cidr'] unless @options['cidr'].nil?
|
49
|
-
@config['parameters']['DnsServers'] = @options['dns_servers'] unless @options['dns_servers'].nil?
|
50
|
-
@config['parameters']['SplitTunnel'] = @options['split_tunnel'].to_s unless @options['split_tunnel'].nil?
|
51
|
-
@config['parameters']['InternetRoute'] = @options['internet_route'].to_s unless @options['internet_route'].nil?
|
52
|
-
@config['parameters']['Protocol'] = @options['protocol'] unless @options['protocol'].nil?
|
53
|
-
@config['template_version'] = '0.2.0'
|
54
|
-
end
|
55
|
-
|
56
|
-
def stack_exist
|
57
|
-
@cfn = CfnVpn::Cloudformation.new(@options['region'],@name)
|
58
|
-
if !@cfn.does_cf_stack_exist()
|
59
|
-
Log.logger.error "#{@name}-cfnvpn stack doesn't exists in this account in region #{@options['region']}\n Try running `cfn-vpn init #{@name}` to setup the stack"
|
60
|
-
exit 1
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def deploy_vpn
|
65
|
-
template('templates/cfnvpn.cfhighlander.rb.tt', "#{@build_dir}/#{@name}.cfhighlander.rb", @config, force: true)
|
66
|
-
Log.logger.debug "Generating cloudformation from #{@build_dir}/#{@name}.cfhighlander.rb"
|
67
|
-
cfhl = CfnVpn::CfHiglander.new(@options['region'],@name,@config,@build_dir)
|
68
|
-
template_path = cfhl.render()
|
69
|
-
Log.logger.debug "Cloudformation template #{template_path} generated and validated"
|
70
|
-
|
71
|
-
Log.logger.info "Modifying cloudformation stack #{@name}-cfnvpn in #{@options['region']}"
|
72
|
-
cfn = CfnVpn::Cloudformation.new(@options['region'],@name)
|
73
|
-
change_set, change_set_type = cfn.create_change_set(template_path,@config['parameters'])
|
74
|
-
cfn.wait_for_changeset(change_set.id)
|
75
|
-
changes = cfn.get_change_set(change_set.id)
|
76
|
-
|
77
|
-
Log.logger.warn("The following changes to the cfnvpn stack will be made")
|
78
|
-
changes.changes.each do |change|
|
79
|
-
Log.logger.warn("ID: #{change.resource_change.logical_resource_id} Action: #{change.resource_change.action}")
|
80
|
-
change.resource_change.details.each do |details|
|
81
|
-
Log.logger.warn("Name: #{details.target.name} Attribute: #{details.target.attribute} Cause: #{details.causing_entity}")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
continue = yes? "Continue?", :green
|
86
|
-
if !continue
|
87
|
-
Log.logger.error("Cancelled cfn-vpn modifiy #{@name}")
|
88
|
-
exit 1
|
89
|
-
end
|
90
|
-
|
91
|
-
cfn.execute_change_set(change_set.id)
|
92
|
-
cfn.wait_for_execute(change_set_type)
|
93
|
-
Log.logger.debug "Changeset #{change_set_type} complete"
|
94
|
-
end
|
95
|
-
|
96
|
-
def finish
|
97
|
-
vpn = CfnVpn::ClientVpn.new(@name,@options['region'])
|
98
|
-
@endpoint_id = vpn.get_endpoint_id()
|
99
|
-
Log.logger.info "Client VPN #{@endpoint_id} modified."
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|