Skip to content

Commit 8657afe

Browse files
Merge pull request #14 from LerianStudio/fix/documentdb-enable-tls-parameter
fix(security): resolve all 17 Checkov security scan failures
2 parents 1baf402 + 30783a3 commit 8657afe

7 files changed

Lines changed: 117 additions & 3 deletions

File tree

products/midaz/helm.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ Resources:
200200
# NOTE: Lambda runs outside VPC to access CloudFormation response URL
201201
# It connects to EKS via public endpoint (EndpointPublicAccess: true)
202202
HelmDeployerFunction:
203+
# checkov:skip=CKV_AWS_116:Deployer Lambda is one-shot during stack creation, DLQ not applicable
204+
# checkov:skip=CKV_AWS_117:Deployer Lambda requires internet access for Helm chart deployment to EKS
205+
# checkov:skip=CKV_AWS_173:Environment variables contain non-sensitive configuration references (endpoints, ARNs, chart version)
203206
Type: AWS::Lambda::Function
204207
Properties:
205208
FunctionName: !Sub "${ProjectName}-helm-deployer"
@@ -208,6 +211,7 @@ Resources:
208211
Handler: index.handler
209212
Timeout: 900
210213
MemorySize: 1024
214+
ReservedConcurrentExecutions: 1
211215
Role: !GetAtt HelmDeployerRole.Arn
212216
# No VpcConfig - Lambda runs outside VPC to access internet
213217
# EKS is accessed via public endpoint

templates/alb-controller.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Resources:
4444
# ALB CONTROLLER IAM ROLE (IRSA)
4545
# =============================================================================
4646
ALBControllerRole:
47+
# checkov:skip=CKV_AWS_111:ALB Controller requires broad write permissions to manage ELBv2 resources across the account as per AWS documentation
4748
Type: AWS::IAM::Role
4849
Properties:
4950
RoleName: !Sub "${ProjectName}-alb-controller-role"
@@ -323,6 +324,9 @@ Resources:
323324
# LAMBDA FUNCTION FOR ALB CONTROLLER DEPLOYMENT
324325
# =============================================================================
325326
ALBControllerDeployerFunction:
327+
# checkov:skip=CKV_AWS_116:Deployer Lambda is one-shot during stack creation, DLQ not applicable
328+
# checkov:skip=CKV_AWS_117:Deployer Lambda requires internet access for Helm chart deployment to EKS
329+
# checkov:skip=CKV_AWS_173:Environment variables contain only non-sensitive configuration (cluster name, VPC ID, region, chart version)
326330
Type: AWS::Lambda::Function
327331
Properties:
328332
FunctionName: !Sub "${ProjectName}-alb-controller-deployer"
@@ -331,6 +335,7 @@ Resources:
331335
Handler: index.handler
332336
Timeout: 900
333337
MemorySize: 1024
338+
ReservedConcurrentExecutions: 1
334339
Role: !GetAtt ALBControllerDeployerRole.Arn
335340
Environment:
336341
Variables:

templates/amazonmq.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,49 @@ Conditions:
101101
- !Not [!Equals [!Ref AdditionalIngressCIDR3, !Ref AdditionalIngressCIDR2]]
102102

103103
Resources:
104+
# =============================================================================
105+
# KMS KEY
106+
# =============================================================================
107+
AmazonMQKMSKey:
108+
Type: AWS::KMS::Key
109+
Properties:
110+
Description: KMS key for AmazonMQ encryption
111+
EnableKeyRotation: true
112+
KeyPolicy:
113+
Version: '2012-10-17'
114+
Statement:
115+
- Sid: Enable IAM User Permissions
116+
Effect: Allow
117+
Principal:
118+
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
119+
Action: kms:*
120+
Resource: '*'
121+
- Sid: Allow CloudWatch Logs
122+
Effect: Allow
123+
Principal:
124+
Service: !Sub "logs.${AWS::Region}.amazonaws.com"
125+
Action:
126+
- kms:Encrypt
127+
- kms:Decrypt
128+
- kms:ReEncrypt*
129+
- kms:GenerateDataKey*
130+
- kms:DescribeKey
131+
Resource: '*'
132+
Condition:
133+
ArnLike:
134+
kms:EncryptionContext:aws:logs:arn: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/amazonmq/${ProjectName}"
135+
Tags:
136+
- Key: Name
137+
Value: !Sub "${ProjectName}-amazonmq-kms"
138+
- Key: Environment
139+
Value: !Ref EnvironmentName
140+
141+
AmazonMQKMSKeyAlias:
142+
Type: AWS::KMS::Alias
143+
Properties:
144+
AliasName: !Sub "alias/${ProjectName}-amazonmq"
145+
TargetKeyId: !Ref AmazonMQKMSKey
146+
104147
# =============================================================================
105148
# SECRETS
106149
# =============================================================================
@@ -109,6 +152,7 @@ Resources:
109152
Properties:
110153
Name: !Sub "${ProjectName}/amazonmq-password"
111154
Description: AmazonMQ Admin Password
155+
KmsKeyId: !GetAtt AmazonMQKMSKey.Arn
112156
GenerateSecretString:
113157
SecretStringTemplate: !Sub '{"username": "${AdminUsername}"}'
114158
GenerateStringKey: password
@@ -261,6 +305,7 @@ Resources:
261305
Properties:
262306
LogGroupName: !Sub "/aws/amazonmq/${ProjectName}"
263307
RetentionInDays: 30
308+
KmsKeyId: !GetAtt AmazonMQKMSKey.Arn
264309

265310
# =============================================================================
266311
# AMAZONMQ BROKER

templates/documentdb.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Resources:
112112
Properties:
113113
Name: !Sub "${ProjectName}/documentdb-password"
114114
Description: DocumentDB Master Password
115+
KmsKeyId: !GetAtt DocumentDBKMSKey.Arn
115116
GenerateSecretString:
116117
SecretStringTemplate: !Sub '{"username": "${MasterUsername}"}'
117118
GenerateStringKey: password
@@ -235,6 +236,7 @@ Resources:
235236
Description: Parameter group for Midaz DocumentDB
236237
Parameters:
237238
tls: !Ref EnableTLS
239+
audit_logs: "enabled"
238240
Tags:
239241
- Key: Name
240242
Value: !Sub "${ProjectName}-documentdb-params"

templates/elasticache.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,54 @@ Conditions:
7878
- !Not [!Equals [!Ref AdditionalIngressCIDR3, !Ref AdditionalIngressCIDR2]]
7979

8080
Resources:
81+
# =============================================================================
82+
# KMS KEY
83+
# =============================================================================
84+
ElastiCacheKMSKey:
85+
Type: AWS::KMS::Key
86+
Properties:
87+
Description: KMS key for ElastiCache secrets encryption
88+
EnableKeyRotation: true
89+
KeyPolicy:
90+
Version: '2012-10-17'
91+
Statement:
92+
- Sid: Enable IAM User Permissions
93+
Effect: Allow
94+
Principal:
95+
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
96+
Action: kms:*
97+
Resource: '*'
98+
Tags:
99+
- Key: Name
100+
Value: !Sub "${ProjectName}-elasticache-kms"
101+
- Key: Environment
102+
Value: !Ref EnvironmentName
103+
104+
ElastiCacheKMSKeyAlias:
105+
Type: AWS::KMS::Alias
106+
Properties:
107+
AliasName: !Sub "alias/${ProjectName}-elasticache"
108+
TargetKeyId: !Ref ElastiCacheKMSKey
109+
110+
# =============================================================================
111+
# SECRETS
112+
# =============================================================================
113+
ElastiCacheAuthSecret:
114+
Type: AWS::SecretsManager::Secret
115+
Properties:
116+
Name: !Sub "${ProjectName}/elasticache-auth-token"
117+
Description: ElastiCache Auth Token for transit encryption
118+
KmsKeyId: !GetAtt ElastiCacheKMSKey.Arn
119+
GenerateSecretString:
120+
PasswordLength: 64
121+
ExcludeCharacters: '"@/\!'
122+
ExcludePunctuation: false
123+
Tags:
124+
- Key: Name
125+
Value: !Sub "${ProjectName}-elasticache-auth-secret"
126+
- Key: Environment
127+
Value: !Ref EnvironmentName
128+
81129
# =============================================================================
82130
# SECURITY GROUP
83131
# =============================================================================
@@ -185,7 +233,8 @@ Resources:
185233
AutomaticFailoverEnabled: true
186234
MultiAZEnabled: true
187235
TransitEncryptionEnabled: true
188-
TransitEncryptionMode: preferred
236+
TransitEncryptionMode: required
237+
AuthToken: !Sub "{{resolve:secretsmanager:${ElastiCacheAuthSecret}:SecretString}}"
189238
AtRestEncryptionEnabled: true
190239
AutoMinorVersionUpgrade: true
191240
PreferredMaintenanceWindow: "mon:00:00-mon:03:00"
@@ -212,6 +261,10 @@ Outputs:
212261
Description: ElastiCache Reader Endpoint
213262
Value: !GetAtt ElastiCacheReplicationGroup.ReaderEndPoint.Address
214263

264+
AuthSecretArn:
265+
Description: ElastiCache Auth Token Secret ARN
266+
Value: !Ref ElastiCacheAuthSecret
267+
215268
SecurityGroupId:
216269
Description: ElastiCache Security Group ID
217270
Value: !Ref ElastiCacheSecurityGroup

templates/external-dns.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ Resources:
156156
# LAMBDA FUNCTION FOR EXTERNAL DNS DEPLOYMENT
157157
# =============================================================================
158158
ExternalDNSDeployerFunction:
159+
# checkov:skip=CKV_AWS_116:Deployer Lambda is one-shot during stack creation, DLQ not applicable
160+
# checkov:skip=CKV_AWS_117:Deployer Lambda requires internet access for Helm chart deployment to EKS
161+
# checkov:skip=CKV_AWS_173:Environment variables contain only non-sensitive configuration (cluster name, region, chart version, hosted zone ID)
159162
Type: AWS::Lambda::Function
160163
Properties:
161164
FunctionName: !Sub "${ProjectName}-external-dns-deployer"
@@ -164,6 +167,7 @@ Resources:
164167
Handler: index.handler
165168
Timeout: 900
166169
MemorySize: 1024
170+
ReservedConcurrentExecutions: 1
167171
Role: !GetAtt ExternalDNSDeployerRole.Arn
168172
Environment:
169173
Variables:

templates/rds.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ Parameters:
109109
AllowedValues:
110110
- "0"
111111
- "1"
112-
Default: "0"
112+
Default: "1"
113113
Description: Force SSL/TLS connections to RDS (1 = enabled, 0 = disabled). Recommended for production with sensitive data.
114114

115115
MultiAZ:
116116
Type: String
117117
AllowedValues:
118118
- "true"
119119
- "false"
120-
Default: "false"
120+
Default: "true"
121121
Description: Enable Multi-AZ deployment for high availability. Recommended for production workloads.
122122

123123
DeletionProtection:
@@ -183,6 +183,7 @@ Resources:
183183
Properties:
184184
Name: !Sub "${ProjectName}/rds-master-password"
185185
Description: RDS Master Password
186+
KmsKeyId: !GetAtt RDSKMSKey.Arn
186187
GenerateSecretString:
187188
SecretStringTemplate: !Sub '{"username": "${MasterUsername}"}'
188189
GenerateStringKey: password

0 commit comments

Comments
 (0)