Skip to content

Commit 25fcf34

Browse files
authored
CCM-10048: flaky tests (#488)
1 parent ce3f410 commit 25fcf34

16 files changed

+391
-45
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,5 @@ lambdas/backend-api/src/email/email-template.json
9090

9191
# vscode
9292
.vscode/settings.local.json
93+
94+
test-runs

infrastructure/terraform/modules/backend-api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ No requirements.
1616
| <a name="input_csi"></a> [csi](#input\_csi) | CSI from the parent component | `string` | n/a | yes |
1717
| <a name="input_enable_backup"></a> [enable\_backup](#input\_enable\_backup) | Enable Backups for the DynamoDB table? | `bool` | `true` | no |
1818
| <a name="input_enable_event_stream"></a> [enable\_event\_stream](#input\_enable\_event\_stream) | Enable DynamoDB streaming to SQS? | `bool` | `false` | no |
19+
| <a name="input_enable_guardduty"></a> [enable\_guardduty](#input\_enable\_guardduty) | Enable GuardDuty | `bool` | `true` | no |
1920
| <a name="input_enable_proofing"></a> [enable\_proofing](#input\_enable\_proofing) | Enable proofing feature flag | `bool` | n/a | yes |
2021
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
2122
| <a name="input_function_s3_bucket"></a> [function\_s3\_bucket](#input\_function\_s3\_bucket) | Name of S3 bucket to upload lambda artefacts to | `string` | n/a | yes |

infrastructure/terraform/modules/backend-api/cloudwatch_event_rule_guardduty_quarantine_scan_failed_for_proof.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_failed_for_proof
33
description = "Matches quarantine 'GuardDuty Malware Protection Object Scan Result' events where the scan result is not NO_THREATS_FOUND"
44

55
event_pattern = jsonencode({
6-
source = ["aws.guardduty"]
6+
source = [local.guardduty_source]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
8+
resources = [local.guardduty_resource]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]

infrastructure/terraform/modules/backend-api/cloudwatch_event_rule_guardduty_quarantine_scan_failed_for_upload.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_failed_for_uploa
33
description = "Matches quarantine 'GuardDuty Malware Protection Object Scan Result' events where the scan result is not NO_THREATS_FOUND"
44

55
event_pattern = jsonencode({
6-
source = ["aws.guardduty"]
6+
source = [local.guardduty_source]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
8+
resources = [local.guardduty_resource]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]

infrastructure/terraform/modules/backend-api/cloudwatch_event_rule_guardduty_quarantine_scan_passed_for_proof.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_passed_for_proof
33
description = "Matches quarantine 'GuardDuty Malware Protection Object Scan Result' events where the scan result is NO_THREATS_FOUND"
44

55
event_pattern = jsonencode({
6-
source = ["aws.guardduty"]
6+
source = [local.guardduty_source]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
8+
resources = [local.guardduty_resource]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]

infrastructure/terraform/modules/backend-api/cloudwatch_event_rule_guardduty_quarantine_scan_passed_for_upload.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_passed_for_uploa
33
description = "Matches quarantine 'GuardDuty Malware Protection Object Scan Result' events where the scan result is NO_THREATS_FOUND"
44

55
event_pattern = jsonencode({
6-
source = ["aws.guardduty"]
6+
source = [local.guardduty_source]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
8+
resources = [local.guardduty_resource]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]

infrastructure/terraform/modules/backend-api/guardduty_malware_protection_plan_quarantine.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
resource "aws_guardduty_malware_protection_plan" "quarantine" {
2+
count = var.enable_guardduty ? 1 : 0
3+
24
role = aws_iam_role.guardduty_quarantine.arn
35

46
protected_resource {

infrastructure/terraform/modules/backend-api/locals.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ locals {
5959
][0], "")
6060

6161
sftp_environment = "${var.group}-${var.environment}-${var.component}"
62+
63+
guardduty_source = var.enable_guardduty ? "aws.guardduty" : "test.guardduty"
64+
65+
guardduty_resource = var.enable_guardduty ? aws_guardduty_malware_protection_plan.quarantine[0].arn : "test:guardduty"
6266
}

infrastructure/terraform/modules/backend-api/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ variable "enable_backup" {
7171
default = true
7272
}
7373

74+
variable "enable_guardduty" {
75+
type = bool
76+
description = "Enable GuardDuty"
77+
default = true
78+
}
79+
7480
variable "enable_proofing" {
7581
type = bool
7682
description = "Enable proofing feature flag"

package-lock.json

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)