diff --git a/infrastructure/terraform/components/dl/README.md b/infrastructure/terraform/components/dl/README.md index ac8f25b44..236108370 100644 --- a/infrastructure/terraform/components/dl/README.md +++ b/infrastructure/terraform/components/dl/README.md @@ -56,7 +56,7 @@ No requirements. | [lambda\_lambda\_apim\_refresh\_token](#module\_lambda\_lambda\_apim\_refresh\_token) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | | [mesh\_acknowledge](#module\_mesh\_acknowledge) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | | [mesh\_download](#module\_mesh\_download) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | -| [mesh\_poll](#module\_mesh\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | +| [mesh\_poll](#module\_mesh\_poll) | ../../modules/wrappers/lambda | n/a | | [move\_scanned\_files](#module\_move\_scanned\_files) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | | [pdm\_mock](#module\_pdm\_mock) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | | [pdm\_poll](#module\_pdm\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a | diff --git a/infrastructure/terraform/components/dl/module_lambda_mesh_poll.tf b/infrastructure/terraform/components/dl/module_lambda_mesh_poll.tf index 755e4fea8..7ee2c4f55 100644 --- a/infrastructure/terraform/components/dl/module_lambda_mesh_poll.tf +++ b/infrastructure/terraform/components/dl/module_lambda_mesh_poll.tf @@ -1,5 +1,5 @@ module "mesh_poll" { - source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip" + source = "../../modules/wrappers/lambda" function_name = "mesh-poll" description = "A lambda function for polling MESH inbox for new messages" diff --git a/infrastructure/terraform/modules/wrappers/README.md b/infrastructure/terraform/modules/wrappers/README.md new file mode 100644 index 000000000..df8c1f5c0 --- /dev/null +++ b/infrastructure/terraform/modules/wrappers/README.md @@ -0,0 +1,19 @@ + + + + +## Requirements + +No requirements. +## Inputs + +No inputs. +## Modules + +No modules. +## Outputs + +No outputs. + + + diff --git a/infrastructure/terraform/modules/wrappers/lambda/main.tf b/infrastructure/terraform/modules/wrappers/lambda/main.tf new file mode 100644 index 000000000..be7c032d1 --- /dev/null +++ b/infrastructure/terraform/modules/wrappers/lambda/main.tf @@ -0,0 +1,33 @@ +# Wrapper module for lambda - centralizes the source version +# To update the module version, change the source URL below +module "lambda" { + source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.30/terraform-lambda.zip" + + function_name = var.function_name + description = var.description + aws_account_id = var.aws_account_id + component = var.component + environment = var.environment + project = var.project + region = var.region + group = var.group + log_retention_in_days = var.log_retention_in_days + kms_key_arn = var.kms_key_arn + iam_policy_document = var.iam_policy_document + function_s3_bucket = var.function_s3_bucket + function_code_base_path = var.function_code_base_path + function_code_dir = var.function_code_dir + function_include_common = var.function_include_common + function_module_name = var.function_module_name + handler_function_name = var.handler_function_name + runtime = var.runtime + memory = var.memory + timeout = var.timeout + log_level = var.log_level + schedule = try(var.schedule, null) + force_lambda_code_deploy = var.force_lambda_code_deploy + enable_lambda_insights = var.enable_lambda_insights + log_destination_arn = var.log_destination_arn + log_subscription_role_arn = var.log_subscription_role_arn + lambda_env_vars = try(var.lambda_env_vars, {}) +} diff --git a/infrastructure/terraform/modules/wrappers/lambda/outputs.tf b/infrastructure/terraform/modules/wrappers/lambda/outputs.tf new file mode 100644 index 000000000..7face173d --- /dev/null +++ b/infrastructure/terraform/modules/wrappers/lambda/outputs.tf @@ -0,0 +1,12 @@ +# Outputs from lambda wrapper module +# These expose the outputs from the upstream nhs-notify-shared-modules lambda module + +output "function_arn" { + description = "ARN of the Lambda function" + value = module.lambda.function_arn +} + +output "function_name" { + description = "Name of the Lambda function" + value = module.lambda.function_name +} diff --git a/infrastructure/terraform/modules/wrappers/lambda/variables.tf b/infrastructure/terraform/modules/wrappers/lambda/variables.tf new file mode 100644 index 000000000..c5318e8a2 --- /dev/null +++ b/infrastructure/terraform/modules/wrappers/lambda/variables.tf @@ -0,0 +1,139 @@ +# Variables for lambda wrapper module +# These mirror the variables from the upstream nhs-notify-shared-modules lambda module + +variable "function_name" { + type = string + description = "The name of the Lambda function" +} + +variable "description" { + type = string + description = "Description of the Lambda function" +} + +variable "aws_account_id" { + type = string + description = "AWS Account ID" +} + +variable "component" { + type = string + description = "Component name" +} + +variable "environment" { + type = string + description = "Environment name" +} + +variable "project" { + type = string + description = "Project name" +} + +variable "region" { + type = string + description = "AWS Region" +} + +variable "group" { + type = string + description = "Group name" +} + +variable "log_retention_in_days" { + type = number + description = "CloudWatch log retention in days" +} + +variable "kms_key_arn" { + type = string + description = "KMS key ARN for encryption" +} + +variable "iam_policy_document" { + type = any + description = "IAM policy document for the Lambda execution role" +} + +variable "function_s3_bucket" { + type = string + description = "S3 bucket containing the Lambda function code" +} + +variable "function_code_base_path" { + type = string + description = "Base path for Lambda function code" +} + +variable "function_code_dir" { + type = string + description = "Directory containing the Lambda function code" +} + +variable "function_include_common" { + type = bool + description = "Whether to include common code" +} + +variable "function_module_name" { + type = string + description = "Module name for the function" +} + +variable "handler_function_name" { + type = string + description = "Handler function name" +} + +variable "runtime" { + type = string + description = "Lambda runtime (e.g., nodejs22.x, python3.12)" +} + +variable "memory" { + type = number + description = "Memory allocation for the Lambda function in MB" +} + +variable "timeout" { + type = number + description = "Timeout for the Lambda function in seconds" +} + +variable "log_level" { + type = string + description = "Log level for the Lambda function" +} + +variable "schedule" { + type = string + description = "CloudWatch Events schedule expression (optional)" + default = null +} + +variable "force_lambda_code_deploy" { + type = bool + description = "Force deployment of Lambda code" +} + +variable "enable_lambda_insights" { + type = bool + description = "Enable Lambda Insights" +} + +variable "log_destination_arn" { + type = string + description = "ARN of the log destination" +} + +variable "log_subscription_role_arn" { + type = string + description = "ARN of the role for log subscription" +} + +variable "lambda_env_vars" { + type = map(string) + description = "Environment variables for the Lambda function" + default = {} +}