Skip to content

Commit 55a919e

Browse files
committed
CCM-10294: merge
2 parents be0295f + 4f36f0f commit 55a919e

File tree

116 files changed

+2129
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2129
-1383
lines changed

infrastructure/terraform/components/acct/module_sandbox_kms.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,33 @@ data "aws_iam_policy_document" "kms" {
8585
]
8686
}
8787
}
88+
89+
statement {
90+
sid = "AllowEventBridgeAccessToLetterValidationQueue"
91+
effect = "Allow"
92+
93+
principals {
94+
type = "Service"
95+
identifiers = ["events.amazonaws.com"]
96+
}
97+
98+
actions = [
99+
"kms:GenerateDataKey*",
100+
"kms:Decrypt",
101+
]
102+
103+
resources = ["*"]
104+
105+
condition {
106+
test = "ArnLike"
107+
variable = "kms:EncryptionContext:aws:sqs:arn"
108+
values = ["arn:aws:sqs:${var.region}:${var.aws_account_id}:*-validate-letter-template-files-queue"]
109+
}
110+
111+
condition {
112+
test = "ArnLike"
113+
variable = "aws:SourceArn"
114+
values = ["arn:aws:events:${var.region}:${var.aws_account_id}:rule/*-quarantine-scan-passed-for-upload"]
115+
}
116+
}
88117
}

infrastructure/terraform/components/app/module_kms.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,37 @@ data "aws_iam_policy_document" "kms" {
106106
]
107107
}
108108
}
109+
110+
statement {
111+
sid = "AllowEventBridgeAccessToLetterValidationQueue"
112+
effect = "Allow"
113+
114+
principals {
115+
type = "Service"
116+
identifiers = ["events.amazonaws.com"]
117+
}
118+
119+
actions = [
120+
"kms:GenerateDataKey*",
121+
"kms:Decrypt",
122+
]
123+
124+
resources = ["*"]
125+
126+
condition {
127+
test = "ArnEquals"
128+
variable = "kms:EncryptionContext:aws:sqs:arn"
129+
values = [
130+
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${local.csi}-validate-letter-template-files-queue"
131+
]
132+
}
133+
134+
condition {
135+
test = "ArnEquals"
136+
variable = "aws:SourceArn"
137+
values = [
138+
"arn:aws:events:${var.region}:${var.aws_account_id}:rule/${local.csi}-api-quarantine-scan-passed-for-upload"
139+
]
140+
}
141+
}
109142
}

infrastructure/terraform/components/sandbox/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
| Name | Source | Version |
2929
|------|--------|---------|
3030
| <a name="module_backend_api"></a> [backend\_api](#module\_backend\_api) | ../../modules/backend-api | n/a |
31+
| <a name="module_cognito_triggers"></a> [cognito\_triggers](#module\_cognito\_triggers) | ../../modules/cognito-triggers | n/a |
3132
## Outputs
3233

3334
| Name | Description |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
resource "aws_cognito_user_pool" "sandbox" {
22
name = local.csi
3+
4+
lambda_config {
5+
pre_token_generation_config {
6+
lambda_arn = module.cognito_triggers.pre_token_generation_lambda_function_arn
7+
lambda_version = "V2_0"
8+
}
9+
}
10+
11+
schema {
12+
name = "sbx_client_id"
13+
attribute_data_type = "String"
14+
mutable = true
15+
required = false
16+
string_attribute_constraints {}
17+
}
318
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "cognito_triggers" {
2+
source = "../../modules/cognito-triggers"
3+
4+
aws_account_id = var.aws_account_id
5+
component = var.component
6+
environment = var.environment
7+
project = var.project
8+
region = var.region
9+
group = var.group
10+
11+
function_s3_bucket = local.acct.s3_buckets["artefacts"]["id"]
12+
kms_key_arn = data.aws_kms_key.sandbox.arn
13+
log_retention_in_days = var.log_retention_in_days
14+
user_pool_id = aws_cognito_user_pool.sandbox.id
15+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ 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 |
2019
| <a name="input_enable_proofing"></a> [enable\_proofing](#input\_enable\_proofing) | Enable proofing feature flag | `bool` | n/a | yes |
2120
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
2221
| <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 & 4 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 = [local.guardduty_source]
6+
source = ["aws.guardduty"]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [local.guardduty_resource]
8+
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]
@@ -21,11 +21,9 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_failed_for_proof
2121
resource "aws_cloudwatch_event_target" "quarantine_scan_failed_process_proof" {
2222
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_failed_for_proof.name
2323
arn = module.lambda_process_proof.function_arn
24-
role_arn = aws_iam_role.quarantine_scan_failed_for_proof.arn
2524
}
2625

2726
resource "aws_cloudwatch_event_target" "quarantine_scan_failed_delete_object_for_proof" {
2827
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_failed_for_proof.name
2928
arn = module.lambda_delete_failed_scanned_object.function_arn
30-
role_arn = aws_iam_role.quarantine_scan_failed_for_proof.arn
3129
}

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

Lines changed: 2 additions & 4 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 = [local.guardduty_source]
6+
source = ["aws.guardduty"]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [local.guardduty_resource]
8+
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]
@@ -21,11 +21,9 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_failed_for_uploa
2121
resource "aws_cloudwatch_event_target" "quarantine_scan_failed_set_file_status_for_upload" {
2222
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_failed_for_upload.name
2323
arn = module.lambda_set_file_virus_scan_status_for_upload.function_arn
24-
role_arn = aws_iam_role.quarantine_scan_failed_for_upload.arn
2524
}
2625

2726
resource "aws_cloudwatch_event_target" "quarantine_scan_failed_delete_object_for_upload" {
2827
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_failed_for_upload.name
2928
arn = module.lambda_delete_failed_scanned_object.function_arn
30-
role_arn = aws_iam_role.quarantine_scan_failed_for_upload.arn
3129
}

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

Lines changed: 2 additions & 3 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 = [local.guardduty_source]
6+
source = ["aws.guardduty"]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [local.guardduty_resource]
8+
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]
@@ -21,5 +21,4 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_passed_for_proof
2121
resource "aws_cloudwatch_event_target" "quarantine_scan_passed_process_proof" {
2222
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_passed_for_proof.name
2323
arn = module.lambda_process_proof.function_arn
24-
role_arn = aws_iam_role.quarantine_scan_passed_for_proof.arn
2524
}

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

Lines changed: 6 additions & 9 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 = [local.guardduty_source]
6+
source = ["aws.guardduty"]
77
detail-type = ["GuardDuty Malware Protection Object Scan Result"]
8-
resources = [local.guardduty_resource]
8+
resources = [aws_guardduty_malware_protection_plan.quarantine.arn]
99
detail = {
1010
s3ObjectDetails = {
1111
bucketName = [module.s3bucket_quarantine.id]
@@ -19,19 +19,16 @@ resource "aws_cloudwatch_event_rule" "guardduty_quarantine_scan_passed_for_uploa
1919
}
2020

2121
resource "aws_cloudwatch_event_target" "quarantine_scan_passed_set_file_status_for_upload" {
22-
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_passed_for_upload.name
23-
arn = module.lambda_set_file_virus_scan_status_for_upload.function_arn
24-
role_arn = aws_iam_role.quarantine_scan_passed_for_upload.arn
22+
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_passed_for_upload.name
23+
arn = module.lambda_set_file_virus_scan_status_for_upload.function_arn
2524
}
2625

2726
resource "aws_cloudwatch_event_target" "quarantine_scan_passed_copy_object_for_upload" {
28-
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_passed_for_upload.name
29-
arn = module.lambda_copy_scanned_object_to_internal.function_arn
30-
role_arn = aws_iam_role.quarantine_scan_passed_for_upload.arn
27+
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_passed_for_upload.name
28+
arn = module.lambda_copy_scanned_object_to_internal.function_arn
3129
}
3230

3331
resource "aws_cloudwatch_event_target" "quarantine_scan_passed_validate_files" {
3432
rule = aws_cloudwatch_event_rule.guardduty_quarantine_scan_passed_for_upload.name
3533
arn = module.sqs_validate_letter_template_files.sqs_queue_arn
36-
role_arn = aws_iam_role.quarantine_scan_passed_for_upload.arn
3734
}

0 commit comments

Comments
 (0)