File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ pds_environment = "prod"
55batch_error_notifications_enabled = true
66create_mesh_processor = true
77has_sub_environment_scope = false
8+ dspp_kms_key_alias = " nhsd-dspp-core-prod-extended-attributes-gdp-key"
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ pds_environment = "prod"
55batch_error_notifications_enabled = true
66create_mesh_processor = true
77has_sub_environment_scope = false
8+ dspp_kms_key_alias = " nhsd-dspp-core-prod-extended-attributes-gdp-key"
Original file line number Diff line number Diff line change @@ -253,13 +253,44 @@ resource "aws_iam_policy" "filenameprocessor_dynamo_access_policy" {
253253 })
254254}
255255
256+ # Kms policy setup on filenameprocessor lambda for dps cross account bucket access
257+ resource "aws_iam_policy" "filenameprocessor_dps_extended_attribute_kms_policy" {
258+ name = " ${ local . short_prefix } -filenameproc-dps-kms-policy"
259+ description = " Allow Lambda to use DPS KMS key for SSE-KMS encrypted S3 bucket access"
260+
261+ policy = jsonencode ({
262+ Version = " 2012-10-17"
263+ Statement = [
264+ {
265+ Effect = " Allow" ,
266+ Action = [
267+ " kms:Decrypt" ,
268+ " kms:GenerateDataKey" ,
269+ " kms:DescribeKey"
270+ ],
271+ Resource = " arn:aws:kms:eu-west-2:${ var . dspp_core_account_id } :key/*" ,
272+ " Condition" = {
273+ " ForAnyValue:StringEquals" = {
274+ " kms:ResourceAliases" = " alias/${ var . dspp_kms_key_alias } "
275+ }
276+ }
277+ }
278+ ]
279+ })
280+ }
256281
257282# Attach the execution policy to the Lambda role
258283resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_exec_policy_attachment" {
259284 role = aws_iam_role. filenameprocessor_lambda_exec_role . name
260285 policy_arn = aws_iam_policy. filenameprocessor_lambda_exec_policy . arn
261286}
262287
288+ # Attach the dps kms policy to the Lambda role
289+ resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_dps_kms_ea_policy_attachment" {
290+ role = aws_iam_role. filenameprocessor_lambda_exec_role . name
291+ policy_arn = aws_iam_policy. filenameprocessor_dps_extended_attribute_kms_policy . arn
292+ }
293+
263294# Attach the SQS policy to the Lambda role
264295resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_sqs_policy_attachment" {
265296 role = aws_iam_role. filenameprocessor_lambda_exec_role . name
Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ variable "csoc_account_id" {
1010 default = " 693466633220"
1111}
1212
13+ variable "dspp_kms_key_alias" {
14+ description = " Alias name of the DPS KMS key allowed for SSE-KMS encryption"
15+ type = string
16+ default = " nhsd-dspp-core-ref-extended-attributes-gdp-key"
17+ }
18+
1319variable "create_mesh_processor" {
1420 default = false
1521}
You can’t perform that action at this time.
0 commit comments