-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCloudExchangeTemplate.yaml
1845 lines (1687 loc) · 59.2 KB
/
CloudExchangeTemplate.yaml
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: "CloudExchange CloudFormation deployment"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Basic details"
Parameters:
- CreateResources
- EnvName
- PackageType
- Label:
default: "Application Load Balancer details"
Parameters:
- CreateALB
- ExistingTargetGroup
- Label:
default: "Existing IAM role details"
Parameters:
- ExistingECSTaskRole
- ExistingSGandNACLLambdaRole
- Label:
default: "Existing resources details (applicable if 'Create new resources?' is 'False')"
Parameters:
- ExistingVPCId
- ExistingPrivateSubnet1ID
- ExistingPrivateSubnet2ID
- ExistingVPCCidr
- ExistingECSCluster
- Label:
default: "Network details (applicable if 'Create new resources?' is 'True')"
Parameters:
- VPCName
- VpcCIDR
- PrivateSubnet1CIDR
- PrivateSubnet2CIDR
- PublicSubnet1CIDR
- PublicSubnet2CIDR
- EnableVPCFlowLog
- Label:
default: "Environment variables"
Parameters:
- JWTSECRET
- MAINTENANCEPASSWORD
- MAINTENANCEPASSWORDESCAPED
- TLSVersion
- HTTPPROXY
- HTTPSPROXY
- WhitelistIP
- Label:
default: "CA Certificate"
Parameters:
- CACertFlag
- CACertSecretName
ParameterLabels:
VPCName:
default: "VPC name"
VpcCIDR:
default: "VPC CIDR range"
PrivateSubnet1CIDR:
default: "First private subnet CIDR range"
PrivateSubnet2CIDR:
default: "Second private subnet CIDR range"
ExistingVPCId:
default: "Existing VPC ID"
ExistingPrivateSubnet1ID:
default: "Existing first private subnet ID"
ExistingPrivateSubnet2ID:
default: "Existing second private subnet ID"
CreateResources:
default: "Create new resources?"
ExistingECSCluster:
default: "Existing ECS cluster name"
PublicSubnet1CIDR:
default: "First public subnet CIDR"
PublicSubnet2CIDR:
default: "Second public subnet CIDR"
ExistingALB:
default: "Existing ALB"
ExistingTargetGroup:
default: "Existing ARN of target group for ALB"
ExistingVPCCidr:
default: "Existing VPC CIDR block"
JWTSECRET:
default: "JWT secret"
MAINTENANCEPASSWORD:
default: "Maintenance password"
MAINTENANCEPASSWORDESCAPED:
default: "Maintenance password escaped"
TLSVersion:
default: "TLS version"
HTTPPROXY:
default: "HTTP proxy"
HTTPSPROXY:
default: "HTTPS proxy"
WhitelistIP:
default: "CIDR to allow access to Netskope Cloud Exchange"
EnvName:
default: "Environment name"
CreateALB:
default: "Create Application Load Balancer?"
ExistingECSTaskRole:
default: "Existing IAM role for ECS Task creation & execution"
ExistingSGandNACLLambdaRole:
default: "Existing IAM role for read/modify Security Groups & NACL"
EnableVPCFlowLog:
default: "Enable VPC Flow Logs"
PackageType:
default: "Package Type"
CACertFlag:
default: "Custom CA Certificate required for Proxy?"
CACertSecretName:
default: "Name of the Custom CA Certificate placeholder AWS Secret"
Parameters:
CreateResources:
Description: "Select 'True' to create new resources (VPC, Subnet, IGW, NAT Gateway, TargetGroup, ALB, HTTP Listener, etc) and 'False' to use existing resources"
Default: "True"
Type: String
AllowedValues: ["True", "False"]
VPCName:
Description: "Enter the VPC name to create new VPC where Netskope Cloud Exchange will be deployed "
Type: String
Default: "CloudExchange-VPC"
VpcCIDR:
Description: "Enter the IP range (CIDR notation) for the VPC "
Type: String
Default: 172.16.0.0/16
ExistingVPCCidr:
Description: "Enter the VPC CIDR block of existing VPC (required if 'Create new resources?' is 'False')"
Type: String
Default: 172.16.0.0/16
PrivateSubnet1CIDR:
Description: "Enter the IP range (CIDR notation) for first subnet "
Type: String
Default: 172.16.1.0/24
PrivateSubnet2CIDR:
Description: "Enter the IP Range (CIDR notation) for second subnet "
Type: String
Default: 172.16.2.0/24
ExistingVPCId:
Type: String
Default: ""
Description: "Enter the existing VPC ID where Netskope Cloud Exchange will be deployed (required if 'Create new resources?' is 'False')"
ExistingPrivateSubnet1ID:
Type: String
Default: ""
Description: "Enter the first subnet ID (in first availability zone) where the EFS filesystem for Netskope Cloud Exchange will be deployed. Note that custom resource Lambda function in this stack should be able to communicate from this subnet to Amazon S3 regional endpoint (required if 'Create new resources?' is 'False')"
ExistingPrivateSubnet2ID:
Type: String
Default: ""
Description: "Enter the second subnet ID (in second availability zone) where the EFS filesystem for Netskope Cloud Exchange will be deployed. Note that custom resource Lambda function in this stack should be able to communicate from this subnet to Amazon S3 regional endpoint (required if 'Create new resources?' is 'False')"
MAINTENANCEPASSWORD:
Description: "A maintenance password that will be used for RabbitMQ and MongoDB services (This password can be set only once)"
Type: String
Default: "cteadmin"
NoEcho: "true"
MAINTENANCEPASSWORDESCAPED:
Description: "URL encoded version of the Maintenance Password"
Type: String
Default: cteadmin
NoEcho: "true"
ExistingECSCluster:
Type: String
Default: ""
Description: "Enter the existing cluster to deploy Netskope Cloud Exchange service (if blank, new cluster will be created)"
PublicSubnet1CIDR:
Description: "Enter the IP range (CIDR notation) for the public subnet in first availability zone "
Type: String
Default: 172.16.3.0/24
PublicSubnet2CIDR:
Description: "Enter the IP range (CIDR notation) for the public subnet in second availability zone "
Type: String
Default: 172.16.4.0/24
ExistingTargetGroup:
Description: "Enter the ARN of existing target group attached to the load balancer to deploy Netskope Cloud Exchange (applicable if 'Create Application Load Balancer?' is 'False') (if provided existing ALB else if left blank, no ALB would be used)"
Type: String
Default: ""
TLSVersion:
Description: "This TLS version will be used to access the UI"
Type: String
Default: "TLSv1.3"
AllowedValues: ["TLSv1.3", "TLSv1.2 TLSv1.3"]
HTTPSPROXY:
Description: "Proxy URL to be used for outbound HTTPS traffic (e.g. https://user:[email protected]:3128)"
Type: String
Default: ""
HTTPPROXY:
Description: "Proxy URL to be used for outbound HTTP traffic (e.g. http://user:[email protected]:3128)"
Type: String
Default: ""
JWTSECRET:
Description: "A random secure string that will be used for signing the authentication tokens"
Type: String
Default: verysercterdyuri18
NoEcho: "true"
WhitelistIP:
Description: "Provide IP range to grant access for Netskope Cloud Exchange (required if load balancer is to be used)"
Type: String
Default: "172.16.0.0/16"
EnvName:
Description: "This parameter is to support co-existence of multiple Netskope Cloud Exchange deployments"
Type: String
Default: "netskope-ce"
AllowedPattern: ^[a-zA-Z0-9//-]*$
CreateALB:
Type: String
Default: "True"
AllowedValues: ["True", "False"]
ExistingECSTaskRole:
Description: "Enter the ARN of the existing IAM role having required permissions for ECS Task creation/execution (if provided existing IAM role will be used else if left blank, new IAM role will be created)"
Type: String
ExistingSGandNACLLambdaRole:
Description: "Enter the ARN of the existing IAM role having required permissions for read & modify Security Groups & NACL for security best practices (if provided existing IAM role will be used else if left blank, new IAM role will be created) (applicable if 'Create new resources?' is 'True' else completely ignored)"
Type: String
EnableVPCFlowLog:
Description: "Select 'True' to enable VPC Flow Logs (AWS user account or the AWS IAM role deploying the CLoudFormation stack requires AWS IAM access to enable VPC Flow Logs) (It is recommended to enable VPC Flow Logs as per security best practices)"
Type: String
Default: "True"
AllowedValues: ["True", "False"]
PackageType:
Description: "Select the package type based on the Netskope CE use case"
Type: String
Default: "Medium"
AllowedValues: [ "Extra-Small", "Small", "Medium", "Large" ]
CACertFlag:
Description: "Select True to enable secure connection to the Proxy Server"
Type: String
Default: "False"
AllowedValues: [ "True", "False"]
CACertSecretName:
Description: "Enter the name of the secret within AWS Secrets Manager where Custom CA certificate file has been uploaded"
Type: String
Mappings:
RegionMap:
us-east-1:
ELBId: "127311923021"
us-east-2:
ELBId: "033677994240"
us-west-1:
ELBId: "027434742980"
us-west-2:
ELBId: "797873946194"
af-south-1:
ELBId: "098369216593"
ca-central-1:
ELBId: "985666609251"
eu-central-1:
ELBId: "054676820928"
eu-west-1:
ELBId: "156460612806"
eu-west-2:
ELBId: "652711504416"
eu-west-3:
ELBId: "009996457667"
eu-south-1:
ELBId: "635631232127"
eu-north-1:
ELBId: "897822967062"
ap-east-1:
ELBId: "754344448648"
ap-northeast-1:
ELBId: "582318560864"
ap-northeast-2:
ELBId: "600734575887"
ap-northeast-3:
ELBId: "383597477331"
ap-southeast-1:
ELBId: "114774131450"
ap-southeast-2:
ELBId: "783225319266"
ap-southeast-3:
ELBId: "589379963580"
ap-south-1:
ELBId: "718504428378"
me-south-1:
ELBId: "076674570225"
sa-east-1:
ELBId: "507241528517"
us-gov-west-1:
ELBId: "048591011584"
us-gov-east-1:
ELBId: "190560391635"
cn-north-1:
ELBId: "638102146993"
cn-northwest-1:
ELBId: "037604701340"
CPUMapping:
Extra-Small:
CPU: 4096
Small:
CPU: 8192
Medium:
CPU: 8192
Large:
CPU: 16384
MemoryMapping:
Extra-Small:
Memory: 8192
Small:
Memory: 16384
Medium:
Memory: 16384
Large:
Memory: 32768
RabbitMQAvailableDiskSpace:
Extra-Small:
Disk: 42949672960
Small:
Disk: 42949672960
Medium:
Disk: 85899345920
Large:
Disk: 128849018880
Conditions:
ECSClusterFlag: !Equals
- !Ref ExistingECSCluster
- ""
ExistingALBFlag: !Not [ !Equals [ !Ref ExistingTargetGroup, "" ] ]
CreateNewResources: !Equals
- !Ref CreateResources
- "True"
CreateALB: !Equals
- !Ref CreateALB
- "True"
AttachCACert: !Equals
- !Ref CACertFlag
- "True"
CreateECSTaskRole: !Equals
- !Ref ExistingECSTaskRole
- ""
CreateLambdaRole: !Equals
- !Ref ExistingSGandNACLLambdaRole
- ""
VPCFlowLogCondition: !Equals
- !Ref EnableVPCFlowLog
- "True"
VPCFlowLogResourceCreation: !And [ Condition: CreateNewResources, Condition: VPCFlowLogCondition ]
SGandNACLModifyLambdaRole: !And [ Condition: CreateNewResources, Condition: CreateLambdaRole ]
CreateWithALB: !Or [ Condition: CreateALB, Condition: ExistingALBFlag]
CreateWithoutALB: !Not [Condition: CreateWithALB]
Resources:
VPC:
Type: "AWS::EC2::VPC"
Condition: CreateNewResources
Properties:
CidrBlock: !Ref VpcCIDR
EnableDnsSupport: "true"
EnableDnsHostnames: "true"
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName}
PrivateSubnet1:
Type: AWS::EC2::Subnet
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs ""]
CidrBlock: !Ref PrivateSubnet1CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Private Subnet (AZ1)
PrivateSubnet2:
Type: AWS::EC2::Subnet
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [1, !GetAZs ""]
CidrBlock: !Ref PrivateSubnet2CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Private Subnet (AZ2)
PublicSubnet1:
Type: AWS::EC2::Subnet
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs ""]
CidrBlock: !Ref PublicSubnet1CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Public Subnet (AZ1)
PublicSubnet2:
Type: AWS::EC2::Subnet
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [1, !GetAZs ""]
CidrBlock: !Ref PublicSubnet2CIDR
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Public Subnet (AZ2)
InternetGateway:
Type: AWS::EC2::InternetGateway
Condition: CreateNewResources
Properties:
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName}
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Condition: CreateNewResources
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
NatGateway1EIP:
Type: AWS::EC2::EIP
DependsOn: InternetGatewayAttachment
Condition: CreateNewResources
Properties:
Domain: VPC
NatGateway2EIP:
Type: AWS::EC2::EIP
DependsOn: InternetGatewayAttachment
Condition: CreateNewResources
Properties:
Domain: vpc
NatGateway1:
Type: AWS::EC2::NatGateway
Condition: CreateNewResources
Properties:
AllocationId: !GetAtt NatGateway1EIP.AllocationId
SubnetId: !Ref PublicSubnet1
NatGateway2:
Type: AWS::EC2::NatGateway
Condition: CreateNewResources
Properties:
AllocationId: !GetAtt NatGateway2EIP.AllocationId
SubnetId: !Ref PublicSubnet2
PublicRouteTable:
Type: AWS::EC2::RouteTable
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Public Routes
DefaultPublicRoute:
Type: AWS::EC2::Route
Condition: CreateNewResources
DependsOn: InternetGatewayAttachment
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateNewResources
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet1
PublicSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateNewResources
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet2
PrivateRouteTable1:
Type: AWS::EC2::RouteTable
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Private Routes (AZ1)
DefaultPrivateRoute1:
Type: AWS::EC2::Route
Condition: CreateNewResources
Properties:
RouteTableId: !Ref PrivateRouteTable1
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway1
PrivateSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateNewResources
Properties:
RouteTableId: !Ref PrivateRouteTable1
SubnetId: !Ref PrivateSubnet1
PrivateRouteTable2:
Type: AWS::EC2::RouteTable
Condition: CreateNewResources
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${EnvName}-${VPCName} Private Routes (AZ2)
DefaultPrivateRoute2:
Type: AWS::EC2::Route
Condition: CreateNewResources
Properties:
RouteTableId: !Ref PrivateRouteTable2
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGateway2
PrivateSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateNewResources
Properties:
RouteTableId: !Ref PrivateRouteTable2
SubnetId: !Ref PrivateSubnet2
EC2EndpointSecurityGroup:
Type: AWS::EC2::SecurityGroup
Condition: CreateNewResources
DependsOn: PrivateSubnet2RouteTableAssociation
Properties:
VpcId: !Ref VPC
GroupName: !Sub "${AWS::StackName}-EC2-PrivateEndpoint-SG"
GroupDescription: Used by Netskope CE EC2 Endpoint
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 0
ToPort: 65535
CidrIp: !Ref VpcCIDR
SecurityGroupEgress:
- IpProtocol: "-1"
CidrIp: 0.0.0.0/0
EC2PrivateInterfaceEndpoint:
Type: 'AWS::EC2::VPCEndpoint'
Condition: CreateNewResources
DependsOn: PrivateSubnet2RouteTableAssociation
Properties:
VpcEndpointType: Interface
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.ec2'
VpcId: !Ref VPC
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref EC2EndpointSecurityGroup
NetskopeCloudExchangeTaskExecutionRole:
Type: "AWS::IAM::Role"
Condition: CreateECSTaskRole
Properties:
RoleName: !Sub "NetskopeCloudExchangeTaskExecutionRole-${AWS::StackName}"
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- "sts:AssumeRole"
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Path: /
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
NetskopeCloudExchangeTaskRole:
Type: "AWS::IAM::Role"
Condition: CreateECSTaskRole
Properties:
RoleName: !Sub "NetskopeCloudExchangeTaskRole-${AWS::StackName}"
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- "sts:AssumeRole"
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/SecretsManagerReadWrite"
Path: /
Policies:
- PolicyName: !Sub "NetskopeCloudExchangeTaskPolicy-${AWS::StackName}"
PolicyDocument:
Statement:
- Effect: Allow
Action:
- "elasticfilesystem:ClientMount"
- "elasticfilesystem:ClientWrite"
- "ecr:GetAuthorizationToken"
- "ecr:BatchCheckLayerAvailability"
- "ecr:GetDownloadUrlForLayer"
- "ecr:BatchGetImage"
- "ssmmessages:CreateControlChannel"
- "ssmmessages:CreateDataChannel"
- "ssmmessages:OpenControlChannel"
- "ssmmessages:OpenDataChannel"
Resource: "*"
VPCFlowLogRole:
Type: "AWS::IAM::Role"
Condition: VPCFlowLogResourceCreation
Properties:
RoleName: !Sub "NetskopeCloudExchangeFlowLogRole-${AWS::StackName}"
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- "sts:AssumeRole"
Effect: Allow
Principal:
Service:
- vpc-flow-logs.amazonaws.com
Path: /
Policies:
- PolicyName: !Sub "NetskopeCloudExchangeFlowLogPolicy-${AWS::StackName}"
PolicyDocument:
Statement:
- Effect: Allow
Action:
- "logs:CreateLogStream"
- "logs:DescribeLogGroups"
- "logs:DescribeLogStreams"
- "logs:CreateLogGroup"
- "logs:PutLogEvents"
Resource: "*"
VPCFlowLog:
Type: AWS::EC2::FlowLog
Condition: VPCFlowLogResourceCreation
Properties:
DeliverLogsPermissionArn: !GetAtt VPCFlowLogRole.Arn
LogGroupName: !Sub "Netskope-CE-VPC-FlowLogsGroup-${AWS::StackName}"
ResourceId: !Ref VPC
ResourceType: VPC
TrafficType: REJECT
LogDestinationType: cloud-watch-logs
TaskSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: !If [CreateNewResources, !Ref VPC, !Ref ExistingVPCId]
GroupName: !Sub "${AWS::StackName}-NetskopeCloudExchangeTaskGroup"
GroupDescription: Used by Netskope CloudExchange ECS task
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3000
ToPort: 3000
CidrIp: !If [CreateNewResources, !Ref VpcCIDR, !Ref ExistingVPCCidr]
SecurityGroupEgress:
- IpProtocol: tcp
FromPort: 2049
ToPort: 2049
CidrIp: "0.0.0.0/0"
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: "0.0.0.0/0"
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: "0.0.0.0/0"
- IpProtocol: "-1"
CidrIp: 0.0.0.0/0
ALBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Condition: CreateALB
Properties:
VpcId: !If [CreateNewResources, !Ref VPC, !Ref ExistingVPCId]
GroupName: !Sub "${AWS::StackName}-NetskopeCloudExchangeALBGroup"
GroupDescription: Used by Netskope ALB
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: !Ref WhitelistIP
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: !Ref WhitelistIP
SecurityGroupEgress:
- IpProtocol: "-1"
CidrIp: 0.0.0.0/0
NetskopeCloudExchangeEFSSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: !If [CreateNewResources, !Ref VPC, !Ref ExistingVPCId]
GroupDescription: Grants EFS access to the VPC subnets
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 2049
ToPort: 2049
SourceSecurityGroupId: !Ref TaskSecurityGroup
RoleWaitHandle:
Condition: CreateECSTaskRole
DependsOn: NetskopeCloudExchangeTaskRole
Type: "AWS::CloudFormation::WaitConditionHandle"
RoleWaitHandleFalse:
Type: "AWS::CloudFormation::WaitConditionHandle"
RoleWaitCondition:
Type: "AWS::CloudFormation::WaitCondition"
Properties:
Handle: !If [CreateECSTaskRole, !Ref RoleWaitHandle, !Ref RoleWaitHandleFalse]
Timeout: "1"
Count: 0
NetskopeCloudExchangeEFS:
Type: "AWS::EFS::FileSystem"
DependsOn: RoleWaitCondition
Properties:
BackupPolicy:
Status: ENABLED
Encrypted: true
FileSystemTags:
- Key: Name
Value: !Sub "NetskopeCloudExchange-${AWS::StackName}"
FileSystemPolicy:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "elasticfilesystem:ClientMount"
- "elasticfilesystem:ClientWrite"
Principal:
AWS: !If [CreateECSTaskRole, !Sub "arn:aws:iam::${AWS::AccountId}:role/NetskopeCloudExchangeTaskRole-${AWS::StackName}", !Ref ExistingECSTaskRole]
Condition:
Bool:
"aws:SecureTransport": true
MountTargetResource1:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
SubnetId:
!If [CreateNewResources, !Ref PrivateSubnet1, !Ref ExistingPrivateSubnet1ID]
SecurityGroups:
- !Ref NetskopeCloudExchangeEFSSecurityGroup
MountTargetResource2:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
SubnetId:
!If [CreateNewResources, !Ref PrivateSubnet2, !Ref ExistingPrivateSubnet2ID]
SecurityGroups:
- !Ref NetskopeCloudExchangeEFSSecurityGroup
MongoDBAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/mongo-data/data/db"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
CertificateAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/certificate"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
MongoDBInitAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/mongo-init"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
SSLCertAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/ssl_certs"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
CustomPluginsAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/custom_plugins"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
CustomRepoAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/repos"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
RabbitMQAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/rabbitmq"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
RabbitmqDataAccessPoint:
Type: "AWS::EFS::AccessPoint"
Properties:
FileSystemId: !Ref NetskopeCloudExchangeEFS
PosixUser:
Uid: "1001"
Gid: "1001"
RootDirectory:
Path: "/data/rabbitmq-data"
CreationInfo:
OwnerGid: "1001"
OwnerUid: "1001"
Permissions: "0777"
NetskopeTaskLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/ecs/Netskope-Cloud-Exchange-4-${EnvName}
RetentionInDays: 3653
NetskopeECSCluster:
Type: "AWS::ECS::Cluster"
Condition: ECSClusterFlag
Properties:
ClusterName: !Sub Netskope-CE-${EnvName}-Cluster
ClusterSettings:
- Name: containerInsights
Value: enabled
taskdefinition:
Type: "AWS::ECS::TaskDefinition"
Properties:
ContainerDefinitions:
- Name: init-container
Image: "709825985650.dkr.ecr.us-east-1.amazonaws.com/netskope/cloudexchange:aws-cli-latest"
Essential: false
Command:
- /bin/bash
- -c
- Fn::If:
- AttachCACert
- Fn::Sub: echo $DATA | base64 -d - | tee /docker-entrypoint-initdb.d/init.sh && aws secretsmanager get-secret-value --secret-id ${CACertSecretName} --region ${AWS::Region} --query SecretString --output text > /certificate/cert.pem
- echo $DATA | base64 -d - | tee /docker-entrypoint-initdb.d/init.sh
Environment:
- Name: DATA
Value:
Fn::Base64: |
mongosh $MONGO_INITDB_DATABASE --authenticationDatabase admin -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --eval "db.createUser({user: '$MONGODB_USERNAME', pwd: '$MONGODB_PASSWORD', roles: [{ role: 'dbOwner', db: '$MONGO_INITDB_DATABASE'}]})"
MountPoints:
- SourceVolume: mongo-init
ContainerPath: /docker-entrypoint-initdb.d
ReadOnly: false
- SourceVolume: certificate
ContainerPath: /certificate
ReadOnly: false
VolumesFrom: []
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Sub /aws/ecs/Netskope-Cloud-Exchange-4-${EnvName}
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: Netskope
- Name: core-init-container
Image: "709825985650.dkr.ecr.us-east-1.amazonaws.com/netskope/core5:11062023"
Essential: false
Command:
- -c
- echo "copy /opt/netskope/plugins data to the EFS" && cp -r /opt/netskope/plugins/* /data && ls -l /data && echo "copy /opt/netskope/repos data to the EFS" && cp -r /opt/netskope/repos/* /repos && ls -l /repos
EntryPoint: ["/bin/sh"]
MountPoints:
- SourceVolume: custom_plugins
ContainerPath: /data
ReadOnly: false
- SourceVolume: repos
ContainerPath: /repos
ReadOnly: false
VolumesFrom: []
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Sub /aws/ecs/Netskope-Cloud-Exchange-4-${EnvName}
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: Netskope