Skip to content

Commit 46ab15a

Browse files
committed
use alias and add arn for filenameproc lambda
1 parent ec55d70 commit 46ab15a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

infrastructure/instance/file_name_processor.tf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ locals {
1111
dps_bucket_arn_for_extended_attribute = [
1212
"arn:aws:s3:::${local.dps_bucket_name_for_extended_attribute}/*"
1313
]
14+
15+
dps_kms_key_alias = (
16+
var.environment == "prod"
17+
? "nhsd-dspp-core-prod-extended-attributes-gdp-key"
18+
: "nhsd-dspp-core-ref-extended-attributes-gdp-key"
19+
)
1420
}
1521

1622

@@ -268,7 +274,12 @@ resource "aws_iam_policy" "filenameprocessor_dps_extended_attribute_kms_policy"
268274
"kms:GenerateDataKey",
269275
"kms:DescribeKey"
270276
],
271-
Resource = "arn:aws:kms:eu-west-2:${var.dspp_core_account_id}:key/*"
277+
Resource = "arn:aws:kms:eu-west-2:${var.dspp_core_account_id}:key/*",
278+
"Condition" = {
279+
"ForAnyValue:StringLike" = {
280+
"kms:ResourceAliases" = "alias/${local.dps_kms_key_alias}"
281+
}
282+
}
272283
}
273284
]
274285
})
@@ -283,7 +294,7 @@ resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_exec_policy_
283294
#Attach the dps kms policy to the Lambda role
284295
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_dps_kms_ea_policy_attachment" {
285296
role = aws_iam_role.filenameprocessor_lambda_exec_role.name
286-
policy_arn = aws_iam_policy.filenameprocessor_dps_extended_attribute_kms_policy
297+
policy_arn = aws_iam_policy.filenameprocessor_dps_extended_attribute_kms_policy.arn
287298
}
288299

289300
# Attach the SQS policy to the Lambda role

0 commit comments

Comments
 (0)