Skip to content

Commit 052601a

Browse files
committed
add kms permission unto filenameprocessor lambda
1 parent 6566cc3 commit 052601a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

infrastructure/instance/file_name_processor.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,39 @@ 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_account_id}:key/*"
272+
}
273+
]
274+
})
275+
}
256276

257277
# Attach the execution policy to the Lambda role
258278
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_exec_policy_attachment" {
259279
role = aws_iam_role.filenameprocessor_lambda_exec_role.name
260280
policy_arn = aws_iam_policy.filenameprocessor_lambda_exec_policy.arn
261281
}
262282

283+
#Attach the dps kms policy to the Lambda role
284+
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_dps_kms_ea_policy_attachment" {
285+
role = aws_iam_role.filenameprocessor_lambda_exec_role.name
286+
policy_arn = aws_iam_policy.filenameprocessor_dps_extended_attribute_kms_policy
287+
}
288+
263289
# Attach the SQS policy to the Lambda role
264290
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_sqs_policy_attachment" {
265291
role = aws_iam_role.filenameprocessor_lambda_exec_role.name

0 commit comments

Comments
 (0)