Skip to content

Commit 571b5f1

Browse files
committed
CCM-10048: do not deploy GuardDuty
1 parent b9d0b51 commit 571b5f1

14 files changed

+87
-96
lines changed

infrastructure/terraform/components/sandbox/outputs.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ output "download_bucket_name" {
1414
value = module.backend_api.download_bucket_name
1515
}
1616

17-
output "guardduty_quarantine_arn" {
18-
value = module.backend_api.guardduty_quarantine_arn
19-
}
20-
2117
output "internal_bucket_name" {
2218
value = module.backend_api.internal_bucket_name
2319
}

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 = compact(["aws.guardduty", var.test_environment_mock_guardduty_event_source])
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 = compact(["aws.guardduty", var.test_environment_mock_guardduty_event_source])
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 = compact(["aws.guardduty", var.test_environment_mock_guardduty_event_source])
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 = compact(["aws.guardduty", var.test_environment_mock_guardduty_event_source])
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
@@ -61,4 +61,8 @@ locals {
6161
][0], "")
6262

6363
sftp_environment = "${var.group}-${var.environment}-${var.component}"
64+
65+
guardduty_source = var.enable_guardduty ? "aws.guardduty" : "test.guardduty"
66+
67+
guardduty_resource = var.enable_guardduty ? aws_guardduty_malware_protection_plan.quarantine[0].arn : "test:guardduty"
6468
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ output "download_bucket_regional_domain_name" {
1010
value = module.s3bucket_download.bucket_regional_domain_name
1111
}
1212

13-
output "guardduty_quarantine_arn" {
14-
value = aws_guardduty_malware_protection_plan.quarantine.arn
15-
}
16-
1713
output "internal_bucket_name" {
1814
value = module.s3bucket_internal.id
1915
}

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 = false
78+
}
79+
7480
variable "enable_proofing" {
7581
type = bool
7682
description = "Enable proofing feature flag"

run-e2e.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ print_error() {
2121
echo -e "${RED}[ERROR]${NC} $1"
2222
}
2323

24-
RANDOM_DIGITS=0056
24+
RANDOM_DIGITS=0082
2525
ENVIRONMENT_NAME="${RANDOM_DIGITS}flaky"
2626
TOTAL_RUNS=1
2727
export CI=1
@@ -64,14 +64,31 @@ for i in $(seq 1 $TOTAL_RUNS); do
6464
cp -r tests/test-team/playwright-report/* "$RUN_DIR/" 2>/dev/null || true
6565
fi
6666

67-
# Destory environment
68-
print_status "Destorying $ENVIRONMENT_NAME env... "
69-
if ./scripts/destroy_backend_sandbox.sh "$ENVIRONMENT_NAME"; then
70-
print_status "Environment destroyed successfully"
71-
else
72-
print_warning "Could not automagically destroy environment. You may need to clean up manually."
73-
print_warning "Environment name: $ENVIRONMENT_NAME"
74-
fi
67+
echo
68+
while true; do
69+
read -p "Do you want to destroy the environment '$ENVIRONMENT_NAME'? [Y/n]: " choice
70+
71+
case $choice in
72+
[Yy]* | "" ) # Default to Yes if user just presses Enter
73+
print_status "Destorying environment '$ENVIRONMENT_NAME'..."
74+
if ./scripts/destroy_backend_sandbox.sh "$ENVIRONMENT_NAME"; then
75+
print_status "Environment destroyed successfully"
76+
else
77+
print_warning "Could not automaically destroy environment. You may need to clean up manually."
78+
print_warning "Environment name: $ENVIRONMENT_NAME"
79+
fi
80+
break
81+
;;
82+
[Nn]* )
83+
print_warning "Environment '$ENVIRONMENT_NAME' left running"
84+
print_status "Remember to clean it up later to avoid unnecessary costs"
85+
break
86+
;;
87+
* )
88+
echo "Please answer Y (yes) or n (no)"
89+
;;
90+
esac
91+
done
7592
done
7693

7794
print_status "Script completed"

0 commit comments

Comments
 (0)