Skip to content

Commit c54d91d

Browse files
authored
Merge branch 'main' into feature/CCM-12952-Publish-MI-Events
2 parents 9743c03 + 92573c0 commit c54d91d

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
resource "aws_lambda_event_source_mapping" "letter_updates_transformer_kinesis" {
2-
event_source_arn = aws_kinesis_stream.letter_change_stream.arn
3-
function_name = module.letter_updates_transformer.function_arn
4-
starting_position = "LATEST"
5-
batch_size = 10
6-
maximum_batching_window_in_seconds = 1
2+
event_source_arn = aws_kinesis_stream.letter_change_stream.arn
3+
function_name = module.letter_updates_transformer.function_arn
4+
starting_position = "LATEST"
5+
batch_size = 10
6+
maximum_batching_window_in_seconds = 1
77

88
depends_on = [
9-
module.letter_updates_transformer # ensures updates transformer exists
9+
module.letter_updates_transformer # ensures updates transformer exists
1010
]
1111
}

infrastructure/terraform/components/api/locals.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ locals {
2828
APIM_CORRELATION_HEADER = "nhsd-correlation-id",
2929
DOWNLOAD_URL_TTL_SECONDS = 60
3030
}
31+
32+
core_pdf_bucket_arn = "arn:aws:s3:::comms-${var.core_account_id}-eu-west-2-${var.core_environment}-api-stg-pdf-pipeline"
33+
core_s3_kms_key_alias_name = "alias/comms-${var.core_environment}-api-s3"
3134
}

infrastructure/terraform/components/api/module_lambda_get_letter_data.tf

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,43 @@ data "aws_iam_policy_document" "get_letter_data_lambda" {
6868
]
6969
}
7070

71+
statement {
72+
sid = "S3ListBucketForPresign"
73+
actions = [
74+
"s3:ListBucket"
75+
]
76+
resources = [
77+
module.s3bucket_test_letters.arn,
78+
local.core_pdf_bucket_arn
79+
]
80+
}
81+
7182
statement {
7283
sid = "S3GetObjectForPresign"
7384
actions = [
7485
"s3:GetObject",
75-
"s3:ListBucket"] # allows 404 response instead of 403 if object missing
76-
resources = ["${module.s3bucket_test_letters.arn}/*"]
86+
"s3:PutObject",
87+
] # allows 404 response instead of 403 if object missing
88+
resources = [
89+
"${module.s3bucket_test_letters.arn}/*",
90+
"${local.core_pdf_bucket_arn}/*",
91+
]
92+
}
93+
94+
statement {
95+
sid = "KMSForCoreS3Access"
96+
actions = [
97+
"kms:Decrypt",
98+
"kms:GenerateDataKey",
99+
"kms:DescribeKey"
100+
]
101+
resources = [
102+
"arn:aws:kms:${var.region}:${var.core_account_id}:key/*"
103+
]
104+
condition {
105+
test = "ForAnyValue:StringEquals"
106+
variable = "kms:ResourceAliases"
107+
values = [local.core_s3_kms_key_alias_name]
108+
}
77109
}
78110
}

infrastructure/terraform/components/api/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,15 @@ variable "eventpub_control_plane_bus_arn" {
134134
description = "ARN of the EventBridge control plane bus for eventpub"
135135
default = ""
136136
}
137+
138+
variable "core_account_id" {
139+
type = string
140+
description = "AWS Account ID for Core"
141+
default = "000000000000"
142+
}
143+
144+
variable "core_environment" {
145+
type = string
146+
description = "Environment of Core"
147+
default = "prod"
148+
}

0 commit comments

Comments
 (0)