|
| 1 | +module "print_status_handler" { |
| 2 | + source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip" |
| 3 | + |
| 4 | + function_name = "print-status-handler" |
| 5 | + description = "A function for processing letter printing statuses " |
| 6 | + |
| 7 | + aws_account_id = var.aws_account_id |
| 8 | + component = local.component |
| 9 | + environment = var.environment |
| 10 | + project = var.project |
| 11 | + region = var.region |
| 12 | + group = var.group |
| 13 | + |
| 14 | + log_retention_in_days = var.log_retention_in_days |
| 15 | + kms_key_arn = module.kms.key_arn |
| 16 | + |
| 17 | + iam_policy_document = { |
| 18 | + body = data.aws_iam_policy_document.print_status_handler.json |
| 19 | + } |
| 20 | + |
| 21 | + function_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"] |
| 22 | + function_code_base_path = local.aws_lambda_functions_dir_path |
| 23 | + function_code_dir = "print-status-handler/dist" |
| 24 | + function_include_common = true |
| 25 | + handler_function_name = "handler" |
| 26 | + runtime = "nodejs22.x" |
| 27 | + memory = 128 |
| 28 | + timeout = 60 |
| 29 | + log_level = var.log_level |
| 30 | + |
| 31 | + force_lambda_code_deploy = var.force_lambda_code_deploy |
| 32 | + enable_lambda_insights = false |
| 33 | + |
| 34 | + log_destination_arn = local.log_destination_arn |
| 35 | + log_subscription_role_arn = local.acct.log_subscription_role_arn |
| 36 | + |
| 37 | + lambda_env_vars = { |
| 38 | + "EVENT_PUBLISHER_EVENT_BUS_ARN" = aws_cloudwatch_event_bus.main.arn |
| 39 | + "EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +data "aws_iam_policy_document" "print_status_handler" { |
| 44 | + statement { |
| 45 | + sid = "PutEvents" |
| 46 | + effect = "Allow" |
| 47 | + |
| 48 | + actions = [ |
| 49 | + "events:PutEvents", |
| 50 | + ] |
| 51 | + |
| 52 | + resources = [ |
| 53 | + aws_cloudwatch_event_bus.main.arn, |
| 54 | + ] |
| 55 | + } |
| 56 | + |
| 57 | + statement { |
| 58 | + sid = "SQSPermissionsDLQs" |
| 59 | + effect = "Allow" |
| 60 | + |
| 61 | + actions = [ |
| 62 | + "sqs:SendMessage", |
| 63 | + "sqs:SendMessageBatch", |
| 64 | + ] |
| 65 | + |
| 66 | + resources = [ |
| 67 | + module.sqs_event_publisher_errors.sqs_queue_arn, |
| 68 | + ] |
| 69 | + } |
| 70 | + |
| 71 | + statement { |
| 72 | + sid = "SQSPermissionsPrintStatusHandlerQueue" |
| 73 | + effect = "Allow" |
| 74 | + |
| 75 | + actions = [ |
| 76 | + "sqs:ReceiveMessage", |
| 77 | + "sqs:DeleteMessage", |
| 78 | + "sqs:GetQueueAttributes", |
| 79 | + "sqs:GetQueueUrl", |
| 80 | + ] |
| 81 | + |
| 82 | + resources = [ |
| 83 | + module.sqs_print_status_handler.sqs_queue_arn, |
| 84 | + ] |
| 85 | + } |
| 86 | +} |
0 commit comments