-
Notifications
You must be signed in to change notification settings - Fork 105
/
aqua-ecs-fargate-envoy.yaml
876 lines (874 loc) · 25.7 KB
/
aqua-ecs-fargate-envoy.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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
This AWS CloudFormation template installs the Aqua Command Center components
in ECS FARGATE.
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: ECS Infrastructure Configuration
Parameters:
- ClusterName
- VpcId
- VpcCidr
- EcsInstanceSubnets
- LbSubnets
- Label:
default: Aqua Security Configuration
Parameters:
- AquaConsoleAccess
- AquaServerImage
- AquaGatewayImage
- AquaEnvoyImage
- Label:
default: 'RDS Configuration: RDS Configuration'
Parameters:
- RdsInstanceName
- RdsMasterUsername
- RdsMasterPassword
- RdsInstanceClass
- RdsStorage
- MultiAzDatabase
- AuditRdsInstanceName
- AuditRdsMasterUsername
- AuditRdsMasterPassword
- AuditRdsInstanceClass
- AuditRdsStorage
- AuditMultiAzDatabase
ParameterLabels:
ClusterName:
default: ECS cluster name
VpcId:
default: VPC ID
VpcCidr:
default: VPC CIDR
EcsInstanceSubnets:
default: ECS Instance Subnets
LbSubnets:
default: Aqua LB Subnets
AquaConsoleAccess:
default: Web Console Source
RdsInstanceName:
default: RDS instance name
RdsMasterUsername:
default: RDS username
RdsMasterPassword:
default: RDS password
RdsInstanceClass:
default: RDS instance type
RdsStorage:
default: RDS storage size (GB)
MultiAzDatabase:
default: Enable Multi-AZ RDS
AuditRdsInstanceName:
default: Audit RDS instance name
AuditRdsMasterUsername:
default: Audit RDS username
AuditRdsMasterPassword:
default: Audit RDS password
AuditRdsInstanceClass:
default: Audit RDS instance type
AuditRdsStorage:
default: Audit RDS storage size (GB)
AuditMultiAzDatabase:
default: Enable Multi-AZ Audit RDS
Parameters:
AquaServerImage:
Type: String
Description: Enter server image path on ECR
AquaGatewayImage:
Type: String
Description: Enter gateway image path on ECR
AquaEnvoyImage:
Type: String
Description: Enter envoy image path on ECR
ClusterName:
Description: Name of ecs cluster to be created
Type: String
MinLength: '5'
MaxLength: '25'
AllowedPattern: '[a-z0-9-]*'
VpcId:
Description: VpcId to deploy into
Type: 'AWS::EC2::VPC::Id'
VpcCidr:
Description: 'For use by load balancer service polling. Enter VPC CIDR. Ex: 10.0.0.0/16'
Type: String
EcsInstanceSubnets:
Type: 'List<AWS::EC2::Subnet::Id>'
Description: Select all the subnets ECS utilizes
ConstraintDescription: >-
Password must be at least 9 characters long and have 3 out of the
following: one number, one lower case, one upper case, or one special
character.
LbSubnets:
Type: 'List<AWS::EC2::Subnet::Id>'
Description: Select external ones if you need internet access.
AquaConsoleAccess:
Description: The IP address or range that may be used to access the Aqua Console
Type: String
MinLength: '9'
MaxLength: '18'
AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})'
ConstraintDescription: Must be a valid IP CIDR range of the form x.x.x.x/x
RdsInstanceName:
Default: aquadb
Description: ''
Type: String
MinLength: '1'
MaxLength: '64'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: Must begin with a letter and between 1 and 64 alphanumeric characters.
RdsMasterUsername:
Description: Enter the master username for the RDS instance.
Type: String
MinLength: '1'
MaxLength: '63'
AllowedPattern: '^[a-zA-Z0-9]*$'
ConstraintDescription: >-
Must be 1 to 63 characters long, begin with a letter, contain only
alphanumeric characters, and not be a reserved word by PostgreSQL engine.
RdsMasterPassword:
NoEcho: 'true'
Description: >-
Enter the master password for the RDS instance. This password must contain
8 to 128 characters and can be any printable ASCII character except @, /,
or ".
Type: String
MinLength: '8'
MaxLength: '128'
AllowedPattern: >-
^((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])|(?=.*[0-9])(?=.*[a-z])(?=.*[!@#$%^&*])|(?=.*[0-9])(?=.*[A-Z])(?=.*[!@#$%^&*])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])).{8,128}$
ConstraintDescription: >-
Password must be at least 9 characters long and have 3 out of the
following: one number, one lower case, one upper case, or one special
character.
RdsInstanceClass:
Description: ''
Type: String
Default: db.m5.8xlarge
ConstraintDescription: Must be a valid EC2 RDS instance type
RdsStorage:
Default: '40'
Description: ''
Type: Number
MinValue: '40'
MaxValue: '1024'
ConstraintDescription: Must be set to between 40 and 1024GB.
MultiAzDatabase:
Default: 'false'
Description: ''
Type: String
AllowedValues:
- 'true'
- 'false'
ConstraintDescription: Must be either true or false.
AuditRdsInstanceName:
Default: aquaAuditDb
Description: ''
Type: String
MinLength: '1'
MaxLength: '64'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: Must begin with a letter and between 1 and 64 alphanumeric characters.
AuditRdsMasterUsername:
Description: Enter the master username for the RDS instance.
Type: String
MinLength: '1'
MaxLength: '63'
AllowedPattern: '^[a-zA-Z0-9]*$'
ConstraintDescription: >-
Must be 1 to 63 characters long, begin with a letter, contain only
alphanumeric characters, and not be a reserved word by PostgreSQL engine.
AuditRdsMasterPassword:
NoEcho: 'true'
Description: >-
Enter the master password for the RDS instance. This password must contain
8 to 128 characters and can be any printable ASCII character except @, /,
or ".
Type: String
MinLength: '8'
MaxLength: '128'
AllowedPattern: >-
^((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])|(?=.*[0-9])(?=.*[a-z])(?=.*[!@#$%^&*])|(?=.*[0-9])(?=.*[A-Z])(?=.*[!@#$%^&*])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])).{8,128}$
ConstraintDescription: >-
Password must be at least 9 characters long and have 3 out of the
following: one number, one lower case, one upper case, or one special
character.
AuditRdsInstanceClass:
Description: ''
Type: String
Default: db.m5.4xlarge
ConstraintDescription: Must be a valid EC2 RDS instance type
AuditRdsStorage:
Default: '40'
Description: ''
Type: Number
MinValue: '40'
MaxValue: '1024'
ConstraintDescription: Must be set to between 40 and 1024GB.
AuditMultiAzDatabase:
Default: 'false'
Description: ''
Type: String
AllowedValues:
- 'true'
- 'false'
ConstraintDescription: Must be either true or false.
Resources:
EcsCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Ref ClusterName
AquaConsole:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
DependsOn:
- AquaConsoleSecurityGroup
Properties:
Name: !Join
- '-'
- - !Ref EcsCluster
- AquaConsole
Scheme: internet-facing
SecurityGroups:
- !Ref AquaConsoleSecurityGroup
Subnets: !Ref LbSubnets
Type: application
AquaConsoleTaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
DependsOn:
- AquaEcsTaskRole
- RdsInstance
- AquaConsoleLogs
- Secret0
- Secret1
Properties:
Family: !Join
- '-'
- - !Ref EcsCluster
- aqua-console
RequiresCompatibilities:
- FARGATE
Cpu: '4096'
Memory: '8192'
NetworkMode: awsvpc
ExecutionRoleArn: !Ref AquaEcsTaskRole
ContainerDefinitions:
- Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-console
Image: !Ref AquaServerImage
PortMappings:
- ContainerPort: '8080'
HostPort: '8080'
Protocol: tcp
- ContainerPort: '8443'
HostPort: '8443'
Protocol: tcp
Essential: 'true'
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Join ['-', ['/aqua/console', !Ref EcsCluster]]
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: aquaConsole
Secrets:
- Name: SCALOCK_DBPASSWORD
ValueFrom: !Ref Secret0
- Name: SCALOCK_AUDIT_DBPASSWORD
ValueFrom: !Ref Secret1
Environment:
- Name: AQUA_GRPC_MODE
Value: 1
- Name: AQUA_DOCKERLESS_SCANNING
Value: 1
- Name: SCALOCK_DBSSL
Value: require
- Name: SCALOCK_AUDIT_DBSSL
Value: require
- Name: SCALOCK_DBNAME
Value: scalock
- Name: BATCH_INSTALL_GATEWAY
Value: !GetAtt
- AquaNlb
- DNSName
- Name: SCALOCK_DBUSER
Value: !Ref RdsMasterUsername
- Name: SCALOCK_DBHOST
Value: !GetAtt
- RdsInstance
- Endpoint.Address
- Name: SCALOCK_AUDIT_DBUSER
Value: !Ref AuditRdsMasterUsername
- Name: SCALOCK_AUDIT_DBNAME
Value: slk_audit
- Name: SCALOCK_AUDIT_DBHOST
Value: !GetAtt
- AuditRdsInstance
- Endpoint.Address
TaskRoleArn: !Ref AquaEcsTaskRole
AquaConsoleService:
Type: 'AWS::ECS::Service'
DependsOn:
- AquaConsoleTaskDefinition
- AquaConsoleListener
- AquaConsoleGrpcListener
Properties:
Cluster: !Ref EcsCluster
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref AquaFargateSecurityGroup
Subnets: !Ref EcsInstanceSubnets
ServiceName: !Join
- '-'
- - !Ref EcsCluster
- aqua-console
DesiredCount: '1'
DeploymentConfiguration:
MaximumPercent: '100'
MinimumHealthyPercent: '0'
LoadBalancers:
- ContainerName: !Join
- '-'
- - !Ref EcsCluster
- aqua-console
ContainerPort: '8080'
TargetGroupArn: !Ref AquaConsoleTargetGroup
- ContainerName: !Join
- '-'
- - !Ref EcsCluster
- aqua-console
ContainerPort: '8443'
TargetGroupArn: !Ref AquaConsoleGrpcTargetGroup
TaskDefinition: !Ref AquaConsoleTaskDefinition
AquaConsoleListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
DependsOn:
- AquaConsoleTargetGroup
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaConsoleTargetGroup
LoadBalancerArn: !Ref AquaConsole
Port: '8080'
Protocol: HTTP
AquaConsoleTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaConsole
Properties:
TargetType: ip
HealthCheckIntervalSeconds: 6
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
Matcher:
HttpCode: '200'
Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-console
Port: '8080'
Protocol: HTTP
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '60'
UnhealthyThresholdCount: 3
VpcId: !Ref VpcId
AquaEnvoyListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
DependsOn:
- AquaEnvoyTargetGroup
- AquaNlb
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaEnvoyTargetGroup
LoadBalancerArn: !Ref AquaNlb
Port: '443'
Protocol: TCP
AquaConsoleGrpcListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
DependsOn:
- AquaConsoleGrpcTargetGroup
- AquaNlb
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaConsoleGrpcTargetGroup
LoadBalancerArn: !Ref AquaNlb
Port: '8443'
Protocol: TCP
AquaEnvoyTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaNlb
Properties:
TargetType: ip
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: TCP
HealthyThresholdCount: 2
UnhealthyThresholdCount: 2
HealthCheckPort: 8443
Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-envoy
Port: '443'
Protocol: TCP
VpcId: !Ref VpcId
AquaConsoleGrpcTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaConsole
Properties:
TargetType: ip
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: TCP
HealthyThresholdCount: 2
HealthCheckPort: 8443
Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-grpc
Port: '8443'
Protocol: TCP
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '60'
UnhealthyThresholdCount: 2
VpcId: !Ref VpcId
AquaEnvoyTaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
DependsOn:
- AquaEcsTaskRole
- AquaEnvoyLogs
Properties:
Family: !Join
- '-'
- - !Ref EcsCluster
- aqua-envoy
NetworkMode: awsvpc
ExecutionRoleArn: !Ref AquaEcsTaskRole
RequiresCompatibilities:
- FARGATE
Cpu: '4096'
Memory: '8192'
TaskRoleArn: !Ref AquaEcsTaskRole
ContainerDefinitions:
- Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-envoy
Image: !Ref AquaEnvoyImage
PortMappings:
- ContainerPort: '8443'
HostPort: '8443'
Protocol: tcp
Essential: 'true'
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Join ['-', ['/aqua/envoy', !Ref EcsCluster]]
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: aquaEnvoy
Environment:
- Name: GATEWAY_ADDRESS
Value: !Join
- '-'
- - !Ref EcsCluster
- aqua-gateway.ecs.aqua
AquaGatewayTaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
DependsOn:
- AquaEcsTaskRole
- RdsInstance
- AquaGatewayLogs
- Secret0
- Secret1
Properties:
Family: !Join
- '-'
- - !Ref EcsCluster
- aqua-gateway
NetworkMode: awsvpc
ExecutionRoleArn: !Ref AquaEcsTaskRole
RequiresCompatibilities:
- FARGATE
Cpu: '4096'
Memory: '8192'
TaskRoleArn: !Ref AquaEcsTaskRole
ContainerDefinitions:
- Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-gateway
Image: !Ref AquaGatewayImage
PortMappings:
- ContainerPort: '8443'
HostPort: '8443'
Protocol: tcp
- ContainerPort: '8089'
HostPort: '8089'
Protocol: tcp
Essential: 'true'
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Join ['-', ['/aqua/gateway', !Ref EcsCluster]]
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: aquaGateway
Secrets:
- Name: SCALOCK_DBPASSWORD
ValueFrom: !Ref Secret0
- Name: SCALOCK_AUDIT_DBPASSWORD
ValueFrom: !Ref Secret1
Environment:
- Name: SCALOCK_DBSSL
Value: require
- Name: SCALOCK_AUDIT_DBSSL
Value: require
- Name: HEALTH_MONITOR
Value: '0.0.0.0:8089'
- Name: SCALOCK_DBUSER
Value: !Ref RdsMasterUsername
- Name: SCALOCK_DBNAME
Value: scalock
- Name: SCALOCK_DBHOST
Value: !GetAtt
- RdsInstance
- Endpoint.Address
- Name: SCALOCK_AUDIT_DBUSER
Value: !Ref AuditRdsMasterUsername
- Name: SCALOCK_AUDIT_DBNAME
Value: slk_audit
- Name: SCALOCK_AUDIT_DBHOST
Value: !GetAtt
- AuditRdsInstance
- Endpoint.Address
- Name: AQUA_CONSOLE_SECURE_ADDRESS
Value: !Join
- ''
- - !GetAtt
- AquaNlb
- DNSName
- ':8443'
PrivateNamespace:
Type: AWS::ServiceDiscovery::PrivateDnsNamespace
Properties:
Name: ecs.aqua
Vpc: !Ref VpcId
DiscoveryService:
DependsOn:
- PrivateNamespace
Type: AWS::ServiceDiscovery::Service
Properties:
Description: Discovery Service for the Demo Application
DnsConfig:
RoutingPolicy: MULTIVALUE
DnsRecords:
- TTL: 60
Type: A
- TTL: 60
Type: SRV
HealthCheckCustomConfig:
FailureThreshold: 1
Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-gateway
NamespaceId: !Ref PrivateNamespace
AquaGatewayService:
Type: 'AWS::ECS::Service'
DependsOn:
- AquaGatewayTaskDefinition
Properties:
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref AquaFargateSecurityGroup
Subnets: !Ref EcsInstanceSubnets
Cluster: !Ref EcsCluster
ServiceName: !Join
- '-'
- - !Ref EcsCluster
- aqua-gateway
DesiredCount: '2'
DeploymentConfiguration:
MaximumPercent: '200'
MinimumHealthyPercent: '100'
TaskDefinition: !Ref AquaGatewayTaskDefinition
ServiceRegistries:
- RegistryArn: !GetAtt DiscoveryService.Arn
Port: 8443
AquaEnvoyService:
Type: 'AWS::ECS::Service'
DependsOn:
- AquaEnvoyTaskDefinition
- AquaNlb
- AquaEnvoyTargetGroup
- AquaEnvoyListener
Properties:
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref AquaFargateSecurityGroup
Subnets: !Ref EcsInstanceSubnets
Cluster: !Ref EcsCluster
ServiceName: !Join
- '-'
- - !Ref EcsCluster
- aqua-envoy
DesiredCount: '2'
DeploymentConfiguration:
MaximumPercent: '200'
MinimumHealthyPercent: '100'
LoadBalancers:
- ContainerName: !Join
- '-'
- - !Ref EcsCluster
- aqua-envoy
ContainerPort: '8443'
TargetGroupArn: !Ref AquaEnvoyTargetGroup
TaskDefinition: !Ref AquaEnvoyTaskDefinition
AquaConsoleSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Allow access to Aqua Console Instances
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: !Ref AquaConsoleAccess
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: !Ref AquaConsoleAccess
- IpProtocol: tcp
FromPort: '8443'
ToPort: '8443'
CidrIp: !Ref AquaConsoleAccess
AquaFargateSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
DependsOn:
- AquaConsoleSecurityGroup
Properties:
GroupDescription: Allow lb access to fargate tasks
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '8443'
ToPort: '8443'
CidrIp: !Ref VpcCidr
- IpProtocol: tcp
FromPort: '8089'
ToPort: '8089'
CidrIp: !Ref VpcCidr
- IpProtocol: tcp
FromPort: '8443'
ToPort: '8443'
CidrIp: !Ref VpcCidr
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
SourceSecurityGroupId: !Ref AquaConsoleSecurityGroup
AquaEcsTaskRole:
Type: 'AWS::IAM::Role'
Properties:
RoleName: !Join
- '-'
- - !Ref EcsCluster
- AquaEcsTaskRole
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: !Join
- '-'
- - !Ref EcsCluster
- AquaScannerPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'ecr:GetDownloadUrlForLayer'
- 'ecr:BatchGetImage'
- 'ecr:DescribeImages'
- 'ecr:GetAuthorizationToken'
- 'ecr:DescribeRepositories'
- 'ecr:ListImages'
- 'ecr:BatchCheckLayerAvailability'
- 'ecr:GetRepositoryPolicy'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: '*'
- !Ref 'AWS::NoValue'
- PolicyName: !Join
- '-'
- - !Ref EcsCluster
- AquaSecretsManagerPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'secretsmanager:GetSecretValue'
Resource:
- !Ref Secret0
- !Ref Secret1
AquaConsoleLogs:
Type: 'AWS::Logs::LogGroup'
Properties:
LogGroupName: !Join ['-', ['/aqua/console', !Ref EcsCluster]]
RetentionInDays: 30
AquaGatewayLogs:
Type: 'AWS::Logs::LogGroup'
Properties:
LogGroupName: !Join ['-', ['/aqua/gateway', !Ref EcsCluster]]
RetentionInDays: 30
AquaEnvoyLogs:
Type: 'AWS::Logs::LogGroup'
Properties:
LogGroupName: !Join ['-', ['/aqua/envoy', !Ref EcsCluster]]
RetentionInDays: 30
AquaNlb:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
Properties:
Name: !Join
- '-'
- - !Ref EcsCluster
- aqua-nlb
Scheme: internet-facing
Subnets: !Ref LbSubnets
Type: network
LoadBalancerAttributes:
- Key: load_balancing.cross_zone.enabled
Value: true
AuditRdsInstance:
Type: 'AWS::RDS::DBInstance'
DependsOn:
- RdsSecurityGroup
- RdsInstanceSubnetGroup
- AquaEnvoyService
Properties:
AllocatedStorage: !Ref RdsStorage
AutoMinorVersionUpgrade: 'false'
VPCSecurityGroups:
- !Ref RdsSecurityGroup
DBName: !Ref AuditRdsInstanceName
BackupRetentionPeriod: '7'
DBInstanceIdentifier: !Join ['-', ['aquaAuditDb', !Ref EcsCluster]]
DBInstanceClass: !Ref AuditRdsInstanceClass
DBSubnetGroupName: !Ref RdsInstanceSubnetGroup
Engine: postgres
EngineVersion: 12.15
MasterUsername: !Ref AuditRdsMasterUsername
MasterUserPassword: !Ref AuditRdsMasterPassword
MultiAZ: !Ref AuditMultiAzDatabase
StorageType: gp2
RdsInstance:
Type: 'AWS::RDS::DBInstance'
DependsOn:
- RdsSecurityGroup
- RdsInstanceSubnetGroup
- AquaEnvoyService
Properties:
AllocatedStorage: !Ref RdsStorage
AutoMinorVersionUpgrade: 'false'
VPCSecurityGroups:
- !Ref RdsSecurityGroup
DBName: !Ref RdsInstanceName
BackupRetentionPeriod: '7'
DBInstanceIdentifier: !Join ['-', ['aquadb', !Ref EcsCluster]]
DBInstanceClass: !Ref RdsInstanceClass
DBSubnetGroupName: !Ref RdsInstanceSubnetGroup
Engine: postgres
EngineVersion: 12.15
MasterUsername: !Ref RdsMasterUsername
MasterUserPassword: !Ref RdsMasterPassword
MultiAZ: !Ref MultiAzDatabase
StorageType: gp2
RdsInstanceSubnetGroup:
Type: 'AWS::RDS::DBSubnetGroup'
Properties:
DBSubnetGroupDescription: Source subnet
SubnetIds: !Ref EcsInstanceSubnets
RdsSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Allow access to RDS Instances
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '5432'
ToPort: '5432'
SourceSecurityGroupId: !Ref AquaFargateSecurityGroup
Secret0:
Type: AWS::SecretsManager::Secret
Properties:
Description: Aqua RDS password
Name: !Join
- '/'
- - !Ref EcsCluster
- AquaRdsPassword
SecretString:
!Ref RdsMasterPassword
Secret1:
Type: AWS::SecretsManager::Secret
Properties:
Description: Aqua Audit RDS password
Name: !Join
- '/'
- - !Ref EcsCluster
- AuditAquaRdsPassword
SecretString:
!Ref AuditRdsMasterPassword
Outputs:
AquaConsole:
Description: URL to access Aqua Security Console
Value: !Join
- ''
- - 'http://'
- !GetAtt
- AquaConsole
- DNSName
- ':8080'
AquaConsoleGrpcConnection:
Description: >-
DNS to server gRPC
Value: !Join
- ''
- - !GetAtt
- AquaNlb
- DNSName
- ':8443'
AquaEnvoyExternalConnection:
Description: >-
Aqua Enforcer gateway startup connection string for use when Enforcers are
external to VPC.
Value: !Join
- ''
- - !GetAtt
- AquaNlb
- DNSName
- ':443'
AquaEcsTaskRole:
Description: IAM role assigned to access ECR
Value: !Ref AquaEcsTaskRole