forked from awslabs/aws-transit-vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transit-vpc.cfn.yml
1286 lines (1286 loc) · 34.9 KB
/
transit-vpc.cfn.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
AWSTemplateFormatVersion: 2010-09-09
Description: >-
(SO0001) - Transit VPC: This template creates a dedicated transit VPC with
Cisco CSRs for routing traffic. ***NOTE*** You must first subscribe to the
appropriate Cisco CSR marketplace BYOL or License Included AMI from the AWS
Marketplace before you launch this template. Version 3
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
Type: 'AWS::EC2::KeyPair::KeyName'
Default: Lab
TerminationProtection:
Description: >-
Enable termination protection on the CSR EC2 instances to avoid
accidential CSR termination?
Type: String
Default: 'Yes'
AllowedValues:
- 'Yes'
- 'No'
PreferredPathTag:
Description: >-
Tag to use to configure a preferred CSR VPN endpoint to control traffic
flow through the Transit VPC CSRs (e.g. when integrating with stateful
on-prem firewalls).
Type: String
Default: 'transitvpc:preferred-path'
SpokeTag:
Description: Tag to use to identify spoke VPCs to connect to Transit VPC.
Type: String
Default: 'transitvpc:spoke'
SpokeTagValue:
Description: Tag value to use to identify spoke VPCs to connect to Transit VPC.
Type: String
Default: 'true'
BgpAsn:
Description: BGP ASN to use for Transit VPC.
Type: String
Default: '64512'
VpcCidr:
Description: CIDR block for Transit VPC.
Type: String
Default: 100.64.127.224/27
PubSubnet1:
Description: Address range for Transit VPC subnet to be created in AZ1.
Type: String
Default: 100.64.127.224/28
PubSubnet2:
Description: Address range for Transit VPC subnet to be created in AZ2.
Type: String
Default: 100.64.127.240/28
CSRType:
Description: Maximum network througput required for CSR instances.
Type: String
Default: 2x500Mbps
AllowedValues:
- 2x500Mbps
- 2x1Gbps
- 2x2Gbps
- 2x4.5Gbps
LicenseModel:
Description: >-
Choose between BYOL (Bring Your Own License) and License Included license
models. Remember to first subscribe the the appropriate Marketplace AMI!
Type: String
Default: LicenseIncluded
AllowedValues:
- LicenseIncluded
- BYOL
S3Prefix:
Description: S3 prefix to append before S3 key names.
Type: String
Default: vpnconfigs/
AccountId:
Description: >-
Another AWS Account ID to authorize access to VPN Config S3 bucket (for
example bucket and KMS key policies).
Type: String
Default: ''
SendAnonymousData:
Description: Choose to send anonymous data to AWS.
Type: String
Default: 'Yes'
AllowedValues:
- 'Yes'
- 'No'
Conditions:
AuthorizeAnotherAccount: !Not
- !Equals
- !Ref AccountId
- ''
EnableTerm: !Equals
- !Ref TerminationProtection
- 'Yes'
SendData: !Equals
- !Ref SendAnonymousData
- 'Yes'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: Cisco CSR Configuration
Parameters:
- CSRType
# - KeyName
- LicenseModel
- TerminationProtection
- Label:
default: AWS Service Configuration
Parameters:
- S3Prefix
- AccountId
- Label:
default: Network Configuration
Parameters:
- VpcCidr
- PubSubnet1
- PubSubnet2
- BgpAsn
- SpokeTag
- SpokeTagValue
- PreferredPathTag
- Label:
default: Anonymous Metrics Request
Parameters:
- SendAnonymousData
ParameterLabels:
BgpAsn:
default: Transit VPC BGP ASN
SpokeTag:
default: Spoke VPC Tag Name
SpokeTagValue:
default: Spoke VPC Tag Value
PreferredPathTag:
default: Preferred VPN Endpoint Tag Name
VpcCidr:
default: Transit VPC CIDR Block
PubSubnet1:
default: 1st Subnet Network
PubSubnet2:
default: 2nd Subnet Network
CSRType:
default: CSR Throughput Requirements
KeyName:
default: SSH Key to access CSR
S3Prefix:
default: Prefix for S3 Objects
LicenseModel:
default: License Model
TerminationProtection:
default: Enable Termination Protection
AccountId:
default: Additional AWS Account ID (Optional)
Mappings:
Function:
Configurator:
CodeLocation: solutions-reference/transit-vpc/v3/transit-vpc-push-cisco-config.zip
CodeRegion: us-east-1
Name: cisco-configurator
Description: >-
Transit VPC: This function is invoked when a generic VPN configuration
is placed in an S3 bucket - it converts the generic information into
Cisco IOS specific commands and pushes the config to transit VPC
routers.
Runtime: python2.7
Timeout: '300'
MemorySize: '128'
Poller:
CodeLocation: solutions-reference/transit-vpc/v3/transit-vpc-poller.py
CodeRegion: us-east-1
Name: vgw-poller
Description: >-
Transit VPC: Poller function responsible for identifying specifically
tagged VGWs and creating VPN connections to transit VPC.
Runtime: python2.7
Timeout: '120'
MemorySize: '128'
FindReplace:
S3BucketID: '%BUCKET_NAME%'
S3PrefixID: '%PREFIX%'
Deliminator: '|'
Csr:
UserName: automate
PasswordLength: '15'
PrivateKey: prikey.pem
PublicKey: pubkey.pem
CiscoCsrAMI:
us-east-1:
BYOL: ami-d17520c6
LicenseIncluded: ami-53742144
us-east-2:
BYOL: ami-e7104a82
LicenseIncluded: ''
us-west-2:
BYOL: ami-1ed2087e
LicenseIncluded: ami-c1df05a1
us-west-1:
BYOL: ami-75501815
LicenseIncluded: ami-77501817
eu-west-1:
BYOL: ami-5084c923
LicenseIncluded: ami-858ac7f6
eu-central-1:
BYOL: ami-6602fc09
LicenseIncluded: ami-b707f9d8
ap-south-1:
BYOL: ami-cd7e0aa2
LicenseIncluded: ami-f17a0e9e
ap-southeast-1:
BYOL: ami-f81bbc9b
LicenseIncluded: ami-a018bfc3
ap-southeast-2:
BYOL: ami-e7e7d584
LicenseIncluded: ami-a4e7d5c7
ap-northeast-1:
BYOL: ami-f6ba1f97
LicenseIncluded: ami-62862303
ap-northeast-2:
BYOL: ami-2cc01442
LicenseIncluded: ami-12c1157c
sa-east-1:
BYOL: ami-7a940916
LicenseIncluded: ami-83910cef
CsrInstance:
2x500Mbps:
Type: c4.large
Bandwidth: '500000'
2x1Gbps:
Type: c4.xlarge
Bandwidth: '1000000'
2x2Gbps:
Type: c4.2xlarge
Bandwidth: '2000000'
2x4.5Gbps:
Type: c4.4xlarge
Bandwidth: '4500000'
Resources:
VPNConfigS3Bucket:
Type: 'AWS::S3::Bucket'
VPNConfigBucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket: !Ref VPNConfigS3Bucket
PolicyDocument:
Statement:
- Sid: DenyUnEncryptedObjectUploads
Effect: Deny
Principal: '*'
Action: 's3:PutObject'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref VPNConfigS3Bucket
- /
- !Ref S3Prefix
- '*'
Condition:
StringNotEquals:
's3:x-amz-server-side-encryption': 'aws:kms'
- Action:
- 's3:GetObject'
- 's3:PutObject'
- 's3:PutObjectAcl'
Effect: Allow
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref VPNConfigS3Bucket
- /
- !Ref S3Prefix
- '*'
Principal:
AWS:
- !Join
- ''
- - 'arn:aws:iam::'
- !If
- AuthorizeAnotherAccount
- !Ref AccountId
- !Ref 'AWS::AccountId'
- ':root'
KMSKey:
Type: 'AWS::KMS::Key'
Properties:
Description: TransitVPC CMK for S3 SSE-KMS
KeyPolicy:
Version: 2012-10-17
Id: transit-vpc-1
Statement:
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS:
- !Join
- ''
- - 'arn:aws:iam::'
- !Ref 'AWS::AccountId'
- ':root'
Action:
- 'kms:*'
Resource: '*'
- Sid: Allow use of the key
Effect: Allow
Principal:
AWS:
- !Join
- ''
- - 'arn:aws:iam::'
- !If
- AuthorizeAnotherAccount
- !Ref AccountId
- !Ref 'AWS::AccountId'
- ':root'
- !GetAtt
- SolutionHelperRole
- Arn
- !GetAtt
- CiscoConfigFunctionRole
- Arn
- !GetAtt
- TransitVpcPollerRole
- Arn
Action:
- 'kms:Encrypt'
- 'kms:Decrypt'
- 'kms:ReEncrypt*'
- 'kms:GenerateDataKey*'
- 'kms:DescribeKey'
Resource: '*'
KMSKeyAlias:
Type: 'AWS::KMS::Alias'
Properties:
AliasName: !Join
- ''
- - alias/
- !Ref 'AWS::StackName'
- '-key'
TargetKeyId: !Ref KMSKey
TransitVPC:
Type: 'AWS::EC2::VPC'
Properties:
CidrBlock: !Ref VpcCidr
Tags:
- Key: Name
Value: Transit VPC
VPCPubSub1:
Type: 'AWS::EC2::Subnet'
Properties:
VpcId: !Ref TransitVPC
CidrBlock: !Ref PubSubnet1
AvailabilityZone: !Select
- '0'
- !GetAZs ''
Tags:
- Key: Network
Value: Public
- Key: Name
Value: Transit VPC Subnet1
VPCPubSub2:
Type: 'AWS::EC2::Subnet'
Properties:
VpcId: !Ref TransitVPC
CidrBlock: !Ref PubSubnet2
AvailabilityZone: !Select
- '1'
- !GetAZs ''
Tags:
- Key: Network
Value: Public
- Key: Name
Value: Transit VPC Subnet2
IGW:
Type: 'AWS::EC2::InternetGateway'
Properties:
Tags:
- Key: Name
Value: Transit VPC IGW
IGWToInternet:
Type: 'AWS::EC2::VPCGatewayAttachment'
Properties:
VpcId: !Ref TransitVPC
InternetGatewayId: !Ref IGW
VPCRouteTable:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref TransitVPC
Tags:
- Key: Network
Value: Public
- Key: Name
Value: Transit VPC
VPCPublicRoute:
Type: 'AWS::EC2::Route'
Properties:
RouteTableId: !Ref VPCRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref IGW
S3Endpoint:
Type: 'AWS::EC2::VPCEndpoint'
Properties:
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal: '*'
Action:
- 's3:*'
Resource:
- '*'
RouteTableIds:
- !Ref VPCRouteTable
ServiceName: !Join
- ''
- - com.amazonaws.
- !Ref 'AWS::Region'
- .s3
VpcId: !Ref TransitVPC
VPCPubSubnetRouteTableAssociation1:
Type: 'AWS::EC2::SubnetRouteTableAssociation'
Properties:
SubnetId: !Ref VPCPubSub1
RouteTableId: !Ref VPCRouteTable
VPCPubSubnetRouteTableAssociation2:
Type: 'AWS::EC2::SubnetRouteTableAssociation'
Properties:
SubnetId: !Ref VPCPubSub2
RouteTableId: !Ref VPCRouteTable
CsrEip1:
Type: 'AWS::EC2::EIP'
Properties:
Domain: vpc
InstanceId: !Ref VpcCsr1
CsrEip2:
Type: 'AWS::EC2::EIP'
Properties:
Domain: vpc
InstanceId: !Ref VpcCsr2
VpcCsr1:
Type: 'AWS::EC2::Instance'
Metadata:
Comment1: Launch Cisco CSR1
Properties:
InstanceType: !FindInMap
- CsrInstance
- !Ref CSRType
- Type
KeyName: !Ref KeyName
DisableApiTermination: !If
- EnableTerm
- true
- false
ImageId: !FindInMap
- CiscoCsrAMI
- !Ref 'AWS::Region'
- !Ref LicenseModel
SubnetId: !Ref VPCPubSub1
SecurityGroupIds:
- !Ref CSRSecurityGroup
Tags:
- Key: Name
Value: Transit VPC CSR1
UserData: !Base64
'Fn::Join':
- ''
- - 'ios-config-1="username '
- !FindInMap
- Function
- Csr
- UserName
- ' priv 15 pass '
- !GetAtt
- CreateRandomPassword
- Password
- |
"
- |
ios-config-2="service password-encryption"
- |
ios-config-3="crypto isakmp policy 200"
- |
ios-config-4="encryption aes 128"
- |
ios-config-5="authentication pre-share"
- |
ios-config-6="group 2"
- |
ios-config-7="lifetime 28800"
- |
ios-config-8="hash sha"
- >
ios-config-9="crypto ipsec transform-set ipsec-prop-vpn-aws
esp-aes 128 esp-sha-hmac"
- |
ios-config-10="mode tunnel"
- |
ios-config-11="crypto ipsec df-bit clear"
- |
ios-config-12="crypto isakmp keepalive 10 10 on-demand"
- >
ios-config-13="crypto ipsec security-association replay
window-size 1024"
- |
ios-config-14="crypto ipsec fragmentation before-encryption"
- |
ios-config-15="crypto ipsec profile ipsec-vpn-aws"
- |
ios-config-16="set pfs group2"
- |
ios-config-17="set security-association lifetime seconds 3600"
- |
ios-config-18="set transform-set ipsec-prop-vpn-aws"
- 'ios-config-19="router bgp '
- !Ref BgpAsn
- |
"
- |
ios-config-20="bgp log-neighbor-changes"
- |
ios-config-21="ip vrf vpn0"
- 'ios-config-22="rd '
- !Ref BgpAsn
- |
:0"
- |
ios-config-23="ip ssh pubkey-chain"
- 'ios-config-24="username '
- !FindInMap
- Function
- Csr
- UserName
- |
"
- 'ios-config-25="key-hash ssh-rsa '
- !GetAtt
- CreateRsaKey
- Fingerprint
- |
"
- |
ios-config-26="ip ssh server algorithm authentication publickey"
- |
ios-config-27="ip ssh maxstartups 1"
VpcCsr2:
Type: 'AWS::EC2::Instance'
Metadata:
Comment1: Launch Cisco CSR2
Properties:
InstanceType: !FindInMap
- CsrInstance
- !Ref CSRType
- Type
KeyName: !Ref KeyName
DisableApiTermination: !If
- EnableTerm
- true
- false
ImageId: !FindInMap
- CiscoCsrAMI
- !Ref 'AWS::Region'
- !Ref LicenseModel
SubnetId: !Ref VPCPubSub2
SecurityGroupIds:
- !Ref CSRSecurityGroup
Tags:
- Key: Name
Value: Transit VPC CSR2
UserData: !Base64
'Fn::Join':
- ''
- - 'ios-config-1="username '
- !FindInMap
- Function
- Csr
- UserName
- ' priv 15 pass '
- !GetAtt
- CreateRandomPassword
- Password
- |
"
- |
ios-config-2="service password-encryption"
- |
ios-config-3="crypto isakmp policy 200"
- |
ios-config-4="encryption aes 128"
- |
ios-config-5="authentication pre-share"
- |
ios-config-6="group 2"
- |
ios-config-7="lifetime 28800"
- |
ios-config-8="hash sha"
- >
ios-config-9="crypto ipsec transform-set ipsec-prop-vpn-aws
esp-aes 128 esp-sha-hmac"
- |
ios-config-10="mode tunnel"
- |
ios-config-11="crypto ipsec df-bit clear"
- |
ios-config-12="crypto isakmp keepalive 10 10 on-demand"
- >
ios-config-13="crypto ipsec security-association replay
window-size 1024"
- |
ios-config-14="crypto ipsec fragmentation before-encryption"
- |
ios-config-15="crypto ipsec profile ipsec-vpn-aws"
- |
ios-config-16="set pfs group2"
- |
ios-config-17="set security-association lifetime seconds 3600"
- |
ios-config-18="set transform-set ipsec-prop-vpn-aws"
- 'ios-config-19="router bgp '
- !Ref BgpAsn
- |
"
- |
ios-config-20="bgp log-neighbor-changes"
- |
ios-config-21="ip vrf vpn0"
- 'ios-config-22="rd '
- !Ref BgpAsn
- |
:0"
- |
ios-config-23="ip ssh pubkey-chain"
- 'ios-config-24="username '
- !FindInMap
- Function
- Csr
- UserName
- |
"
- 'ios-config-25="key-hash ssh-rsa '
- !GetAtt
- CreateRsaKey
- Fingerprint
- |
"
- |
ios-config-26="ip ssh server algorithm authentication publickey"
- |
ios-config-27="ip ssh maxstartups 1"
SolutionHelperRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: 'sts:AssumeRole'
Path: /
SolutionHelperRolePolicy:
Type: 'AWS::IAM::Policy'
Properties:
Roles:
- !Ref SolutionHelperRole
PolicyName: Solution_Helper_Permissions
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: !Join
- ''
- - 'arn:aws:logs:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':log-group:/aws/lambda/*'
- Effect: Allow
Action:
- 's3:PutBucketNotification'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref VPNConfigS3Bucket
- Effect: Allow
Action:
- 'lambda:*'
- 'events:*'
- 'ec2:DescribeSecurityGroups'
- 'ec2:DescribeSubnets'
- 'ec2:DescribeVpcs'
Resource: '*'
- Effect: Allow
Action:
- 'iam:PassRole'
Resource:
- !GetAtt
- CiscoConfigFunctionRole
- Arn
- !GetAtt
- TransitVpcPollerRole
- Arn
- Effect: Allow
Action:
- 's3:PutObject'
- 's3:GetObject'
- 's3:DeleteObject'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref VPNConfigS3Bucket
- /
- !Ref S3Prefix
- '*'
- Effect: Allow
Action:
- 's3:GetObject'
Resource: 'arn:aws:s3:::solutions-reference/*'
SolutionHelper:
Type: 'AWS::Lambda::Function'
DependsOn: SolutionHelperRolePolicy
Properties:
Handler: solution-helper.lambda_handler
Role: !GetAtt
- SolutionHelperRole
- Arn
Description: >-
Transit VPC: CloudFormation custom resource function invoked during
transit VPC CloudFormation create, update, and delete stack operations.
Code:
S3Bucket: !Join
- ''
- - solutions-
- !Ref 'AWS::Region'
S3Key: library/solution-helper/v3/solution-helper.zip
Runtime: python2.7
Timeout: '60'
CreateRsaKey:
Type: 'Custom::LoadLambda'
Properties:
ServiceToken: !GetAtt
- SolutionHelper
- Arn
Region: !Ref 'AWS::Region'
CreateSshKey: !Join
- ''
- - '{ ''Bucket'' : '''
- !Ref VPNConfigS3Bucket
- ''', '
- '''SSEKMSKeyId'' : ''arn:aws:kms:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':key/'
- !Ref KMSKey
- ''', '
- '''PrivateKey'' : '''
- !Ref S3Prefix
- !FindInMap
- Function
- Csr
- PrivateKey
- ''', '
- '''PublicKey'' : '''
- !Ref S3Prefix
- !FindInMap
- Function
- Csr
- PublicKey
- ''' '
- '}'
CreateRandomPassword:
Type: 'Custom::LoadLambda'
Properties:
ServiceToken: !GetAtt
- SolutionHelper
- Arn
Region: !Ref 'AWS::Region'
CreateRandomPassword: !FindInMap
- Function
- Csr
- PasswordLength
RandomPasswordSpecialCharacters: 'False'
CiscoConfigFunctionRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: 'sts:AssumeRole'
Path: /
CiscoConfigFunctionRolePolicy:
Type: 'AWS::IAM::Policy'
Properties:
Roles:
- !Ref CiscoConfigFunctionRole
PolicyName: Cisco_Config_Permissions
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: !Join
- ''
- - 'arn:aws:logs:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':log-group:/aws/lambda/*'
- Effect: Allow
Action:
- 'ec2:CreateNetworkInterface'
- 'ec2:DescribeNetworkInterfaces'
- 'ec2:DetachNetworkInterface'
- 'ec2:DeleteNetworkInterface'
Resource: '*'
- Effect: Allow
Action:
- 's3:PutObject'
- 's3:GetObject'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref VPNConfigS3Bucket
- /
- !Ref S3Prefix
- '*'
CiscoConfigFunct:
Type: 'Custom::LoadLambda'
Properties:
ServiceToken: !GetAtt
- SolutionHelper
- Arn
Region: !Ref 'AWS::Region'
LambdaCode: !FindInMap
- Function
- Configurator
- CodeLocation
LambdaCodeRegion: !FindInMap
- Function
- Configurator
- CodeRegion
FunctionName: !Join
- ''
- - !Ref 'AWS::StackName'
- '-'
- !FindInMap
- Function
- Configurator
- Name
Role: !GetAtt
- CiscoConfigFunctionRole
- Arn
Runtime: !FindInMap
- Function
- Configurator
- Runtime
Description: !FindInMap
- Function
- Configurator
- Description
Timeout: !FindInMap
- Function
- Configurator
- Timeout
MemorySize: !FindInMap
- Function
- Configurator
- MemorySize
VpcConfig: !Join
- ''
- - '{ ''SubnetIds'': ['
- ''''
- !Ref VPCPubSub1
- ''','
- ''''
- !Ref VPCPubSub2
- '''],'
- '''SecurityGroupIds'': ['
- ''''
- !Ref CiscoConfigSecurityGroup
- ''']'
- '}'
S3Event: !Join
- ''
- - '{ ''Bucket'' : '''
- !Ref VPNConfigS3Bucket
- ''', '
- '''EventPattern'' : {'
- '''LambdaFunctionConfigurations'' : [ {'
- '''LambdaFunctionArn'': ''Replace_by_SolutionHelper'','
- '''Events'': [''s3:ObjectCreated:Put'' ],'
- '''Filter'': {'
- '''Key'': {'
- '''FilterRules'': [ {'
- '''Name'': ''prefix'','
- '''Value'': '''
- !Ref S3Prefix
- ''''
- '}, {'
- '''Name'': ''suffix'','
- '''Value'': ''.conf'''
- '} ] } }'
- '} ] }'
- '}'
StoreInS3KMS: !Join
- ''
- - '[{ ''Bucket'' : '''
- !Ref VPNConfigS3Bucket
- ''', '
- '''Key'' : '''
- !Ref S3Prefix
- 'transit_vpc_config.txt'', '
- '''SSEKMSKeyId'' : ''arn:aws:kms:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':key/'
- !Ref KMSKey
- ''', '
- '''Body'': "{'
- '''UUID'':'''
- !GetAtt
- CreateUniqueID
- UUID
- ''','
- '''SENDDATA'':'''
- !Ref SendAnonymousData
- ''','
- '''EIP1'':'''
- !Ref CsrEip1
- ''','
- '''EIP2'':'''
- !Ref CsrEip2
- ''','
- '''PIP1'':'''
- !GetAtt
- VpcCsr1
- PrivateIp
- ''','
- '''PIP2'':'''
- !GetAtt
- VpcCsr2
- PrivateIp
- ''','
- '''BGP_ASN'':'
- !Ref BgpAsn
- ','
- '''PREFERRED_PATH_TAG'':'''
- !Ref PreferredPathTag
- ''','
- '''HUB_TAG'':'''
- !Ref SpokeTag
- ''','
- '''HUB_TAG_VALUE'':'''
- !Ref SpokeTagValue
- ''','
- '''USER_NAME'':'''
- !FindInMap
- Function
- Csr
- UserName
- ''','
- '''PRIVATE_KEY'':'''
- !FindInMap
- Function
- Csr
- PrivateKey
- ''','
- '''PUBLIC_KEY'':'''
- !GetAtt
- CreateRsaKey
- PubKey
- ''','
- '''PASSWORD'':'''
- !GetAtt
- CreateRandomPassword
- Password
- ''','
- '''KMS_KEY'':''arn:aws:kms:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':key/'
- !Ref KMSKey
- ''''
- '}"'
- '}]'
TransitVpcPollerRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument: