Skip to content

Commit 7933b3d

Browse files
committed
CCM-14480: Centralize terraform module source configuration
1 parent 02730c2 commit 7933b3d

6 files changed

Lines changed: 220 additions & 2 deletions

File tree

infrastructure/terraform/components/dl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ No requirements.
5656
| <a name="module_lambda_lambda_apim_refresh_token"></a> [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 |
5757
| <a name="module_mesh_acknowledge"></a> [mesh\_acknowledge](#module\_mesh\_acknowledge) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
5858
| <a name="module_mesh_download"></a> [mesh\_download](#module\_mesh\_download) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
59-
| <a name="module_mesh_poll"></a> [mesh\_poll](#module\_mesh\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
59+
| <a name="module_mesh_poll"></a> [mesh\_poll](#module\_mesh\_poll) | ../../../modules/wrappers/lambda | n/a |
6060
| <a name="module_move_scanned_files"></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 |
6161
| <a name="module_pdm_mock"></a> [pdm\_mock](#module\_pdm\_mock) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
6262
| <a name="module_pdm_poll"></a> [pdm\_poll](#module\_pdm\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |

infrastructure/terraform/components/dl/module_lambda_mesh_poll.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "mesh_poll" {
2-
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip"
2+
source = "../../../modules/wrappers/lambda"
33

44
function_name = "mesh-poll"
55
description = "A lambda function for polling MESH inbox for new messages"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
<!-- markdownlint-disable -->
3+
<!-- vale off -->
4+
5+
## Requirements
6+
7+
No requirements.
8+
## Inputs
9+
10+
No inputs.
11+
## Modules
12+
13+
No modules.
14+
## Outputs
15+
16+
No outputs.
17+
<!-- vale on -->
18+
<!-- markdownlint-enable -->
19+
<!-- END_TF_DOCS -->
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Wrapper module for lambda - centralizes the source version
2+
# To update the module version, change the source URL below
3+
module "lambda" {
4+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.30/terraform-lambda.zip"
5+
6+
function_name = var.function_name
7+
description = var.description
8+
aws_account_id = var.aws_account_id
9+
component = var.component
10+
environment = var.environment
11+
project = var.project
12+
region = var.region
13+
group = var.group
14+
log_retention_in_days = var.log_retention_in_days
15+
kms_key_arn = var.kms_key_arn
16+
iam_policy_document = var.iam_policy_document
17+
function_s3_bucket = var.function_s3_bucket
18+
function_code_base_path = var.function_code_base_path
19+
function_code_dir = var.function_code_dir
20+
function_include_common = var.function_include_common
21+
function_module_name = var.function_module_name
22+
handler_function_name = var.handler_function_name
23+
runtime = var.runtime
24+
memory = var.memory
25+
timeout = var.timeout
26+
log_level = var.log_level
27+
schedule = try(var.schedule, null)
28+
force_lambda_code_deploy = var.force_lambda_code_deploy
29+
enable_lambda_insights = var.enable_lambda_insights
30+
log_destination_arn = var.log_destination_arn
31+
log_subscription_role_arn = var.log_subscription_role_arn
32+
lambda_env_vars = try(var.lambda_env_vars, {})
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Outputs from lambda wrapper module
2+
# These expose the outputs from the upstream nhs-notify-shared-modules lambda module
3+
4+
output "function_arn" {
5+
description = "ARN of the Lambda function"
6+
value = module.lambda.function_arn
7+
}
8+
9+
output "function_name" {
10+
description = "Name of the Lambda function"
11+
value = module.lambda.function_name
12+
}
13+
14+
output "role_arn" {
15+
description = "ARN of the Lambda execution role"
16+
value = module.lambda.role_arn
17+
}
18+
19+
output "role_name" {
20+
description = "Name of the Lambda execution role"
21+
value = module.lambda.role_name
22+
}
23+
24+
output "log_group_name" {
25+
description = "Name of the CloudWatch log group"
26+
value = module.lambda.log_group_name
27+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Variables for lambda wrapper module
2+
# These mirror the variables from the upstream nhs-notify-shared-modules lambda module
3+
4+
variable "function_name" {
5+
type = string
6+
description = "The name of the Lambda function"
7+
}
8+
9+
variable "description" {
10+
type = string
11+
description = "Description of the Lambda function"
12+
}
13+
14+
variable "aws_account_id" {
15+
type = string
16+
description = "AWS Account ID"
17+
}
18+
19+
variable "component" {
20+
type = string
21+
description = "Component name"
22+
}
23+
24+
variable "environment" {
25+
type = string
26+
description = "Environment name"
27+
}
28+
29+
variable "project" {
30+
type = string
31+
description = "Project name"
32+
}
33+
34+
variable "region" {
35+
type = string
36+
description = "AWS Region"
37+
}
38+
39+
variable "group" {
40+
type = string
41+
description = "Group name"
42+
}
43+
44+
variable "log_retention_in_days" {
45+
type = number
46+
description = "CloudWatch log retention in days"
47+
}
48+
49+
variable "kms_key_arn" {
50+
type = string
51+
description = "KMS key ARN for encryption"
52+
}
53+
54+
variable "iam_policy_document" {
55+
type = any
56+
description = "IAM policy document for the Lambda execution role"
57+
}
58+
59+
variable "function_s3_bucket" {
60+
type = string
61+
description = "S3 bucket containing the Lambda function code"
62+
}
63+
64+
variable "function_code_base_path" {
65+
type = string
66+
description = "Base path for Lambda function code"
67+
}
68+
69+
variable "function_code_dir" {
70+
type = string
71+
description = "Directory containing the Lambda function code"
72+
}
73+
74+
variable "function_include_common" {
75+
type = bool
76+
description = "Whether to include common code"
77+
}
78+
79+
variable "function_module_name" {
80+
type = string
81+
description = "Module name for the function"
82+
}
83+
84+
variable "handler_function_name" {
85+
type = string
86+
description = "Handler function name"
87+
}
88+
89+
variable "runtime" {
90+
type = string
91+
description = "Lambda runtime (e.g., nodejs22.x, python3.12)"
92+
}
93+
94+
variable "memory" {
95+
type = number
96+
description = "Memory allocation for the Lambda function in MB"
97+
}
98+
99+
variable "timeout" {
100+
type = number
101+
description = "Timeout for the Lambda function in seconds"
102+
}
103+
104+
variable "log_level" {
105+
type = string
106+
description = "Log level for the Lambda function"
107+
}
108+
109+
variable "schedule" {
110+
type = string
111+
description = "CloudWatch Events schedule expression (optional)"
112+
default = null
113+
}
114+
115+
variable "force_lambda_code_deploy" {
116+
type = bool
117+
description = "Force deployment of Lambda code"
118+
}
119+
120+
variable "enable_lambda_insights" {
121+
type = bool
122+
description = "Enable Lambda Insights"
123+
}
124+
125+
variable "log_destination_arn" {
126+
type = string
127+
description = "ARN of the log destination"
128+
}
129+
130+
variable "log_subscription_role_arn" {
131+
type = string
132+
description = "ARN of the role for log subscription"
133+
}
134+
135+
variable "lambda_env_vars" {
136+
type = map(string)
137+
description = "Environment variables for the Lambda function"
138+
default = {}
139+
}

0 commit comments

Comments
 (0)