@aws/nx-plugin 0.1.6 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE-THIRD-PARTY +1554 -3241
  2. package/generators.json +1 -13
  3. package/package.json +14 -14
  4. package/src/cloudscape-website/app/README.md +84 -48
  5. package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +168 -233
  6. package/src/cloudscape-website/app/files/app/README.md.template +44 -0
  7. package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +40 -43
  8. package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +3 -3
  9. package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +4 -6
  10. package/src/cloudscape-website/app/files/app/src/main.tsx.template +7 -10
  11. package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -2
  12. package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +13 -0
  13. package/src/cloudscape-website/app/files/common/constructs/src/{__websiteNameKebabCase__ → core}/static-website.ts.template +79 -144
  14. package/src/cloudscape-website/app/generator.js +90 -74
  15. package/src/cloudscape-website/app/generator.js.map +1 -1
  16. package/src/cloudscape-website/app/schema.d.ts +3 -5
  17. package/src/cloudscape-website/app/schema.json +1 -24
  18. package/src/cloudscape-website/cognito-auth/README.md +53 -32
  19. package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +162 -124
  20. package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +53 -39
  21. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +168 -0
  22. package/src/cloudscape-website/cognito-auth/generator.js +130 -47
  23. package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
  24. package/src/cloudscape-website/cognito-auth/schema.d.ts +1 -0
  25. package/src/cloudscape-website/cognito-auth/schema.json +7 -1
  26. package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +20 -15
  27. package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +7 -10
  28. package/src/cloudscape-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +13 -0
  29. package/src/cloudscape-website/runtime-config/generator.js +4 -2
  30. package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
  31. package/src/infra/app/README.md +71 -46
  32. package/src/infra/app/__snapshots__/generator.spec.ts.snap +184 -305
  33. package/src/infra/app/files/app/README.md.template +76 -0
  34. package/src/infra/app/files/app/src/main.ts.template +18 -0
  35. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +1282 -0
  36. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +6839 -0
  37. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +2807 -0
  38. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +2585 -0
  39. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +2236 -0
  40. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +885 -0
  41. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +2205 -0
  42. package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +63 -0
  43. package/src/infra/app/generator.js +36 -7
  44. package/src/infra/app/generator.js.map +1 -1
  45. package/src/infra/app/schema.d.ts +10 -1
  46. package/src/infra/app/schema.json +16 -8
  47. package/src/trpc/backend/README.md +102 -80
  48. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +42 -19
  49. package/src/trpc/backend/files/backend/README.md.template +33 -0
  50. package/src/trpc/backend/files/common/constructs/src/app/trpc-apis/__apiNameKebabCase__.ts.template +18 -0
  51. package/src/trpc/backend/files/common/constructs/src/{__apiNameKebabCase__/index.ts.template → core/trpc-api.ts.template} +12 -16
  52. package/src/trpc/backend/files/schema/README.md.template +33 -0
  53. package/src/trpc/backend/generator.js +30 -44
  54. package/src/trpc/backend/generator.js.map +1 -1
  55. package/src/trpc/backend/schema.d.ts +3 -1
  56. package/src/trpc/backend/schema.json +8 -13
  57. package/src/trpc/react/README.md +46 -66
  58. package/src/trpc/react/__snapshots__/generator.spec.ts.snap +104 -65
  59. package/src/trpc/react/files/src/components/TrpcClients/IsolatedTrpcProvider.tsx.template +75 -0
  60. package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +1 -0
  61. package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +10 -0
  62. package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +5 -0
  63. package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +38 -0
  64. package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -0
  65. package/src/trpc/react/generator.js +124 -25
  66. package/src/trpc/react/generator.js.map +1 -1
  67. package/src/trpc/react/schema.json +2 -2
  68. package/src/ts/lib/__snapshots__/generator.spec.ts.snap +47 -93
  69. package/src/ts/lib/eslint.d.ts +1 -2
  70. package/src/ts/lib/eslint.js +62 -21
  71. package/src/ts/lib/eslint.js.map +1 -1
  72. package/src/ts/lib/files/README.md.template +33 -0
  73. package/src/ts/lib/generator.js +44 -5
  74. package/src/ts/lib/generator.js.map +1 -1
  75. package/src/ts/lib/schema.d.ts +1 -4
  76. package/src/ts/lib/schema.json +2 -21
  77. package/src/ts/lib/ts-project-utils.js +3 -18
  78. package/src/ts/lib/ts-project-utils.js.map +1 -1
  79. package/src/ts/lib/vitest.js +12 -0
  80. package/src/ts/lib/vitest.js.map +1 -1
  81. package/src/utils/ast.d.ts +13 -0
  82. package/src/utils/ast.js +102 -0
  83. package/src/utils/ast.js.map +1 -0
  84. package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
  85. package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
  86. package/src/utils/files/common/constructs/src/index.ts.template +2 -1
  87. package/src/utils/files/common/readme/README.md.template +33 -0
  88. package/src/utils/files/common/types/src/runtime-config.ts.template +2 -13
  89. package/src/utils/format.d.ts +1 -1
  90. package/src/utils/format.js +2 -2
  91. package/src/utils/format.js.map +1 -1
  92. package/src/utils/names.d.ts +2 -0
  93. package/src/utils/names.js +27 -0
  94. package/src/utils/names.js.map +1 -0
  95. package/src/utils/npm-scope.js.map +1 -1
  96. package/src/utils/paths.js.map +1 -1
  97. package/src/utils/shared-constructs.js +37 -4
  98. package/src/utils/shared-constructs.js.map +1 -1
  99. package/src/utils/test.d.ts +2 -0
  100. package/src/utils/test.js +19 -0
  101. package/src/utils/test.js.map +1 -0
  102. package/src/utils/versions.d.ts +15 -9
  103. package/src/utils/versions.js +14 -8
  104. package/src/utils/versions.js.map +1 -1
  105. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
  106. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
  107. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
  108. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
  109. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
  110. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
  111. package/src/gitlab/generator.d.ts +0 -8
  112. package/src/gitlab/generator.js +0 -16
  113. package/src/gitlab/generator.js.map +0 -1
  114. package/src/gitlab/schema.d.ts +0 -9
  115. package/src/gitlab/schema.json +0 -52
  116. package/src/infra/app/files/src/main.ts.template +0 -37
  117. package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
  118. package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
  119. package/src/ts/cjs-to-esm/generator.d.ts +0 -12
  120. package/src/ts/cjs-to-esm/generator.js +0 -189
  121. package/src/ts/cjs-to-esm/generator.js.map +0 -1
  122. package/src/ts/cjs-to-esm/schema.d.ts +0 -9
  123. package/src/ts/cjs-to-esm/schema.json +0 -28
  124. /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
  125. /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
  126. /package/src/utils/files/common/constructs/src/{runtime-config → core}/index.ts.template +0 -0
@@ -0,0 +1,885 @@
1
+ ## Config Rule Name : dynamodb-throughput-limit-check
2
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-throughput-limit-check.html"
3
+
4
+ #
5
+ #####################################
6
+ ## Gherkin ##
7
+ #####################################
8
+ # Rule Identifier:
9
+ # LAMBDA_CONCURRENCY_CHECK
10
+ #
11
+ # Description:
12
+ # Checks whether the AWS Lambda function is configured with function-level concurrent execution limit.
13
+ #
14
+ # Reports on:
15
+ # AWS::Lambda::Function
16
+ #
17
+ # Evaluates:
18
+ # AWS CloudFormation
19
+ #
20
+ # Rule Parameters:
21
+ # NA
22
+ #
23
+ # Scenarios:
24
+ # a) SKIP: when no AWS Lambda functions are present
25
+ # b) PASS: when all AWS Lambda functions are configured with function-level concurrent execution limits
26
+ # c) FAIL: when any AWS Lambda functions are not configured with function-level concurrent execution limits
27
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_CONCURRENCY_CHECK
28
+
29
+ #
30
+ # Select all AWS Lambda Function resources from incoming template (payload)
31
+ #
32
+ let aws_lambda_functions_concurrency = Resources.*[ Type == 'AWS::Lambda::Function'
33
+ Metadata.guard.SuppressedRules not exists or
34
+ Metadata.guard.SuppressedRules.* != "LAMBDA_CONCURRENCY_CHECK"
35
+ ]
36
+
37
+ rule LAMBDA_CONCURRENCY_CHECK when %aws_lambda_functions_concurrency !empty {
38
+ %aws_lambda_functions_concurrency.Properties.ReservedConcurrentExecutions >= 0
39
+ <<
40
+ Guard Rule Set: wa-Reliability-Pillar
41
+ Controls: REL-1
42
+ Violation: All AWS Lambda Functions must have concurrent execution limits configured
43
+ Fix: Set the ReservedConcurrentExecutions property to an integer greater than or equal to 0
44
+ >>
45
+ }
46
+ #
47
+ #####################################
48
+ ## Gherkin ##
49
+ #####################################
50
+ # Rule Identifier:
51
+ # LAMBDA_DLQ_CHECK
52
+ #
53
+ # Description:
54
+ # Checks whether an AWS Lambda function is configured with a dead-letter queue.
55
+ #
56
+ # Reports on:
57
+ # AWS::Lambda::Function
58
+ #
59
+ # Evaluates:
60
+ # AWS CloudFormation
61
+ #
62
+ # Rule Parameters:
63
+ # NA
64
+ #
65
+ # Scenarios:
66
+ # a) SKIP: when no AWS Lambda functions are present
67
+ # b) PASS: when all AWS Lambda functions are configured with a dead-letter queue
68
+ # c) FAIL: when any AWS Lambda functions are not configured with a dead-letter queue
69
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_DLQ_CHECK
70
+
71
+ #
72
+ # Select all AWS Lambda Function resources from incoming template (payload)
73
+ #
74
+ let aws_lambda_functions_dlq = Resources.*[ Type == 'AWS::Lambda::Function'
75
+ Metadata.guard.SuppressedRules not exists or
76
+ Metadata.guard.SuppressedRules.* != "LAMBDA_DLQ_CHECK"
77
+ ]
78
+
79
+ rule LAMBDA_DLQ_CHECK when %aws_lambda_functions_dlq !empty {
80
+ %aws_lambda_functions_dlq.Properties.DeadLetterConfig.TargetArn !empty
81
+ <<
82
+ Guard Rule Set: wa-Reliability-Pillar
83
+ Controls: REL-1,REL-6
84
+ Violation: All AWS Lambda Functions must have a dead-letter queue configured
85
+ Fix: Set the DeadLetterConfig.TargetAr Property to the Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic
86
+ >>
87
+ }
88
+ #
89
+ #####################################
90
+ ## Gherkin ##
91
+ #####################################
92
+ # Rule Identifier:
93
+ # ELASTICSEARCH_IN_VPC_ONLY
94
+ #
95
+ # Description:
96
+ # Elasticsearch domains must be in a VPC
97
+ #
98
+ # Reports on:
99
+ # AWS::Elasticsearch::Domain
100
+ #
101
+ # Evaluates:
102
+ # AWS CloudFormation
103
+ #
104
+ # Rule Parameters:
105
+ # NA
106
+ #
107
+ # Scenarios:
108
+ # a) SKIP: when there is no elasticsearch domain present
109
+ # b) FAIL: when elasticsearch domain does not have VPCOptions or Endpoint properties
110
+ # c) PASS: when elasticsearch domain has VPCOptions or Endpoint properties
111
+ # d) SKIP: when metada has rule suppression for ELASTICSEARCH_IN_VPC_ONLY
112
+
113
+ #
114
+ # Select all elasticsearch domains from incoming template
115
+ #
116
+ let elasticsearch_domains_vpc_required = Resources.*[ Type == 'AWS::Elasticsearch::Domain'
117
+ Metadata.guard.SuppressedRules not exists or
118
+ Metadata.guard.SuppressedRules.* != "ELASTICSEARCH_IN_VPC_ONLY"
119
+ ]
120
+
121
+ rule ELASTICSEARCH_IN_VPC_ONLY when %elasticsearch_domains_vpc_required !empty {
122
+ %elasticsearch_domains_vpc_required.Properties.VPCOptions EXISTS
123
+ <<
124
+ Guard Rule Set: wa-Reliability-Pillar
125
+ Controls: REL-2
126
+ Violation: Elasticsearch domains must be in a VPC.
127
+ Fix: Provide VPCOptions object to enable opensearch to function in a VPC.
128
+ >>
129
+ }
130
+ #
131
+ #####################################
132
+ ## Gherkin ##
133
+ #####################################
134
+ # Rule Identifier:
135
+ # EC2_INSTANCES_IN_VPC
136
+ #
137
+ # Description:
138
+ # Checks if your EC2 instances belong to a virtual private cloud (VPC).
139
+ #
140
+ # Reports on:
141
+ # AWS::EC2::Instance
142
+ #
143
+ # Evaluates:
144
+ # AWS CloudFormation
145
+ #
146
+ # Rule Parameters:
147
+ # NA
148
+ #
149
+ # Scenarios:
150
+ # a) SKIP: when there are no EC2 resource present
151
+ # b) PASS: when all EC2 resources have the SubnetId property set
152
+ # c) FAIL: when any EC2 resources do not have the SubnetId property set
153
+ # d) SKIP: when metadata includes the suppression for rule EC2_INSTANCES_IN_VPC
154
+
155
+ #
156
+ # Select all ECS Instance resources from incoming template (payload)
157
+ #
158
+ let ec2_instances_in_vpc = Resources.*[ Type == 'AWS::EC2::Instance'
159
+ Metadata.guard.SuppressedRules not exists or
160
+ Metadata.guard.SuppressedRules.* != "EC2_INSTANCES_IN_VPC"
161
+ ]
162
+
163
+ rule EC2_INSTANCES_IN_VPC when %ec2_instances_in_vpc !empty {
164
+ %ec2_instances_in_vpc.Properties.SubnetId !empty
165
+ <<
166
+ Guard Rule Set: wa-Reliability-Pillar
167
+ Controls: REL-2
168
+ Violation: EC2 Instances must belong to a VPC
169
+ Fix: set the SubnetId property to a subnet ID
170
+ >>
171
+ }
172
+ #
173
+ #####################################
174
+ ## Gherkin ##
175
+ #####################################
176
+ # Rule Identifier:
177
+ # LAMBDA_INSIDE_VPC
178
+ #
179
+ # Description:
180
+ # Checks whether an AWS Lambda function is allowed access to an Amazon Virtual Private Cloud.
181
+ #
182
+ # Reports on:
183
+ # AWS::Lambda::Function
184
+ #
185
+ # Evaluates:
186
+ # AWS CloudFormation
187
+ #
188
+ # Rule Parameters:
189
+ # NA
190
+ #
191
+ # Scenarios:
192
+ # a) SKIP: when no AWS Lambda functions are present
193
+ # b) PASS: when all AWS Lambda functions are VPC enabled
194
+ # c) FAIL: when any AWS Lambda functions are not VPC enabled
195
+ # d) SKIP: hen metadata includes the suppression for rule LAMBDA_INSIDE_VPC
196
+
197
+ #
198
+ # Select all AWS Lambda Function resources from incoming template (payload)
199
+ #
200
+ let aws_lambda_functions_inside_vpc = Resources.*[ Type == 'AWS::Lambda::Function'
201
+ Metadata.guard.SuppressedRules not exists or
202
+ Metadata.guard.SuppressedRules.* != "LAMBDA_INSIDE_VPC"
203
+ ]
204
+
205
+ rule LAMBDA_INSIDE_VPC when %aws_lambda_functions_inside_vpc !empty {
206
+ %aws_lambda_functions_inside_vpc.Properties.VpcConfig.SecurityGroupIds !empty
207
+ %aws_lambda_functions_inside_vpc.Properties.VpcConfig.SubnetIds !empty
208
+ <<
209
+ Guard Rule Set: wa-Reliability-Pillar
210
+ Controls: REL-2
211
+ Violation: All AWS Lambda Functions must be configured with access to a VPC
212
+ Fix: set the VpcConfig.SecurityGroupIds and VpcConfig.SubnetIds parameters with a list of security groups and subnets.
213
+ Lambda creates an elastic network interface for each combination of security group and subnet in the function's VPC configuration.
214
+ >>
215
+ }
216
+ ## Config Rule Name : autoscaling-group-elb-healthcheck-required
217
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-group-elb-healthcheck-required.html"
218
+ #
219
+ #####################################
220
+ ## Gherkin ##
221
+ #####################################
222
+ # Rule Identifier:
223
+ # AUTOSCALING_GROUP_ELB_HEALTHCHECK_REQUIRED
224
+ #
225
+ # Description:
226
+ # Checks whether your Auto Scaling groups that are associated with a load balancer are using Elastic Load Balancing health checks.
227
+ #
228
+ # Reports on:
229
+ # AWS::AutoScaling::AutoScalingGroup
230
+ #
231
+ # Evaluates:
232
+ # AWS CloudFormation
233
+ #
234
+ # Rule Parameters:
235
+ # NA
236
+ #
237
+ # Scenarios:
238
+ # a) SKIP: when there are no S3 resource present
239
+ # b) PASS: when all S3 resources ObjectLockEnabled property is set to true
240
+ # c) FAIL: when all S3 resources do not have the ObjectLockEnabled property is set to true or is missing
241
+ # d) SKIP: when metada has rule suppression for S3_BUCKET_DEFAULT_LOCK_ENABLED
242
+
243
+ #
244
+ # Select all S3 resources from incoming template (payload)
245
+ #
246
+ ## Config Rule Name : beanstalk-enhanced-health-reporting-enabled
247
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/beanstalk-enhanced-health-reporting-enabled.html"
248
+
249
+ #
250
+ #####################################
251
+ ## Gherkin ##
252
+ #####################################
253
+ # Rule Identifier:
254
+ # CLOUDWATCH_ALARM_ACTION_CHECK
255
+ #
256
+ # Description:
257
+ # Checks whether CloudWatch alarms have at least one alarm action,
258
+ # one Insufficient Data Actions action, or one OK action enabled.
259
+ #
260
+ # Reports on:
261
+ # AWS::Logs::LogGroup
262
+ #
263
+ # Evaluates:
264
+ # AWS CloudFormation
265
+ #
266
+ # Rule Parameters:
267
+ # NA
268
+ #
269
+ # Scenarios:
270
+ # a) SKIP: when there are no cloudwatch alarm resources present
271
+ # b) PASS: when resource Metadata is set with rule suppressed
272
+ # c) PASS: when all cloudwatch alarm resources property Alarm Actions, Insufficient Data Actions, or OK Action set
273
+ # d) FAIL: when all cloudwatch alarms resources property Alarm Actions, Insufficient Data Actions, or OK Action are not set with valid value
274
+ # e) SKIP: when metada has rule suppression for CLOUDWATCH_ALARM_ACTION_CHECK
275
+
276
+ #
277
+ # Select all cloudwatch logs log group resources from incoming template (payload)
278
+ #
279
+ let cloudwatch_alarm_action_check = Resources.*[ Type == 'AWS::CloudWatch::Alarm'
280
+ Metadata.guard.SuppressedRules not exists or
281
+ Metadata.guard.SuppressedRules.* != "CLOUDWATCH_ALARM_ACTION_CHECK"
282
+ ]
283
+
284
+ rule CLOUDWATCH_ALARM_ACTION_CHECK when %cloudwatch_alarm_action_check !empty {
285
+ %cloudwatch_alarm_action_check.Properties.AlarmActions exists or
286
+ %cloudwatch_alarm_action_check.Properties.OKActions exists or
287
+ %cloudwatch_alarm_action_check.Properties.InsufficientDataActions exists
288
+
289
+ <<
290
+ Guard Rule Set: wa-Reliability-Pillar
291
+ Controls: REL-6
292
+ Violation: CloudWatch Alarms should have at least one Alarm Action, one Insufficient Data Actions action, or one OK Action enabled.
293
+ Fix: Set one Alarm Action, one Insufficient Data Actions action, or one OK Action on the CloudWatch Alarm resource.
294
+ >>
295
+ }
296
+
297
+
298
+ #
299
+ #####################################
300
+ ## Gherkin ##
301
+ #####################################
302
+ # Rule Identifier:
303
+ # EC2_INSTANCE_DETAILED_MONITORING_ENABLED
304
+ #
305
+ # Description:
306
+ # Checks if detailed monitoring is enabled for EC2 instances.
307
+ #
308
+ # Reports on:
309
+ # AWS::EC2::Instance
310
+ #
311
+ # Evaluates:
312
+ # AWS CloudFormation
313
+ #
314
+ # Rule Parameters:
315
+ # NA
316
+ #
317
+ # Scenarios:
318
+ # a) SKIP: when there are no EC2 resource present
319
+ # b) PASS: when all EC2 resources have the Monitoring property set to true
320
+ # c) FAIL: when any EC2 resources do not have the Monitoring property set to true
321
+ # d) SKIP: hen metadata includes the suppression for rule EC2_INSTANCE_DETAILED_MONITORING_ENABLED
322
+
323
+ #
324
+ # Select all EC2 Instance resources from incoming template (payload)
325
+ #
326
+ let ec2_instances_detailed_monitoring_enabled = Resources.*[ Type == 'AWS::EC2::Instance'
327
+ Metadata.guard.SuppressedRules not exists or
328
+ Metadata.guard.SuppressedRules.* != "EC2_INSTANCE_DETAILED_MONITORING_ENABLED"
329
+ ]
330
+
331
+ rule EC2_INSTANCE_DETAILED_MONITORING_ENABLED when %ec2_instances_detailed_monitoring_enabled !empty {
332
+ %ec2_instances_detailed_monitoring_enabled.Properties.Monitoring == true
333
+ <<
334
+ Guard Rule Set: wa-Reliability-Pillar
335
+ Controls: REL-6
336
+ Violation: EC2 Instance Monitoring must be enabled on all EC2 instances
337
+ Fix: set the Monitoring property to true
338
+ >>
339
+ }
340
+ #
341
+ #####################################
342
+ ## Gherkin ##
343
+ #####################################
344
+ # Rule Identifier:
345
+ # RDS_ENHANCED_MONITORING_ENABLED
346
+ #
347
+ # Description:
348
+ # Checks whether enhanced monitoring is enabled for Amazon Relational Database Service (Amazon RDS) instances.
349
+ #
350
+ # Reports on:
351
+ # AWS::RDS::DBInstance
352
+ #
353
+ # Evaluates:
354
+ # AWS CloudFormation
355
+ #
356
+ # Rule Parameters:
357
+ # NA
358
+ #
359
+ # Scenarios:
360
+ # a) SKIP: when there are no RDS instances present
361
+ # b) PASS: when all RDS instances have MonitoringInterval set to a value of 1, 5, 10, 15, 30, or 60
362
+ # c) FAIL: when all RDS instances have MonitoringInterval set to 0
363
+ # d) FAIL: when there are RDS instances with MonitoringInterval property is not present
364
+ # e) SKIP: when metadata includes the suppression for rule RDS_ENHANCED_MONITORING_ENABLED
365
+
366
+
367
+ #
368
+ # Select all RDS instance resources from incoming template (payload)
369
+ #
370
+
371
+ let aws_rds_instances_enhanced_monitoring_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
372
+ Metadata.guard.SuppressedRules not exists or
373
+ Metadata.guard.SuppressedRules.* != "RDS_ENHANCED_MONITORING_ENABLED"
374
+ ]
375
+
376
+
377
+ rule RDS_ENHANCED_MONITORING_ENABLED when %aws_rds_instances_enhanced_monitoring_enabled !empty {
378
+ %aws_rds_instances_enhanced_monitoring_enabled.Properties.MonitoringInterval EXISTS
379
+ %aws_rds_instances_enhanced_monitoring_enabled.Properties.MonitoringInterval IN [1, 5, 10, 15, 30, 60]
380
+ <<
381
+ Guard Rule Set: wa-Reliability-Pillar
382
+ Controls: REL-6
383
+ Violation: RDS Instance enhanced monitoring required.
384
+ Fix: Specify a value of 1, 5, 10, 15, 30, or 60 for the parameter on the property MonitoringInterval.
385
+ >>
386
+ }
387
+
388
+ ## Config Rule Name : dynamodb-autoscaling-enabled
389
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-autoscaling-enabled.html"
390
+
391
+ ## Config Rule Name : autoscaling-launch-config-public-ip-disabled
392
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/AUTOSCALING_LAUNCH_CONFIG_PUBLIC_IP_DISABLED.html"
393
+
394
+ ####################################
395
+ ## Gherkin ##
396
+ #####################################
397
+ # Rule Identifier:
398
+ # REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK
399
+ #
400
+ # Description:
401
+ # Checks whether Amazon Redshift clusters have the specified maintenance settings (AllowVersionUpgrade, PreferredMaintenanceWindow, AutomatedSnapshotRetentionPeriod)
402
+ #
403
+ # Reports on:
404
+ # AWS::Redshift::Cluster
405
+ #
406
+ # Evaluates:
407
+ # AWS CloudFormation
408
+ #
409
+ # Rule Parameters:
410
+ # NA
411
+ #
412
+ # Scenarios:
413
+ # a) SKIP: when there are no Redshift Cluster resource present
414
+ # b) PASS: when Redshift Cluster resources have properties PreferredMaintenanceWindow set, AllowVersionUpgrade either not set (default true) or set to true, and AutomatedSnapshotRetentionPeriod either not set (default 1 day) or set to greated than 0.
415
+ # c) FAIL: when any Redshift Cluster resources do not have PreferredMaintenanceWindow property set
416
+ # d) FAIL: when any Redshift Cluster resources have AllowVersionUpgrade property set to false
417
+ # e) FAIL: when any Redshift Cluster resources have AutomatedSnapshotRetentionPeriod property set to 0
418
+ # f) SKIP: when metadata includes the suppression for rule REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK
419
+
420
+ #
421
+ # Select all Redshift Cluster resources from incoming template (payload)
422
+ #
423
+ let redhshift_clusters_maintenancesettings_check = Resources.*[ Type == 'AWS::Redshift::Cluster'
424
+ Metadata.guard.SuppressedRules not exists or
425
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK"
426
+ ]
427
+
428
+ rule REDSHIFT_CLUSTER_MAINTENANCESETTINGS_CHECK when %redhshift_clusters_maintenancesettings_check !empty {
429
+ %redhshift_clusters_maintenancesettings_check.Properties.PreferredMaintenanceWindow exists
430
+
431
+ %redhshift_clusters_maintenancesettings_check.Properties.AllowVersionUpgrade not exists or
432
+ %redhshift_clusters_maintenancesettings_check.Properties.AllowVersionUpgrade == true
433
+
434
+
435
+ %redhshift_clusters_maintenancesettings_check.Properties.AutomatedSnapshotRetentionPeriod not exists or
436
+ %redhshift_clusters_maintenancesettings_check.Properties.AutomatedSnapshotRetentionPeriod > 0
437
+
438
+ <<
439
+ Guard Rule Set: wa-Reliability-Pillar
440
+ Controls: REL-8
441
+ Violation: Amazon Redshift maintenance settings must be configured
442
+ Fix: set the PreferredMaintenanceWindow property, remove the AllowVersionUpgrade property (default true) or set it to true, and remove the AutomatedSnapshotRetentionPeriod property (default 1 day) or set it to greated than 0.
443
+ >>
444
+ }
445
+ #
446
+ #####################################
447
+ ## Gherkin ##
448
+ #####################################
449
+ # Rule Identifier:
450
+ # RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED
451
+ #
452
+ # Description:
453
+ # Checks whether storage encryption is enabled for your RDS DB instances
454
+ #
455
+ # Reports on:
456
+ # AWS::RDS::DBInstance
457
+ #
458
+ # Evaluates:
459
+ # AWS CloudFormation
460
+ #
461
+ # Rule Parameters:
462
+ # NA
463
+ #
464
+ # Scenarios:
465
+ # a) SKIP: when there are no RDS instances present
466
+ # b) PASS: when all RDS instances have AutoMinorVersionUpgrade set to true
467
+ # c) FAIL: when all RDS instances have AutoMinorVersionUpgrade set to false
468
+ # d) FAIL: when there are RDS instances with AutoMinorVersionUpgrade property is not present
469
+ # e) SKIP: when metadata includes the suppression for rule RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED
470
+
471
+ #
472
+ # Select all RDS instance resources from incoming template (payload)
473
+ #
474
+
475
+ let aws_rds_instances_minor_version_upgrade_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
476
+ Metadata.guard.SuppressedRules not exists or
477
+ Metadata.guard.SuppressedRules.* != "RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED"
478
+ ]
479
+
480
+
481
+ rule RDS_AUTOMATIC_MINOR_VERSION_UPGRADE_ENABLED when %aws_rds_instances_minor_version_upgrade_enabled !empty {
482
+ %aws_rds_instances_minor_version_upgrade_enabled.Properties.AutoMinorVersionUpgrade EXISTS
483
+ %aws_rds_instances_minor_version_upgrade_enabled.Properties.AutoMinorVersionUpgrade == true
484
+ <<
485
+ Guard Rule Set: wa-Reliability-Pillar
486
+ Controls: REL-8
487
+ Violation: All RDS instances must have automatic minor version upgrade enabled.
488
+ Fix: Set the AutoMinorVersionUpgrade parameter to true.
489
+ >>
490
+ }
491
+
492
+ #
493
+ #####################################
494
+ ## Gherkin ##
495
+ #####################################
496
+ # Rule Identifier:
497
+ # DB_INSTANCE_BACKUP_ENABLED
498
+ #
499
+ # Description:
500
+ # Checks if RDS DB instances have backups enabled.
501
+ #
502
+ # Reports on:
503
+ # AWS::RDS::DBInstance
504
+ #
505
+ # Evaluates:
506
+ # AWS CloudFormation
507
+ #
508
+ # Rule Parameters:
509
+ # NA
510
+ #
511
+ # Scenarios:
512
+ # a) SKIP: when there are no RDS instances present
513
+ # b) PASS: when all RDS instances have BackupRetentionPeriod set to a positive number
514
+ # c) FAIL: when all RDS instances have BackupRetentionPeriod set to 0
515
+ # d) FAIL: when there are RDS instances with BackupRetentionPeriod property is not present
516
+ # e) SKIP: when metadata includes the suppression for rule DB_INSTANCE_BACKUP_ENABLED
517
+
518
+ #
519
+ # Select all RDS instance resources from incoming template (payload)
520
+ #
521
+
522
+ let aws_rds_instances_db_instance_backup_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
523
+ Metadata.guard.SuppressedRules not exists or
524
+ Metadata.guard.SuppressedRules.* != "DB_INSTANCE_BACKUP_ENABLED"
525
+ ]
526
+
527
+
528
+ rule DB_INSTANCE_BACKUP_ENABLED when %aws_rds_instances_db_instance_backup_enabled !empty {
529
+ %aws_rds_instances_db_instance_backup_enabled.Properties.BackupRetentionPeriod EXISTS
530
+ %aws_rds_instances_db_instance_backup_enabled.Properties.BackupRetentionPeriod >= 1
531
+ <<
532
+ Guard Rule Set: wa-Reliability-Pillar
533
+ Controls: REL-9
534
+ Violation: All RDS instances must have automated backup enabled.
535
+ Fix: Set the BackupRetentionPeriod to values of 1 to 35 to enable backups.
536
+ >>
537
+ }
538
+
539
+ ## Config Rule Name : dynamodb-in-backup-plan
540
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-in-backup-plan.html"
541
+
542
+ ## Config Rule Name : dynamodb-pitr-enabled
543
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/dynamodb-pitr-enabled.html"
544
+
545
+ # Rule Intent: All DynamoDB Tables must have Point-In-Time-Recovery enabled
546
+
547
+ # Expectations:
548
+ # a) SKIP: when there are no DynamoDB Tables present
549
+ # b) PASS: when all DynamoDB Tables have PITR enabled
550
+ # c) FAIL: when all DynamoDB Tables have PITR disabled
551
+
552
+ #
553
+ # Select all DynamoDB Table resources from incoming template (payload)
554
+ #
555
+ let aws_dynamodb_table_resources = Resources.*[ Type == 'AWS::DynamoDB::Table' ]
556
+
557
+
558
+ rule DYNAMODB_PITR_ENABLED when %aws_dynamodb_table_resources !empty {
559
+ # Ensure ALL DynamoDB Tables have Point-In-Time-Recovery enabled
560
+ %aws_dynamodb_table_resources.Properties.PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled == true
561
+ <<
562
+ Guard Rule Set: wa-Reliability-Pillar
563
+ Controls: REL-9
564
+ Violation: All DynamoDB Tables must have Point-In-Time-Recovery enabled.
565
+ Fix: Set the dynamodb table property PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled to true.
566
+ >>
567
+ }
568
+
569
+ ## Config Rule Name : elasticache-redis-cluster-automatic-backup-check
570
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elasticache-redis-cluster-automatic-backup-check.html"
571
+
572
+ #
573
+ #####################################
574
+ ## Gherkin ##
575
+ #####################################
576
+ # Rule Identifier:
577
+ # S3_BUCKET_REPLICATION_ENABLED
578
+ #
579
+ # Description:
580
+ # Checks whether the Amazon S3 buckets have cross-region replication enabled.
581
+ #
582
+ # Reports on:
583
+ # AWS::S3::Bucket
584
+ #
585
+ # Evaluates:
586
+ # AWS CloudFormation
587
+ #
588
+ # Rule Parameters:
589
+ # NA
590
+ #
591
+ # Scenarios:
592
+ # a) SKIP: when there are no S3 resource present
593
+ # b) PASS: when all S3 resources replication configuration set status is set to Enabled
594
+ # c) FAIL: when all S3 resources have Versioning Configuration status property not set or set to Suspended
595
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_REPLICATION_ENABLED
596
+
597
+ #
598
+ # Select all S3 resources from incoming template (payload)
599
+ #
600
+
601
+ let s3_buckets_replication_enabled = Resources.*[ Type == 'AWS::S3::Bucket'
602
+ Metadata.guard.SuppressedRules not exists or
603
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_REPLICATION_ENABLED"
604
+ ]
605
+
606
+ rule S3_BUCKET_REPLICATION_ENABLED when %s3_buckets_replication_enabled !empty {
607
+ %s3_buckets_replication_enabled.Properties.ReplicationConfiguration exists
608
+ <<
609
+ Guard Rule Set: wa-Reliability-Pillar
610
+ Controls: REL-9
611
+ Violation: S3 Bucket replication should be enabled.
612
+ Fix: Set S3 Bucket ReplicationConfiguration to another S3 Bucket.
613
+ >>
614
+ ## TODO regex to identify cross-region
615
+ }
616
+ #
617
+ #####################################
618
+ ## Gherkin ##
619
+ #####################################
620
+ # Rule Identifier:
621
+ # EBS_OPTIMIZED_INSTANCE
622
+ #
623
+ # Description:
624
+ # Checks whether EBS optimization is enabled for your EC2 instances that can be EBS-optimized
625
+ #
626
+ # Reports on:
627
+ # AWS::EC2::Instance
628
+ #
629
+ # Evaluates:
630
+ # AWS CloudFormation
631
+ #
632
+ # Rule Parameters:
633
+ # NA
634
+ #
635
+ # Scenarios:
636
+ # a) SKIP: when there are no EC2 resource present
637
+ # b) PASS: when all EC2 resources EbsOptimized property is set to true
638
+ # c) FAIL: when any EC2 resources do not have the EbsOptimized property set to true
639
+ # e) SKIP: hen metadata includes the suppression for rule EBS_OPTIMIZED_INSTANCE
640
+
641
+ #
642
+ # Select all AWS EC2 Instance resources from incoming template (payload)
643
+ #
644
+ let ec2_ebs_optimized_instances = Resources.*[ Type == 'AWS::EC2::Instance'
645
+ Metadata.guard.SuppressedRules not exists or
646
+ Metadata.guard.SuppressedRules.* != "EBS_OPTIMIZED_INSTANCE"
647
+ ]
648
+
649
+ rule EBS_OPTIMIZED_INSTANCE when %ec2_ebs_optimized_instances !empty {
650
+ %ec2_ebs_optimized_instances.Properties.EbsOptimized == true
651
+ <<
652
+ Guard Rule Set: wa-Reliability-Pillar
653
+ Controls: REL-9
654
+ Violation: EBS optimization must be enabled for your EC2 instances
655
+ Fix: set the EbsOptimized property to true
656
+ >>
657
+ }
658
+ #
659
+ #####################################
660
+ ## Gherkin ##
661
+ #####################################
662
+ # Rule Identifier:
663
+ # REDSHIFT_BACKUP_ENABLED
664
+ #
665
+ # Description:
666
+ # Checks that Amazon Redshift automated snapshots are enabled for clusters.
667
+ #
668
+ # Reports on:
669
+ # AWS::Redshift::Cluster
670
+ #
671
+ # Evaluates:
672
+ # AWS CloudFormation
673
+ #
674
+ # Rule Parameters:
675
+ # NA
676
+ #
677
+ # Scenarios:
678
+ # a) SKIP: when there are no Redshift Cluster resource present
679
+ # b) PASS: when Redshift Cluster resources don't have the AutomatedSnapshotRetentionPeriod property set (default retention period is 1 day)
680
+ # c) PASS: when Redshift Cluster resources have the AutomatedSnapshotRetentionPeriod property set to greater than 0
681
+ # d) FAIL: when any Redshift Cluster resources have the AutomatedSnapshotRetentionPeriod property set to 0
682
+ # e) SKIP: when metadata includes the suppression for rule REDSHIFT_BACKUP_ENABLED
683
+
684
+ #
685
+ # Select all Redshift Cluster resources from incoming template (payload)
686
+ #
687
+ let redhshift_backup_enabled_clusters = Resources.*[ Type == 'AWS::Redshift::Cluster'
688
+ Metadata.guard.SuppressedRules not exists or
689
+ Metadata.guard.SuppressedRules.* != "REDSHIFT_BACKUP_ENABLED"
690
+ ]
691
+
692
+ rule REDSHIFT_BACKUP_ENABLED when %redhshift_backup_enabled_clusters !empty {
693
+ %redhshift_backup_enabled_clusters.Properties.AutomatedSnapshotRetentionPeriod not exists
694
+ or %redhshift_backup_enabled_clusters.Properties.AutomatedSnapshotRetentionPeriod > 0
695
+ <<
696
+ Guard Rule Set: wa-Reliability-Pillar
697
+ Controls: REL-9
698
+ Violation: Amazon Redshift automated snapshots must be enabled for clusters
699
+ Fix: Either remove the AutomatedSnapshotRetentionPeriod property (default retention period is 1 day)
700
+ Or set the AutomatedSnapshotRetentionPeriod property to an integer greater than 0
701
+ >>
702
+ }
703
+ #
704
+ #####################################
705
+ ## Gherkin ##
706
+ #####################################
707
+ # Rule Identifier:
708
+ # S3_BUCKET_VERSIONING_ENABLED
709
+ #
710
+ # Description:
711
+ # Checks if versioning is enabled for your S3 buckets.
712
+ #
713
+ # Reports on:
714
+ # AWS::S3::Bucket
715
+ #
716
+ # Evaluates:
717
+ # AWS CloudFormation
718
+ #
719
+ # Rule Parameters:
720
+ # NA
721
+ #
722
+ # Scenarios:
723
+ # a) SKIP: when there are no S3 resource present
724
+ # b) PASS: when all S3 resources Versioning Configuration status is set to Enabled
725
+ # c) FAIL: when all S3 resources have Versioning Configuration status property not set or set to Suspended
726
+ # d) SKIP: when metadata includes the suppression for rule S3_BUCKET_VERSIONING_ENABLED
727
+
728
+ #
729
+ # Select all S3 resources from incoming template (payload)
730
+ #
731
+ let s3_buckets_versioning_enabled = Resources.*[ Type == 'AWS::S3::Bucket'
732
+ Metadata.guard.SuppressedRules not exists or
733
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_VERSIONING_ENABLED"
734
+ ]
735
+
736
+ rule S3_BUCKET_VERSIONING_ENABLED when %s3_buckets_versioning_enabled !empty {
737
+ %s3_buckets_versioning_enabled.Properties.VersioningConfiguration exists
738
+ %s3_buckets_versioning_enabled.Properties.VersioningConfiguration.Status == 'Enabled'
739
+ <<
740
+ Guard Rule Set: wa-Reliability-Pillar
741
+ Controls: REL-9
742
+ Violation: S3 Bucket Versioning must be enabled.
743
+ Fix: Set the S3 Bucket property VersioningConfiguration.Status to 'Enabled' .
744
+ >>
745
+ }
746
+ ## Config Rule Name : elb-cross-zone-load-balancing-enabled
747
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-cross-zone-load-balancing-enabled.html"
748
+
749
+ #
750
+ #####################################
751
+ ## Gherkin ##
752
+ #####################################
753
+ # Rule Identifier:
754
+ # RDS_MULTI_AZ_SUPPORT
755
+ #
756
+ # Description:
757
+ # In a Multi-AZ deployment, Amazon RDS automatically provisions and maintains a synchronous
758
+ # standby replica in a different Availability Zone.
759
+ #
760
+ # Reports on:
761
+ # AWS::RDS::DBInstance
762
+ #
763
+ # Evaluates:
764
+ # AWS CloudFormation
765
+ #
766
+ # Rule Parameters:
767
+ # NA
768
+ #
769
+ # Scenarios:
770
+ # a) SKIP: when there are no RDS instances present
771
+ # b) PASS: when all RDS instances have MultiAZ set to true
772
+ # c) FAIL: when all RDS instances have MultiAZ set to false
773
+ # d) FAIL: when there are RDS instances with MultiAZ property is not present
774
+ # e) SKIP: when metadata includes the suppression for rule RDS_MULTI_AZ_SUPPORT
775
+
776
+ #
777
+ # Select all RDS instance resources from incoming template (payload)
778
+ #
779
+ let aws_rds_instances_multi_az_support = Resources.*[ Type == 'AWS::RDS::DBInstance'
780
+ Metadata.guard.SuppressedRules not exists or
781
+ Metadata.guard.SuppressedRules.* != "RDS_MULTI_AZ_SUPPORT"
782
+ ]
783
+
784
+ rule RDS_MULTI_AZ_SUPPORT when %aws_rds_instances_multi_az_support !empty {
785
+ %aws_rds_instances_multi_az_support.Properties.MultiAZ EXISTS
786
+ %aws_rds_instances_multi_az_support.Properties.MultiAZ == true
787
+ <<
788
+ Guard Rule Set: wa-Reliability-Pillar
789
+ Controls: REL-10
790
+ Violation: All RDS instances must have MultiAZ support enabled.
791
+ Fix: Set the MultiAZ parameter to true.
792
+ >>
793
+ }
794
+
795
+ ## Config Rule Name : elb-deletion-protection-enabled
796
+ ## Config Rule URL: https://docs.aws.amazon.com/config/latest/developerguide/elb-deletion-protection-enabled.html"
797
+
798
+ #
799
+ #####################################
800
+ ## Gherkin ##
801
+ #####################################
802
+ # Rule Identifier:
803
+ # RDS_INSTANCE_DELETION_PROTECTION_ENABLED
804
+ #
805
+ # Description:
806
+ # Checks if an Amazon Relational Database Service (Amazon RDS) instance has deletion protection enabled.
807
+ #
808
+ # Reports on:
809
+ # AWS::RDS::DBInstance
810
+ #
811
+ # Evaluates:
812
+ # AWS CloudFormation
813
+ #
814
+ # Rule Parameters:
815
+ # NA
816
+ #
817
+ # Scenarios:
818
+ # a) SKIP: when there are no RDS instances present
819
+ # b) PASS: when all RDS instances have DeletionProtection set to true
820
+ # c) FAIL: when all RDS instances have DeletionProtection set to false
821
+ # d) FAIL: when there are RDS instances with DeletionProtection property is not present
822
+ # e) SKIP: when metadata includes the suppression for rule RDS_INSTANCE_DELETION_PROTECTION_ENABLED
823
+
824
+ #
825
+ # Select all RDS instance resources from incoming template (payload)
826
+ #
827
+ let aws_rds_instances_deletion_protection_enabled = Resources.*[ Type == 'AWS::RDS::DBInstance'
828
+ Metadata.guard.SuppressedRules not exists or
829
+ Metadata.guard.SuppressedRules.* != "RDS_INSTANCE_DELETION_PROTECTION_ENABLED"
830
+ ]
831
+
832
+ rule RDS_INSTANCE_DELETION_PROTECTION_ENABLED when %aws_rds_instances_deletion_protection_enabled !empty {
833
+ %aws_rds_instances_deletion_protection_enabled.Properties.DeletionProtection EXISTS
834
+ %aws_rds_instances_deletion_protection_enabled.Properties.DeletionProtection == true
835
+ <<
836
+ Guard Rule Set: wa-Reliability-Pillar
837
+ Controls: REL-10
838
+ Violation: All RDS instances must deletion protection enabled.
839
+ Fix: Set the parameter for DeletionProtection to true.
840
+ >>
841
+ }
842
+
843
+ #
844
+ #####################################
845
+ ## Gherkin ##
846
+ #####################################
847
+ # Rule Identifier:
848
+ # S3_BUCKET_DEFAULT_LOCK_ENABLED
849
+ #
850
+ # Description:
851
+ # Checks whether Amazon S3 bucket has lock enabled, by default
852
+ #
853
+ # Reports on:
854
+ # AWS::S3::Bucket
855
+ #
856
+ # Evaluates:
857
+ # AWS CloudFormation
858
+ #
859
+ # Rule Parameters:
860
+ # NA
861
+ #
862
+ # Scenarios:
863
+ # a) SKIP: when there are no S3 resource present
864
+ # b) PASS: when all S3 resources ObjectLockEnabled property is set to true
865
+ # c) FAIL: when all S3 resources do not have the ObjectLockEnabled property is set to true or is missing
866
+ # d) SKIP: when metada has rule suppression for S3_BUCKET_DEFAULT_LOCK_ENABLED
867
+
868
+ #
869
+ # Select all S3 resources from incoming template (payload)
870
+ #
871
+ let s3_buckets_default_lock_enabled = Resources.*[ Type == 'AWS::S3::Bucket'
872
+ Metadata.guard.SuppressedRules not exists or
873
+ Metadata.guard.SuppressedRules.* != "S3_BUCKET_DEFAULT_LOCK_ENABLED"
874
+ ]
875
+
876
+ rule S3_BUCKET_DEFAULT_LOCK_ENABLED when %s3_buckets_default_lock_enabled !empty {
877
+ %s3_buckets_default_lock_enabled.Properties.ObjectLockEnabled exists
878
+ %s3_buckets_default_lock_enabled.Properties.ObjectLockEnabled == true
879
+ <<
880
+ Guard Rule Set: wa-Reliability-Pillar
881
+ Controls: REL-10
882
+ Violation: S3 Bucket ObjectLockEnabled must be set to true.
883
+ Fix: Set the S3 property ObjectLockEnabled parameter to true.
884
+ >>
885
+ }