forked from aquasecurity/deployments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaquaEcs-external.yaml
1296 lines (1295 loc) · 44.7 KB
/
aquaEcs-external.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: >-
This AWS CloudFormation template installs the Aqua Command Center components
in ECS EC2.
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: ECS Infrastructure Configuration
Parameters:
- ECSClusterName
- EcsSecurityGroupId
- VpcId
- VpcCidr
- LbSubnets
- SSLCert
- LBScheme
- Label:
default: Aqua Security Configuration
Parameters:
- AquaConsoleAccess
- AquaGatewayAccess
- AquaConsoleImage
- AquaGatewayImage
- AquaEnforcerImage
- BatchInstallToken
- ActiveActive
- Taskprivileged
- AquaLogLevel
- AquaPassword
- Label:
default: TLS Configuration
Parameters:
- TLSEnabled
- TLSRootCA
- AquaConsoleCrt
- AquaConsoleKey
- AquaGatewayCrt
- AquaGatewayKey
- AquaEnforcerCrt
- AquaEnforcerKey
- TlsVerify
- Label:
default: Aqua Manage DB Configuration
Parameters:
- AquaDBInstanceEndPointURL
- AquaDBUserName
- AquaDBPassword
- AuditRDS
- AuditDBInstanceEndPointURL
- AuditDBUserName
- AuditDBPassword
Parameters:
BatchInstallToken:
Type: String
Description: A unique string token used in the Aqua Enforcer Install command.
AquaConsoleImage:
Type: String
Description: >
The path of the Aqua Console container image in the ECR.
Specify the complete image URI, including the ECR repository, image name, and tag (e.g., your-ecr-repository/aqua-console:latest).
AquaGatewayImage:
Type: String
Description: >
The path of the Aqua Gateway container image in the ECR.
Specify the complete image URI, including the ECR repository, image name, and tag (e.g., your-ecr-repository/aqua-console:latest).
AquaEnforcerImage:
Type: String
Description: >
The path of the Aqua Enforcer container image in the ECR.
Specify the complete image URI, including the ECR repository, image name, and tag (e.g., your-ecr-repository/aqua-console:latest).
ECSClusterName:
Description: The name of an existing Amazon ECS cluster where you want to deploy the resources.
Type: String
MinLength: '5'
MaxLength: '25'
EcsSecurityGroupId:
Type: 'AWS::EC2::SecurityGroup::Id'
Description: >
The security group ID associated with the Amazon ECS cluster or ECS instances created during cluster formation.
This security group controls the inbound and outbound traffic for the ECS resources.
VpcId:
Description: >
The ID of the VPC where you want to deploy the resources.
Specify the VPC ID to associate the stack with a specific networking environment.
Type: 'AWS::EC2::VPC::Id'
VpcCidr:
Description: >
The CIDR block of the VPC.
This information is used by the load balancer service for polling purposes.
Enter the CIDR block in the format, for example, 10.0.0.0/16.
Type: String
LbSubnets:
Type: 'List<AWS::EC2::Subnet::Id>'
Description: >
Choose the external subnets where the load balancer will be deployed to enable internet access.
These subnets determine the availability zones for the load balancer.
LBScheme:
Type: String
Description: >
Choose the load balancer scheme to define its accessibility:
- Select "internet-facing" for external access.
- Choose "internal" for internal access within your VPC.
Default: internet-facing
AllowedValues:
- internet-facing
- internal
AquaConsoleAccess:
Description: >-
The default (0.0.0.0/0) CIDR range will provide global access for Aqua Console.
Please update your own IP address or CIDR range to restrict the Aqua Console access.
Default: 0.0.0.0/0
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
AquaGatewayAccess:
Description: >-
The Default (0.0.0.0/0) CIDR range will provide global access for Aqua Gateway.
Please update your own IP address or CIDR range to restrict the Aqua Gateway access.
Default: 0.0.0.0/0
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
AquaDBInstanceEndPointURL:
Description: >
Enter the Endpoint URL of the Aqua Database.
This URL is used to establish a connection with the Aqua Database instance.
Type: String
AquaDBUserName:
Description: >
Enter the username for authentication to the Aqua Database.
This username is required to access and interact with the Aqua Database.
Type: String
AquaDBPassword:
NoEcho: true
Description: Enter the password for authentication to the Aqua Database.
Type: String
AuditRDS:
Description: >
Select "Yes" if you have a separate Amazon RDS endpoint dedicated for audit purposes.
Choosing "No" indicates that the standard Amazon RDS endpoint will be used.
Default: 'No'
Type: String
AllowedValues: [ 'Yes', 'No' ]
AuditDBInstanceEndPointURL:
Description: >
Enter the Endpoint URL of the dedicated Audit Database.
This URL is used to establish a connection with the Audit Database instance.
Type: String
AuditDBUserName:
Description: >
Enter the username for authentication to the Audit Database.
This username is required to access and interact with the Audit Database.
Type: String
AuditDBPassword:
NoEcho: true
Description: Enter the password for authentication to the Audit Database.
Type: String
SSLCert:
Type: String
Description: The ARN of the SSL certificate to be used with the Aqua Console web user interface Load Balancer (LB).
ActiveActive:
Description: >
Enable or disable the Active-Active configuration for the Aqua Console.
Select "true" to activate Active-Active mode, distributing traffic across multiple instances.
Select "false" for standard mode with a single active instance.
Type: String
Default: 'false'
AllowedValues:
- 'true'
- 'false'
Taskprivileged:
Description: >
Choose "true" to run the Aqua Enforcer in privileged mode, allowing elevated privileges.
Choose "false" to run the Aqua Enforcer in non-privileged mode with reduced privileges.
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
TLSEnabled:
Description: >-
Enable mTLS/TLS establishment between Aqua Console <-> Aqua Gateway and https for
Aqua Console
Type: String
Default: 'false'
AllowedValues:
- 'true'
- 'false'
TLSRootCA:
Description: The ARN of the root certificate stored in AWS Secrets Manager.
Type: String
AquaConsoleCrt:
Description: The ARN of the Aqua Console certificate stored in AWS Secrets Manager.
Type: String
AquaConsoleKey:
Description: The ARN of the Aqua Console certificate key stored in AWS Secrets Manager.
Type: String
AquaGatewayCrt:
Description: The ARN of the Aqua Gateway certificate stored in AWS Secrets Manager.
Type: String
AquaGatewayKey:
Description: The ARN of the Aqua Gateway certificate key stored in AWS Secrets Manager.
Type: String
AquaEnforcerCrt:
Description: The ARN of the Aqua Enforcer certificate stored in AWS Secrets Manager.
Type: String
AquaEnforcerKey:
Description: The ARN of the Aqua Enforcer certificate key stored in AWS Secrets Manager.
Type: String
TlsVerify:
Description: Enable mTLS/TLS between Aqua Enforcer and Aqua Gateway
Type: String
Default: 'false'
AllowedValues:
- 'true'
- 'false'
AquaLogLevel:
Description: Aqua log level, by default set to INFO
Type: String
Default: "INFO"
AllowedValues:
- "WARN"
- "DEBUG"
- "INFO"
- "ERROR"
AquaPassword:
Type: String
Description: Use this Aqua admin password
NoEcho: true
Conditions:
CreateActiveActive: !Equals [ !Ref ActiveActive, 'true' ]
CreateAuditrds: !Equals [ !Ref AuditRDS, 'Yes' ]
TLSEnable: !Equals
- !Ref TLSEnabled
- 'true'
AquaTlsVerify: !Equals
- !Ref TlsVerify
- 'true'
Resources:
LambdaExecutionRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Policies:
- PolicyName: allowLambdaLogging
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'logs:*'
Resource: '*'
RandomStringLambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
Handler: index.lambda_handler
Timeout: 10
Role: !GetAtt LambdaExecutionRole.Arn
Runtime: python3.9
Code:
ZipFile: |
import cfnresponse
from random import choice
from string import ascii_lowercase, digits
def random_string(length=8, chars=ascii_lowercase + digits):
return "".join(choice(chars) for x in range(length))
def lambda_handler(event, context):
print(f"Data in event: {event}")
response_data = {}
if event["RequestType"] == "Create":
string_length = int(event["ResourceProperties"]["Length"])
physicalResourceId = random_string(string_length)
response_data = { "RandomString": physicalResourceId }
else: # if event["RequestType"] == "Update" or event["RequestType"] == "Delete":
physicalResourceId = event["PhysicalResourceId"]
cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, physicalResourceId)
RandomString:
Type: 'AWS::CloudFormation::CustomResource'
Properties:
Length: 5
ServiceToken: !GetAtt RandomStringLambdaFunction.Arn
AquaConsoleLB:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
DependsOn:
- EcsSecurityGroupIngress1
- EcsSecurityGroupIngress2
- EcsSecurityGroupIngress3
Properties:
Name: !Sub 'AquaConsoleLB-${RandomString}'
Scheme: !Ref LBScheme
SecurityGroups:
- !Ref AquaConsoleSecurityGroup
Subnets: !Ref LbSubnets
Type: application
AquaConsoleTaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
Properties:
Family: !Sub 'aqua-console-td-${RandomString}'
RequiresCompatibilities:
- EC2
Volumes:
- Host:
SourcePath: /var/run/docker.sock
Name: docker-socket
- !If
- TLSEnable
- Name: secret-vol
DockerVolumeConfiguration:
Scope: task
Driver: local
- !Ref 'AWS::NoValue'
ContainerDefinitions:
- Name: !Sub 'aqua-console-td-${RandomString}'
Image: !Ref AquaConsoleImage
Cpu: '1024'
Ulimits:
- Name: nofile
SoftLimit: '1048576'
HardLimit: '1048576'
MountPoints:
- ContainerPath: /var/run/docker.sock
SourceVolume: docker-socket
- !If
- TLSEnable
- ContainerPath: /opt/aquasec/ssl
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
PortMappings:
- ContainerPort: '8080'
HostPort: '8080'
Protocol: tcp
- ContainerPort: '8443'
HostPort: '8442'
Protocol: tcp
Memory: '2048'
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaConsoleLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: aquaConsole
Essential: true
Secrets:
- Name: SCALOCK_DBPASSWORD
ValueFrom: !Ref SecretRDSPassword
- Name: SCALOCK_AUDIT_DBPASSWORD
ValueFrom: !If [ CreateAuditrds, !Ref SecretAuditPassword, !Ref SecretRDSPassword ]
- Name: SCALOCK_DBUSER
ValueFrom: !Ref SecretRDSUsername
- Name: SCALOCK_AUDIT_DBUSER
ValueFrom: !If [ CreateAuditrds, !Ref SecretAuditUsername, !Ref SecretRDSUsername ]
- Name: BATCH_INSTALL_TOKEN
ValueFrom: !Ref SecretBatchToken
- Name: AQUA_PUBSUB_DBPASSWORD
ValueFrom: !Ref SecretRDSPassword
- Name: AQUA_PUBSUB_DBUSER
ValueFrom: !Ref SecretRDSUsername
- Name: ADMIN_PASSWORD
ValueFrom: !Ref SecretAquaPassword
Environment:
- Name: SCALOCK_LOG_LEVEL
Value: !Ref AquaLogLevel
- Name: AQUA_GRPC_MODE
Value: 1
- Name: SCALOCK_DBSSL
Value: require
- Name: SCALOCK_AUDIT_DBSSL
Value: require
- Name: SCALOCK_DBNAME
Value: scalock
- Name: SCALOCK_DBHOST
Value: !Ref AquaDBInstanceEndPointURL
- Name: SCALOCK_AUDIT_DBNAME
Value: slk_audit
- Name: SCALOCK_AUDIT_DBHOST
Value: !If [ CreateAuditrds, !Ref AuditDBInstanceEndPointURL, !Ref AquaDBInstanceEndPointURL ]
- Name: AQUA_PUBSUB_DBSSL
Value: !If [ CreateActiveActive, require, !Ref "AWS::NoValue" ]
- Name: AQUA_PUBSUB_DBNAME
Value: !If [ CreateActiveActive, pubsub, !Ref "AWS::NoValue" ]
- Name: AQUA_PUBSUB_DBHOST
Value: !If [ CreateActiveActive, !Ref AquaDBInstanceEndPointURL, !Ref "AWS::NoValue" ]
- Name: AQUA_CLUSTER_MODE
Value: !If [ CreateActiveActive, active-active, !Ref "AWS::NoValue" ]
- Name: AQUA_PRIVATE_KEY
Value: !If [ TLSEnable, /opt/aquasec/ssl/key.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_PUBLIC_KEY
Value: !If [ TLSEnable, /opt/aquasec/ssl/cert.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_ROOT_CA
Value: !If [ TLSEnable, /opt/aquasec/ssl/root_ca.pem, !Ref "AWS::NoValue" ]
- !If
- TLSEnable
- Name: secret-sidecar-root-ca
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaConsoleLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-root-ca
Environment:
- Name: SECRET_ARN
Value: !Ref TLSRootCA
- Name: SECRET_FILENAME
Value: root_ca.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
- !If
- TLSEnable
- Name: secret-sidecar-console-crt
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaConsoleLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-console-crt
Environment:
- Name: SECRET_ARN
Value: !Ref AquaConsoleCrt
- Name: SECRET_FILENAME
Value: cert.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
- !If
- TLSEnable
- Name: secret-sidecar-console-key
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaConsoleLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-console-key
Environment:
- Name: SECRET_ARN
Value: !Ref AquaConsoleKey
- Name: SECRET_FILENAME
Value: key.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
NetworkMode: bridge
TaskRoleArn: !GetAtt AquaEcsTaskRole.Arn
ExecutionRoleArn: !GetAtt AquaEcsTaskRole.Arn
AquaConsoleService:
Type: 'AWS::ECS::Service'
DependsOn:
- AquaConsoleListener
- AquaConsoleGrpcListener
Properties:
Cluster: !Ref ECSClusterName
LaunchType: EC2
ServiceName: !Sub 'aqua-console-td-${RandomString}'
DesiredCount: '1'
PlacementStrategies:
- Type: spread
Field: 'attribute:ecs.availability-zone'
- Type: spread
Field: instanceId
DeploymentConfiguration:
MaximumPercent: '200'
MinimumHealthyPercent: '50'
LoadBalancers:
- ContainerName: !Sub 'aqua-console-td-${RandomString}'
ContainerPort: '8080'
TargetGroupArn: !Ref AquaConsoleHealthTargetGroup
- ContainerName: !Sub 'aqua-console-td-${RandomString}'
ContainerPort: '8443'
TargetGroupArn: !Ref AquaConsoleGrpcTargetGroup
TaskDefinition: !Ref AquaConsoleTaskDefinition
AquaConsoleListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaConsoleHealthTargetGroup
LoadBalancerArn: !Ref AquaConsoleLB
Port: '443'
Protocol: HTTPS
Certificates:
- CertificateArn: !Ref SSLCert
SslPolicy: ELBSecurityPolicy-FS-1-2-Res-2019-08
AquaConsoleGrpcListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaConsoleGrpcTargetGroup
LoadBalancerArn: !Ref AquaConsoleLB
Port: '8442'
Protocol: HTTPS
Certificates:
- CertificateArn: !Ref SSLCert
SslPolicy: ELBSecurityPolicy-FS-1-2-Res-2019-08
AquaConsoleHealthTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaConsoleLB
Properties:
TargetType: instance
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 20
HealthyThresholdCount: 3
Matcher:
HttpCode: '200'
Name: !Sub 'aqua-console-health-tg-${RandomString}'
Port: '8080'
Protocol: HTTP
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '60'
UnhealthyThresholdCount: 3
VpcId: !Ref VpcId
AquaConsoleGrpcTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaConsoleLB
Properties:
TargetType: instance
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: HTTPS
HealthyThresholdCount: 2
HealthCheckPath: "/"
Matcher:
GrpcCode: '0-99'
Name: !Sub 'aqua-console-grpc-tg-${RandomString}'
Port: '8442'
Protocol: HTTPS
ProtocolVersion: GRPC
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '60'
UnhealthyThresholdCount: 2
VpcId: !Ref VpcId
AquaGatewayGrpcListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
DependsOn:
- AquaConsoleGrpcTargetGroup
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaGatewayGrpcTargetGroup
LoadBalancerArn: !Ref AquaGatewayLB
Port: '8443'
Protocol: TCP
AquaGatewayGrpcTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaGatewayLB
Properties:
TargetType: instance
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: TCP
HealthyThresholdCount: 2
UnhealthyThresholdCount: 2
Name: !Sub 'aqua-gateway-grpc-tg-${RandomString}'
Port: '8443'
Protocol: TCP
VpcId: !Ref VpcId
AquaGatewayHealthListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
DependsOn:
- AquaGatewayGrpcTargetGroup
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AquaGatewayHealthTargetGroup
LoadBalancerArn: !Ref AquaGatewayLB
Port: '8089'
Protocol: TCP
AquaGatewayHealthTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
DependsOn:
- AquaGatewayLB
Properties:
TargetType: instance
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 10
HealthyThresholdCount: 2
Matcher:
HttpCode: '200'
Name: !Sub 'aqua-gateway-health-tg-${RandomString}'
Port: '8089'
Protocol: TCP
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '60'
UnhealthyThresholdCount: 3
VpcId: !Ref VpcId
AquaGatewayLB:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
DependsOn:
- EcsSecurityGroupIngress4
- EcsSecurityGroupIngress5
Properties:
Name: !Sub 'AquaGatewayLB-${RandomString}'
Scheme: !Ref LBScheme
SecurityGroups:
- !Ref AquaGatewaySecurityGroup
Subnets: !Ref LbSubnets
Type: network
AquaGatewayTaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
Properties:
Family: !Sub 'aqua-gateway-td-${RandomString}'
TaskRoleArn: !GetAtt AquaEcsTaskRole.Arn
ExecutionRoleArn: !GetAtt AquaEcsTaskRole.Arn
RequiresCompatibilities:
- EC2
Volumes:
- !If
- TLSEnable
- Name: secret-vol
DockerVolumeConfiguration:
Scope: task
Driver: local
- !Ref 'AWS::NoValue'
ContainerDefinitions:
- Name: !Sub 'aqua-gateway-td-${RandomString}'
Image: !Ref AquaGatewayImage
Ulimits:
- Name: nofile
SoftLimit: '1048576'
HardLimit: '1048576'
MountPoints:
- !If
- TLSEnable
- ContainerPath: /opt/aquasec/ssl
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
PortMappings:
- ContainerPort: '8443'
HostPort: '8443'
Protocol: tcp
- ContainerPort: '8089'
HostPort: '8089'
Protocol: tcp
Cpu: '1024'
Memory: '2048'
Essential: true
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaGatewayLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: aquaGateway
Secrets:
- Name: SCALOCK_DBPASSWORD
ValueFrom: !Ref SecretRDSPassword
- Name: SCALOCK_AUDIT_DBPASSWORD
ValueFrom: !If [ CreateAuditrds, !Ref SecretAuditPassword, !Ref SecretRDSPassword ]
- Name: SCALOCK_DBUSER
ValueFrom: !Ref SecretRDSUsername
- Name: SCALOCK_AUDIT_DBUSER
ValueFrom: !If [ CreateAuditrds, !Ref SecretAuditUsername, !Ref SecretRDSUsername ]
Environment:
- Name: SCALOCK_LOG_LEVEL
Value: !Ref AquaLogLevel
- Name: SCALOCK_DBSSL
Value: require
- Name: SCALOCK_AUDIT_DBSSL
Value: require
- Name: HEALTH_MONITOR
Value: '0.0.0.0:8089'
- Name: SCALOCK_DBNAME
Value: scalock
- Name: SCALOCK_DBHOST
Value: !Ref AquaDBInstanceEndPointURL
- Name: SCALOCK_AUDIT_DBNAME
Value: slk_audit
- Name: SCALOCK_AUDIT_DBHOST
Value: !If [ CreateAuditrds, !Ref AuditDBInstanceEndPointURL, !Ref AquaDBInstanceEndPointURL ]
- Name: AQUA_CONSOLE_SECURE_ADDRESS
Value: !Sub "${AquaConsoleLB.DNSName}:8442"
- Name: AQUA_PRIVATE_KEY
Value: !If [ TLSEnable, /opt/aquasec/ssl/key.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_PUBLIC_KEY
Value: !If [ TLSEnable, /opt/aquasec/ssl/cert.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_ROOT_CA
Value: !If [ TLSEnable, /opt/aquasec/ssl/root_ca.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_VERIFY_ENFORCER
Value: !If
- AquaTlsVerify
- "1"
- "0"
- !If
- TLSEnable
- Name: secret-sidecar-root-ca
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaGatewayLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-root-ca
Environment:
- Name: SECRET_ARN
Value: !Ref TLSRootCA
- Name: SECRET_FILENAME
Value: root_ca.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
- !If
- TLSEnable
- Name: secret-sidecar-gateway-crt
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaGatewayLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-gateway-crt
Environment:
- Name: SECRET_ARN
Value: !Ref AquaGatewayCrt
- Name: SECRET_FILENAME
Value: cert.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
- !If
- TLSEnable
- Name: secret-sidecar-gateway-key
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaGatewayLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-gateway-key
Environment:
- Name: SECRET_ARN
Value: !Ref AquaGatewayKey
- Name: SECRET_FILENAME
Value: key.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
NetworkMode: bridge
AquaGatewayService:
Type: 'AWS::ECS::Service'
DependsOn:
- AquaGatewayLB
- AquaGatewayHealthListener
- AquaGatewayGrpcListener
- EcsSecurityGroupIngress4
Properties:
Cluster: !Ref ECSClusterName
ServiceName: !Sub 'aqua-gateway-td-${RandomString}'
DesiredCount: '1'
PlacementStrategies:
- Type: spread
Field: 'attribute:ecs.availability-zone'
- Type: spread
Field: instanceId
DeploymentConfiguration:
MaximumPercent: '200'
MinimumHealthyPercent: '50'
LoadBalancers:
- ContainerName: !Sub 'aqua-gateway-td-${RandomString}'
ContainerPort: '8443'
TargetGroupArn: !Ref AquaGatewayGrpcTargetGroup
- ContainerName: !Sub 'aqua-gateway-td-${RandomString}'
ContainerPort: '8089'
TargetGroupArn: !Ref AquaGatewayHealthTargetGroup
TaskDefinition: !Ref AquaGatewayTaskDefinition
AquaEnforcerTaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
DependsOn:
- AquaGatewayService
Properties:
PidMode: 'host'
ContainerDefinitions:
- Memory: '2048'
Essential: true
MountPoints:
- ContainerPath: /var/run
SourceVolume: var-run
- ContainerPath: /dev
SourceVolume: dev
- ContainerPath: /host/opt/aquasec
SourceVolume: aquasec
ReadOnly: true
- ContainerPath: /opt/aquasec/tmp
SourceVolume: aquasec-tmp
- ContainerPath: /opt/aquasec/audit
SourceVolume: aquasec-audit
- ContainerPath: /data
SourceVolume: data
- ContainerPath: /host/proc
SourceVolume: proc
ReadOnly: true
- ContainerPath: /host/sys
SourceVolume: sys
ReadOnly: true
- ContainerPath: /host/etc
SourceVolume: etc
ReadOnly: true
- !If
- TLSEnable
- ContainerPath: /opt/aquasec/ssl
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
Name: aqua-enforcer
Privileged: !Ref Taskprivileged
LinuxParameters:
Capabilities:
Add:
- SYS_ADMIN
- NET_ADMIN
- NET_RAW
- SYS_PTRACE
- KILL
- MKNOD
- SETGID
- SETUID
- SYS_MODULE
- AUDIT_CONTROL
- SYSLOG
- SYS_CHROOT
- SYS_RESOURCE
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaEnforcerLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: aquaEnforcer
Secrets:
- Name: AQUA_TOKEN
ValueFrom: !Ref SecretBatchToken
Environment:
- Name: SCALOCK_LOG_LEVEL
Value: !Ref AquaLogLevel
- Name: AQUA_SERVER
Value: !Sub '${AquaGatewayLB.DNSName}:8443'
- Name: SILENT
Value: 'yes'
- Name: RESTART_CONTAINERS
Value: 'no'
- Name: AQUA_LOGICAL_NAME
Value: !Sub 'aqua-enf-td-${RandomString}-ECS'
- Name: AQUA_PRIVATE_KEY
Value: !If [ TLSEnable, /opt/aquasec/ssl/key.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_PUBLIC_KEY
Value: !If [ TLSEnable, /opt/aquasec/ssl/cert.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_ROOT_CA
Value: !If [ TLSEnable, /opt/aquasec/ssl/root_ca.pem, !Ref "AWS::NoValue" ]
- Name: AQUA_TLS_VERIFY
Value: !Ref TlsVerify
Image: !Ref AquaEnforcerImage
Cpu: '512'
- !If
- TLSEnable
- Name: secret-sidecar-root-ca
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaEnforcerLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-root-ca
Environment:
- Name: SECRET_ARN
Value: !Ref TLSRootCA
- Name: SECRET_FILENAME
Value: root_ca.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
- !If
- TLSEnable
- Name: secret-sidecar-enforcer-crt
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaEnforcerLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-enforcer-crt
Environment:
- Name: SECRET_ARN
Value: !Ref AquaEnforcerCrt
- Name: SECRET_FILENAME
Value: cert.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
- !If
- TLSEnable
- Name: secret-sidecar-enforcer-key
Image: public.ecr.aws/aws-containers/aws-secrets-manager-secret-sidecar:v0.1.4
Cpu: '0'
Memory: '128'
Essential: false
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref AquaEnforcerLogGroup
awslogs-region: !Ref "AWS::Region"
awslogs-stream-prefix: secret-sidecar-enforcer-key
Environment:
- Name: SECRET_ARN
Value: !Ref AquaEnforcerKey
- Name: SECRET_FILENAME
Value: key.pem
MountPoints:
- ContainerPath: /tmp
SourceVolume: secret-vol
- !Ref 'AWS::NoValue'
Volumes:
- Host:
SourcePath: /var/run
Name: var-run
- Host:
SourcePath: /dev
Name: dev
- Host:
SourcePath: /opt/aquasec/data
Name: data
- Host:
SourcePath: /opt/aquasec
Name: aquasec
- Host:
SourcePath: /opt/aquasec/tmp
Name: aquasec-tmp
- Host:
SourcePath: /opt/aquasec/audit
Name: aquasec-audit
- Host:
SourcePath: /proc
Name: proc
- Host:
SourcePath: /sys
Name: sys
- Host:
SourcePath: /etc
Name: etc
- !If
- TLSEnable
- Name: secret-vol
DockerVolumeConfiguration:
Scope: task
Driver: local
- !Ref 'AWS::NoValue'
Family: !Sub 'aqua-enforcer-td-${RandomString}'
TaskRoleArn: !GetAtt AquaEcsTaskRole.Arn
ExecutionRoleArn: !GetAtt AquaEcsTaskRole.Arn
AquaEnforcerDaemon: