cfn-vpn 1.3.4 → 1.4.3
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/Gemfile.lock +2 -2
- data/docs/README.md +2 -1
- data/docs/certificate-users.md +1 -1
- data/docs/getting-started.md +35 -32
- data/docs/routes.md +48 -0
- data/docs/slack-notifications.md +35 -0
- data/lib/cfnvpn/actions/embedded.rb +3 -4
- data/lib/cfnvpn/actions/init.rb +8 -4
- data/lib/cfnvpn/actions/modify.rb +4 -2
- data/lib/cfnvpn/actions/revoke.rb +2 -3
- data/lib/cfnvpn/actions/routes.rb +20 -16
- data/lib/cfnvpn/actions/sessions.rb +4 -5
- data/lib/cfnvpn/actions/share.rb +3 -4
- data/lib/cfnvpn/actions/subnets.rb +2 -6
- data/lib/cfnvpn/clientvpn.rb +38 -22
- data/lib/cfnvpn/templates/lambdas/auto_route_populator/app.py +177 -92
- data/lib/cfnvpn/templates/lambdas/auto_route_populator/quotas.py +37 -0
- data/lib/cfnvpn/templates/lambdas/auto_route_populator/states.py +21 -0
- data/lib/cfnvpn/templates/lambdas/lib/slack.py +66 -0
- data/lib/cfnvpn/templates/lambdas/scheduler/app.py +42 -24
- data/lib/cfnvpn/templates/lambdas/scheduler/states.py +13 -0
- data/lib/cfnvpn/templates/lambdas.rb +10 -1
- data/lib/cfnvpn/templates/vpn.rb +107 -20
- data/lib/cfnvpn/version.rb +1 -1
- metadata +7 -2
data/lib/cfnvpn/templates/vpn.rb
CHANGED
@@ -131,13 +131,22 @@ module CfnVpn
|
|
131
131
|
cidr_routes = config[:routes].select {|route| route.has_key?(:cidr)}
|
132
132
|
|
133
133
|
if dns_routes.any?
|
134
|
-
auto_route_populator(name, config
|
134
|
+
auto_route_populator(name, config)
|
135
135
|
|
136
136
|
dns_routes.each do |route|
|
137
|
+
# to aide in the migration from single to HA routes if the vpn is HA
|
138
|
+
if route[:subnets]
|
139
|
+
target_subnets = route[:subnets]
|
140
|
+
elsif config[:subnet_ids].include?(route[:subnet])
|
141
|
+
target_subnets = config[:subnet_ids]
|
142
|
+
else
|
143
|
+
target_subnets = [*route[:subnet]]
|
144
|
+
end
|
145
|
+
|
137
146
|
input = {
|
138
147
|
Record: route[:dns],
|
139
148
|
ClientVpnEndpointId: "${ClientVpnEndpoint}",
|
140
|
-
|
149
|
+
TargetSubnets: target_subnets,
|
141
150
|
Description: route[:desc]
|
142
151
|
}
|
143
152
|
|
@@ -146,13 +155,15 @@ module CfnVpn
|
|
146
155
|
end
|
147
156
|
|
148
157
|
Events_Rule(:"CfnVpnAutoRoutePopulatorEvent#{route[:dns].resource_safe}"[0..255]) {
|
158
|
+
Condition(:EnableSubnetAssociation)
|
159
|
+
DependsOn network_assoc_dependson if network_assoc_dependson.any?
|
149
160
|
State 'ENABLED'
|
150
161
|
Description "cfnvpn auto route populator schedule for #{route[:dns]}"
|
151
162
|
ScheduleExpression "rate(5 minutes)"
|
152
163
|
Targets([
|
153
164
|
{
|
154
165
|
Arn: FnGetAtt(:CfnVpnAutoRoutePopulator, :Arn),
|
155
|
-
Id: "
|
166
|
+
Id: "auto-route-populator",
|
156
167
|
Input: FnSub(input.to_json)
|
157
168
|
}
|
158
169
|
])
|
@@ -162,12 +173,23 @@ module CfnVpn
|
|
162
173
|
|
163
174
|
if cidr_routes.any?
|
164
175
|
cidr_routes.each do |route|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
176
|
+
# to aide in the migration from single to HA routes if the vpn is HA
|
177
|
+
if route[:subnets]
|
178
|
+
target_subnets = route[:subnets]
|
179
|
+
elsif config[:subnet_ids].include?(route[:subnet])
|
180
|
+
target_subnets = config[:subnet_ids]
|
181
|
+
else
|
182
|
+
target_subnets = [*route[:subnet]]
|
183
|
+
end
|
184
|
+
|
185
|
+
target_subnets.each do |subnet|
|
186
|
+
EC2_ClientVpnRoute(:"#{route[:cidr].resource_safe}VpnRouteTo#{subnet.resource_safe}"[0..255]) {
|
187
|
+
Description "cfnvpn static route for #{route[:cidr]}. #{route[:desc]}".strip
|
188
|
+
ClientVpnEndpointId Ref(:ClientVpnEndpoint)
|
189
|
+
DestinationCidrBlock route[:cidr]
|
190
|
+
TargetVpcSubnetId subnet
|
191
|
+
}
|
192
|
+
end
|
171
193
|
|
172
194
|
if route[:groups].any?
|
173
195
|
route[:groups].each do |group|
|
@@ -202,7 +224,7 @@ module CfnVpn
|
|
202
224
|
}
|
203
225
|
|
204
226
|
if config[:start] || config[:stop]
|
205
|
-
scheduler(name, config
|
227
|
+
scheduler(name, config)
|
206
228
|
output(:Start, config[:start]) if config[:start]
|
207
229
|
output(:Stop, config[:stop]) if config[:stop]
|
208
230
|
end
|
@@ -228,7 +250,7 @@ module CfnVpn
|
|
228
250
|
Output(name) { Value value }
|
229
251
|
end
|
230
252
|
|
231
|
-
def auto_route_populator(name,
|
253
|
+
def auto_route_populator(name, config)
|
232
254
|
IAM_Role(:CfnVpnAutoRoutePopulatorRole) {
|
233
255
|
AssumeRolePolicyDocument({
|
234
256
|
Version: '2012-10-17',
|
@@ -275,6 +297,31 @@ module CfnVpn
|
|
275
297
|
Resource: '*'
|
276
298
|
}]
|
277
299
|
}
|
300
|
+
},
|
301
|
+
{
|
302
|
+
PolicyName: 'vpn-quotas',
|
303
|
+
PolicyDocument: {
|
304
|
+
Version: '2012-10-17',
|
305
|
+
Statement: [
|
306
|
+
{
|
307
|
+
Effect: 'Allow',
|
308
|
+
Action: [
|
309
|
+
'servicequotas:ListRequestedServiceQuotaChangeHistoryByQuota',
|
310
|
+
],
|
311
|
+
Resource: '*'
|
312
|
+
},
|
313
|
+
{
|
314
|
+
Effect: 'Allow',
|
315
|
+
Action: [
|
316
|
+
'servicequotas:RequestServiceQuotaIncrease'
|
317
|
+
],
|
318
|
+
Resource: [
|
319
|
+
FnSub('arn:aws:servicequotas:${AWS::Region}:${AWS::AccountId}:ec2/L-401D78F7'),
|
320
|
+
FnSub('arn:aws:servicequotas:${AWS::Region}:${AWS::AccountId}:ec2/L-9A1BC94B')
|
321
|
+
]
|
322
|
+
}
|
323
|
+
]
|
324
|
+
}
|
278
325
|
}
|
279
326
|
])
|
280
327
|
Tags([
|
@@ -283,7 +330,17 @@ module CfnVpn
|
|
283
330
|
])
|
284
331
|
}
|
285
332
|
|
286
|
-
s3_key = CfnVpn::Templates::Lambdas.package_lambda(
|
333
|
+
s3_key = CfnVpn::Templates::Lambdas.package_lambda(
|
334
|
+
name: name,
|
335
|
+
bucket: config[:bucket],
|
336
|
+
func: 'auto_route_populator',
|
337
|
+
files: [
|
338
|
+
'auto_route_populator/app.py',
|
339
|
+
'auto_route_populator/quotas.py',
|
340
|
+
'lib/slack.py',
|
341
|
+
'auto_route_populator/states.py'
|
342
|
+
]
|
343
|
+
)
|
287
344
|
|
288
345
|
Lambda_Function(:CfnVpnAutoRoutePopulator) {
|
289
346
|
Runtime 'python3.8'
|
@@ -292,9 +349,15 @@ module CfnVpn
|
|
292
349
|
Handler 'app.handler'
|
293
350
|
Timeout 60
|
294
351
|
Code({
|
295
|
-
S3Bucket: bucket,
|
352
|
+
S3Bucket: config[:bucket],
|
296
353
|
S3Key: s3_key
|
297
354
|
})
|
355
|
+
Environment({
|
356
|
+
Variables: {
|
357
|
+
SLACK_URL: config[:slack_webhook_url] || '',
|
358
|
+
AUTO_LIMIT_INCREASE: config[:auto_limit_increase] || true
|
359
|
+
}
|
360
|
+
})
|
298
361
|
Tags([
|
299
362
|
{ Key: 'Name', Value: "#{name}-cfnvpn-auto-route-populator" },
|
300
363
|
{ Key: 'Environment', Value: 'cfnvpn' }
|
@@ -313,7 +376,7 @@ module CfnVpn
|
|
313
376
|
}
|
314
377
|
end
|
315
378
|
|
316
|
-
def scheduler(name,
|
379
|
+
def scheduler(name, config)
|
317
380
|
IAM_Role(:ClientVpnSchedulerRole) {
|
318
381
|
AssumeRolePolicyDocument({
|
319
382
|
Version: '2012-10-17',
|
@@ -362,6 +425,25 @@ module CfnVpn
|
|
362
425
|
}]
|
363
426
|
}
|
364
427
|
},
|
428
|
+
{
|
429
|
+
PolicyName: 'route-populator-events',
|
430
|
+
PolicyDocument: {
|
431
|
+
Version: '2012-10-17',
|
432
|
+
Statement: [{
|
433
|
+
Effect: 'Allow',
|
434
|
+
Action: [
|
435
|
+
'events:PutRule',
|
436
|
+
'events:PutTargets',
|
437
|
+
'events:DeleteRule',
|
438
|
+
'events:DescribeRule',
|
439
|
+
'events:DisableRule',
|
440
|
+
'events:EnableRule',
|
441
|
+
'events:RemoveTargets'
|
442
|
+
],
|
443
|
+
Resource: FnSub("arn:aws:events:${AWS::Region}:${AWS::AccountId}:rule/#{name}-cfnvpn-CfnVpnAutoRoutePopulator*")
|
444
|
+
}]
|
445
|
+
}
|
446
|
+
},
|
365
447
|
{
|
366
448
|
PolicyName: 'logging',
|
367
449
|
PolicyDocument: {
|
@@ -386,7 +468,7 @@ module CfnVpn
|
|
386
468
|
])
|
387
469
|
}
|
388
470
|
|
389
|
-
s3_key = CfnVpn::Templates::Lambdas.package_lambda(name: name, bucket: bucket, func: 'scheduler', files: ['app.py'])
|
471
|
+
s3_key = CfnVpn::Templates::Lambdas.package_lambda(name: name, bucket: config[:bucket], func: 'scheduler', files: ['scheduler/app.py', 'lib/slack.py', 'scheduler/states.py'])
|
390
472
|
|
391
473
|
Lambda_Function(:ClientVpnSchedulerFunction) {
|
392
474
|
Runtime 'python3.8'
|
@@ -394,8 +476,13 @@ module CfnVpn
|
|
394
476
|
MemorySize '128'
|
395
477
|
Handler 'app.handler'
|
396
478
|
Timeout 60
|
479
|
+
Environment({
|
480
|
+
Variables: {
|
481
|
+
SLACK_URL: config[:slack_webhook_url] || ''
|
482
|
+
}
|
483
|
+
})
|
397
484
|
Code({
|
398
|
-
S3Bucket: bucket,
|
485
|
+
S3Bucket: config[:bucket],
|
399
486
|
S3Key: s3_key
|
400
487
|
})
|
401
488
|
Tags([
|
@@ -415,11 +502,11 @@ module CfnVpn
|
|
415
502
|
Principal 'events.amazonaws.com'
|
416
503
|
}
|
417
504
|
|
418
|
-
if start
|
505
|
+
if config[:start]
|
419
506
|
Events_Rule(:ClientVpnSchedulerStart) {
|
420
507
|
State 'ENABLED'
|
421
508
|
Description "cfnvpn start schedule"
|
422
|
-
ScheduleExpression "cron(#{start})"
|
509
|
+
ScheduleExpression "cron(#{config[:start]})"
|
423
510
|
Targets([
|
424
511
|
{
|
425
512
|
Arn: FnGetAtt(:ClientVpnSchedulerFunction, :Arn),
|
@@ -430,11 +517,11 @@ module CfnVpn
|
|
430
517
|
}
|
431
518
|
end
|
432
519
|
|
433
|
-
if stop
|
520
|
+
if config[:stop]
|
434
521
|
Events_Rule(:ClientVpnSchedulerStop) {
|
435
522
|
State 'ENABLED'
|
436
523
|
Description "cfnvpn stop schedule"
|
437
|
-
ScheduleExpression "cron(#{stop})"
|
524
|
+
ScheduleExpression "cron(#{config[:stop]})"
|
438
525
|
Targets([
|
439
526
|
{
|
440
527
|
Arn: FnGetAtt(:ClientVpnSchedulerFunction, :Arn),
|
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: 1.3
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guslington
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- docs/routes.md
|
248
248
|
- docs/scheduling.md
|
249
249
|
- docs/sessions.md
|
250
|
+
- docs/slack-notifications.md
|
250
251
|
- exe/cfn-vpn
|
251
252
|
- lib/cfnvpn.rb
|
252
253
|
- lib/cfnvpn/acm.rb
|
@@ -273,7 +274,11 @@ files:
|
|
273
274
|
- lib/cfnvpn/templates/helper.rb
|
274
275
|
- lib/cfnvpn/templates/lambdas.rb
|
275
276
|
- lib/cfnvpn/templates/lambdas/auto_route_populator/app.py
|
277
|
+
- lib/cfnvpn/templates/lambdas/auto_route_populator/quotas.py
|
278
|
+
- lib/cfnvpn/templates/lambdas/auto_route_populator/states.py
|
279
|
+
- lib/cfnvpn/templates/lambdas/lib/slack.py
|
276
280
|
- lib/cfnvpn/templates/lambdas/scheduler/app.py
|
281
|
+
- lib/cfnvpn/templates/lambdas/scheduler/states.py
|
277
282
|
- lib/cfnvpn/templates/vpn.rb
|
278
283
|
- lib/cfnvpn/version.rb
|
279
284
|
homepage: https://github.com/base2services/aws-client-vpn
|