Skip to content

Commit 1144590

Browse files
CCM-12875: Package renaming and terraform changes
1 parent ca916a9 commit 1144590

22 files changed

+148
-118
lines changed

infrastructure/terraform/components/dl/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ No requirements.
2626
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
2727
| <a name="input_mesh_poll_schedule"></a> [mesh\_poll\_schedule](#input\_mesh\_poll\_schedule) | Schedule to poll MESH for messages | `string` | `"cron(0,30 8-16 ? * MON-FRI *)"` | no |
2828
| <a name="input_parent_acct_environment"></a> [parent\_acct\_environment](#input\_parent\_acct\_environment) | Name of the environment responsible for the acct resources used, affects things like DNS zone. Useful for named dev environments | `string` | `"main"` | no |
29-
| <a name="input_pdm_access_token_ssm_path"></a> [pdm\_access\_token\_ssm\_path](#input\_pdm\_access\_token\_ssm\_path) | SSM Parameter path for the PDM API access token | `string` | `"/digital-letters/pdm/access-token"` | no |
3029
| <a name="input_pdm_mock_access_token"></a> [pdm\_mock\_access\_token](#input\_pdm\_mock\_access\_token) | Mock access token for PDM API authentication (used in local/dev environments) | `string` | `"mock-pdm-token"` | no |
31-
| <a name="input_pdm_use_non_mock_token"></a> [pdm\_use\_non\_mock\_token](#input\_pdm\_use\_non\_mock\_token) | Whether to use the SSM parameter token instead of the mock token | `bool` | `false` | no |
30+
| <a name="input_pdm_use_non_mock_token"></a> [pdm\_use\_non\_mock\_token](#input\_pdm\_use\_non\_mock\_token) | Whether to use the shared APIM access token from SSM (/component/environment/apim/access\_token) instead of the mock token | `bool` | `false` | no |
3231
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
3332
| <a name="input_queue_batch_size"></a> [queue\_batch\_size](#input\_queue\_batch\_size) | maximum number of queue items to process | `number` | `10` | no |
3433
| <a name="input_queue_batch_window_seconds"></a> [queue\_batch\_window\_seconds](#input\_queue\_batch\_window\_seconds) | maximum time in seconds between processing events | `number` | `10` | no |
@@ -43,7 +42,7 @@ No requirements.
4342
| <a name="module_lambda_apim_key_generation"></a> [lambda\_apim\_key\_generation](#module\_lambda\_apim\_key\_generation) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
4443
| <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.24/terraform-lambda.zip | n/a |
4544
| <a name="module_mesh_poll"></a> [mesh\_poll](#module\_mesh\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
46-
| <a name="module_pdm_mock_api"></a> [pdm\_mock\_api](#module\_pdm\_mock\_api) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
45+
| <a name="module_pdm_mock_lambda"></a> [pdm\_mock\_lambda](#module\_pdm\_mock\_lambda) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
4746
| <a name="module_s3bucket_cf_logs"></a> [s3bucket\_cf\_logs](#module\_s3bucket\_cf\_logs) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-s3bucket.zip | n/a |
4847
| <a name="module_s3bucket_letters"></a> [s3bucket\_letters](#module\_s3bucket\_letters) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-s3bucket.zip | n/a |
4948
| <a name="module_s3bucket_static_assets"></a> [s3bucket\_static\_assets](#module\_s3bucket\_static\_assets) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-s3bucket.zip | n/a |
@@ -58,8 +57,8 @@ No requirements.
5857
| Name | Description |
5958
|------|-------------|
6059
| <a name="output_deployment"></a> [deployment](#output\_deployment) | Deployment details used for post-deployment scripts |
61-
| <a name="output_pdm_mock_api_endpoint"></a> [pdm\_mock\_api\_endpoint](#output\_pdm\_mock\_api\_endpoint) | The base URL of the PDM Mock API |
62-
| <a name="output_pdm_mock_api_id"></a> [pdm\_mock\_api\_id](#output\_pdm\_mock\_api\_id) | The ID of the PDM Mock API Gateway |
60+
| <a name="output_pdm_mock_lambda_endpoint"></a> [pdm\_mock\_lambda\_endpoint](#output\_pdm\_mock\_lambda\_endpoint) | The base URL of the PDM Mock Lambda |
61+
| <a name="output_pdm_mock_lambda_id"></a> [pdm\_mock\_lambda\_id](#output\_pdm\_mock\_lambda\_id) | The ID of the PDM Mock Lambda API Gateway |
6362
<!-- vale on -->
6463
<!-- markdownlint-enable -->
6564
<!-- END_TF_DOCS -->

infrastructure/terraform/components/dl/apigateway_pdm_mock.tf

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
resource "aws_api_gateway_rest_api" "pdm_mock" {
2-
name = "${var.project}-${var.environment}-pdm-mock-api"
2+
name = "${var.project}-${var.environment}-pdm-mock-lambda"
33
description = "PDM Mock API for testing integration with Patient Data Manager"
44

55
endpoint_configuration {
66
types = ["REGIONAL"]
77
}
88

99
tags = {
10-
Name = "${var.project}-${var.environment}-pdm-mock-api"
10+
Name = "${var.project}-${var.environment}-pdm-mock-lambda"
1111
Project = var.project
1212
Environment = var.environment
1313
Component = local.component
@@ -58,7 +58,7 @@ resource "aws_api_gateway_integration" "create_document_reference" {
5858

5959
integration_http_method = "POST"
6060
type = "AWS_PROXY"
61-
uri = module.pdm_mock_api.function_invoke_arn
61+
uri = module.pdm_mock_lambda.function_invoke_arn
6262
}
6363

6464
resource "aws_api_gateway_method" "get_document_reference" {
@@ -75,13 +75,13 @@ resource "aws_api_gateway_integration" "get_document_reference" {
7575

7676
integration_http_method = "POST"
7777
type = "AWS_PROXY"
78-
uri = module.pdm_mock_api.function_invoke_arn
78+
uri = module.pdm_mock_lambda.function_invoke_arn
7979
}
8080

81-
resource "aws_lambda_permission" "pdm_mock_api_gateway" {
81+
resource "aws_lambda_permission" "pdm_mock_lambda_gateway" {
8282
statement_id = "AllowAPIGatewayInvoke"
8383
action = "lambda:InvokeFunction"
84-
function_name = module.pdm_mock_api.function_name
84+
function_name = module.pdm_mock_lambda.function_name
8585
principal = "apigateway.amazonaws.com"
8686

8787
source_arn = "${aws_api_gateway_rest_api.pdm_mock.execution_arn}/*/*"
@@ -121,7 +121,7 @@ resource "aws_api_gateway_stage" "pdm_mock" {
121121
xray_tracing_enabled = true
122122

123123
access_log_settings {
124-
destination_arn = aws_cloudwatch_log_group.pdm_mock_api_gateway.arn
124+
destination_arn = aws_cloudwatch_log_group.pdm_mock_lambda_gateway.arn
125125
format = jsonencode({
126126
requestId = "$context.requestId"
127127
ip = "$context.identity.sourceIp"
@@ -137,30 +137,32 @@ resource "aws_api_gateway_stage" "pdm_mock" {
137137
}
138138

139139
tags = {
140-
Name = "${var.project}-${var.environment}-pdm-mock-api-stage"
140+
Name = "${var.project}-${var.environment}-pdm-mock-lambda-stage"
141141
Project = var.project
142142
Environment = var.environment
143143
Component = local.component
144144
}
145145
}
146-
resource "aws_cloudwatch_log_group" "pdm_mock_api_gateway" {
147-
name = "/aws/apigateway/${var.project}-${var.environment}-pdm-mock-api"
146+
147+
resource "aws_cloudwatch_log_group" "pdm_mock_lambda_gateway" {
148+
name = "/aws/apigateway/${var.project}-${var.environment}-pdm-mock-lambda"
148149
retention_in_days = var.log_retention_in_days
149150
kms_key_id = module.kms.key_arn
150151

151152
tags = {
152-
Name = "${var.project}-${var.environment}-pdm-mock-api-logs"
153+
Name = "${var.project}-${var.environment}-pdm-mock-lambda-logs"
153154
Project = var.project
154155
Environment = var.environment
155156
Component = local.component
156157
}
157158
}
158-
output "pdm_mock_api_endpoint" {
159-
description = "The base URL of the PDM Mock API"
159+
160+
output "pdm_mock_lambda_endpoint" {
161+
description = "The base URL of the PDM Mock Lambda"
160162
value = aws_api_gateway_stage.pdm_mock.invoke_url
161163
}
162164

163-
output "pdm_mock_api_id" {
164-
description = "The ID of the PDM Mock API Gateway"
165+
output "pdm_mock_lambda_id" {
166+
description = "The ID of the PDM Mock Lambda API Gateway"
165167
value = aws_api_gateway_rest_api.pdm_mock.id
166168
}

infrastructure/terraform/components/dl/module_lambda_pdm_mock_api.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module "pdm_mock_api" {
1+
module "pdm_mock_lambda" {
22
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip"
33

4-
function_name = "pdm-mock-api"
4+
function_name = "pdm-mock-lambda"
55
description = "A lambda function for mocking PDM (Patient Data Manager) API endpoints"
66

77
aws_account_id = var.aws_account_id
@@ -15,12 +15,12 @@ module "pdm_mock_api" {
1515
kms_key_arn = module.kms.key_arn
1616

1717
iam_policy_document = {
18-
body = data.aws_iam_policy_document.pdm_mock_api_lambda.json
18+
body = data.aws_iam_policy_document.pdm_mock_lambda.json
1919
}
2020

2121
function_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"]
2222
function_code_base_path = local.aws_lambda_functions_dir_path
23-
function_code_dir = "pdm-mock-api/dist"
23+
function_code_dir = "pdm-mock-lambda/dist"
2424
function_include_common = true
2525
handler_function_name = "handler"
2626
runtime = "nodejs22.x"
@@ -37,12 +37,12 @@ module "pdm_mock_api" {
3737

3838
lambda_env_vars = {
3939
MOCK_ACCESS_TOKEN = var.pdm_mock_access_token
40-
ACCESS_TOKEN_SSM_PATH = var.pdm_access_token_ssm_path
40+
ACCESS_TOKEN_SSM_PATH = local.apim_access_token_ssm_parameter_name
4141
USE_NON_MOCK_TOKEN = var.pdm_use_non_mock_token
4242
}
4343
}
4444

45-
data "aws_iam_policy_document" "pdm_mock_api_lambda" {
45+
data "aws_iam_policy_document" "pdm_mock_lambda" {
4646
statement {
4747
sid = "KMSPermissions"
4848
effect = "Allow"
@@ -67,7 +67,7 @@ data "aws_iam_policy_document" "pdm_mock_api_lambda" {
6767
]
6868

6969
resources = [
70-
"arn:aws:ssm:${var.region}:${var.aws_account_id}:parameter${var.pdm_access_token_ssm_path}",
70+
"arn:aws:ssm:${var.region}:${var.aws_account_id}:parameter${local.apim_access_token_ssm_parameter_name}",
7171
]
7272
}
7373
}

infrastructure/terraform/components/dl/variables.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,9 @@ variable "pdm_mock_access_token" {
122122
default = "mock-pdm-token"
123123
}
124124

125-
variable "pdm_access_token_ssm_path" {
126-
type = string
127-
description = "SSM Parameter path for the PDM API access token"
128-
default = "/digital-letters/pdm/access-token"
129-
}
130-
131125
variable "pdm_use_non_mock_token" {
132126
type = bool
133-
description = "Whether to use the SSM parameter token instead of the mock token"
127+
description = "Whether to use the shared APIM access token from SSM (/component/environment/apim/access_token) instead of the mock token"
134128
default = false
135129
}
136130

lambdas/pdm-mock-api/jest.config.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# PDM Mock API Lambda
1+
# PDM Mock Lambda
22

33
This Lambda function provides a mock implementation of the PDM (Patient Data Manager) API for testing purposes. It allows the NHS Notify Digital Letters system to test integration with PDM without requiring access to the actual PDM service.
44

55
## Overview
66

7-
The PDM Mock API simulates two key PDM endpoints following the FHIR R4 DocumentReference structure:
7+
The PDM Mock Lambda simulates two key PDM endpoints following the FHIR R4 DocumentReference structure:
88

99
- **POST /patient-data-manager/FHIR/R4/DocumentReference** - Create a new DocumentReference
1010
- **GET /patient-data-manager/FHIR/R4/DocumentReference/{id}** - Retrieve a specific DocumentReference
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { baseJestConfig } from '../../jest.config.base';
2+
3+
const config = baseJestConfig;
4+
5+
config.coverageThreshold = {
6+
global: {
7+
branches: 100,
8+
functions: 100,
9+
lines: 90,
10+
statements: -10,
11+
},
12+
};
13+
14+
export default config;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"jest-mock-extended": "^3.0.7",
1515
"typescript": "^5.9.3"
1616
},
17-
"name": "nhs-notify-digital-letters-pdm-mock-api",
17+
"name": "nhs-notify-digital-letters-pdm-mock-lambda",
1818
"private": true,
1919
"scripts": {
2020
"lambda-build": "rm -rf dist && npx esbuild --bundle --minify --sourcemap --target=es2020 --platform=node --loader:.node=file --entry-names=[name] --outdir=dist src/index.ts",

lambdas/pdm-mock-api/src/__tests__/authenticator.test.ts renamed to lambdas/pdm-mock-lambda/src/__tests__/authenticator.test.ts

File renamed without changes.

0 commit comments

Comments
 (0)