Skip to content

Commit c24b7a7

Browse files
committed
Merge branch 'main' into feature/test-data-variations
2 parents 2f763fa + 2518a47 commit c24b7a7

52 files changed

Lines changed: 1441 additions & 201 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
},
8484
"mounts": [
8585
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
86-
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
86+
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached",
87+
"source=${localEnv:HOME}/.npmrc,target=/home/vscode/.npmrc,type=bind,consistency=cached"
8788
],
8889
"name": "Devcontainer",
8990
"postCreateCommand": "scripts/devcontainer/postcreatecommand.sh"

.github/workflows/stage-1-commit.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
needs: detect-terraform-changes
7777
if: needs.detect-terraform-changes.outputs.terraform_changed == 'true'
7878
permissions:
79-
contents: write
79+
contents: write
8080
steps:
8181
- name: "Checkout code"
8282
uses: actions/checkout@v5
@@ -317,7 +317,7 @@ jobs:
317317
uses: actions/setup-node@v4
318318
with:
319319
node-version: ${{ inputs.nodejs_version }}
320-
registry-url: 'https://npm.pkg.github.com'
320+
registry-url: "https://npm.pkg.github.com"
321321

322322
- name: check if local version differs from latest published version
323323
id: check-version

.github/workflows/stage-2-test.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ env:
3838

3939
permissions:
4040
id-token: write # This is required for requesting the JWT
41-
contents: read # This is required for actions/checkout
41+
contents: read # This is required for actions/checkout
4242
packages: read # This is required for downloading from GitHub Package Registry
4343

4444
jobs:
@@ -49,6 +49,11 @@ jobs:
4949
steps:
5050
- name: "Checkout code"
5151
uses: actions/checkout@v5
52+
- name: Setup NodeJS
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: ${{ inputs.nodejs_version }}
56+
registry-url: "https://npm.pkg.github.com"
5257
- name: "Cache node_modules"
5358
uses: actions/cache@v4
5459
with:
@@ -73,6 +78,11 @@ jobs:
7378
steps:
7479
- name: "Checkout code"
7580
uses: actions/checkout@v5
81+
- name: Setup NodeJS
82+
uses: actions/setup-node@v4
83+
with:
84+
node-version: ${{ inputs.nodejs_version }}
85+
registry-url: "https://npm.pkg.github.com"
7686
- name: "Cache node_modules"
7787
uses: actions/cache@v4
7888
with:
@@ -142,6 +152,11 @@ jobs:
142152
steps:
143153
- name: "Checkout code"
144154
uses: actions/checkout@v5
155+
- name: Setup NodeJS
156+
uses: actions/setup-node@v4
157+
with:
158+
node-version: ${{ inputs.nodejs_version }}
159+
registry-url: "https://npm.pkg.github.com"
145160
- name: "Cache node_modules"
146161
uses: actions/cache@v4
147162
with:
@@ -168,6 +183,11 @@ jobs:
168183
steps:
169184
- name: "Checkout code"
170185
uses: actions/checkout@v5
186+
- name: Setup NodeJS
187+
uses: actions/setup-node@v4
188+
with:
189+
node-version: ${{ inputs.nodejs_version }}
190+
registry-url: "https://npm.pkg.github.com"
171191
- name: "Cache node_modules"
172192
uses: actions/cache@v4
173193
with:

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ e12407e09151898bfd8d049d57eee9db9977d56b:.github/copilot-instructions.md:generic
2121
82cf3b2e89ea24b97c4ffc09e618700fb1b0aff3:pact-contracts/pacts/letter-rendering/supplier-api-letter-request-prepared.json:generic-api-key:10
2222
82f6be3e657b46d8447e77cdc1894fba0b855c26:tests/component-tests/testCases/create-letter-request.spec.ts:generic-api-key:10
2323
debc75a97cfe551a69fd1e8694be483213322a9d:pact-contracts/pacts/letter-rendering/supplier-api-letter-request-prepared.json:generic-api-key:10
24+
777eb4047ad06b9e939a292ee18664a0ffee4f29:tests/resources/prepared-letter.json:generic-api-key:4

infrastructure/terraform/components/api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ No requirements.
2626
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
2727
| <a name="input_kms_deletion_window"></a> [kms\_deletion\_window](#input\_kms\_deletion\_window) | When a kms key is deleted, how long should it wait in the pending deletion state? | `string` | `"30"` | no |
2828
| <a name="input_letter_table_ttl_hours"></a> [letter\_table\_ttl\_hours](#input\_letter\_table\_ttl\_hours) | Number of hours to set as TTL on letters table | `number` | `24` | no |
29+
| <a name="input_letter_variant_map"></a> [letter\_variant\_map](#input\_letter\_variant\_map) | n/a | `map(object({ supplierId = string, specId = string }))` | <pre>{<br/> "lv1": {<br/> "specId": "spec1",<br/> "supplierId": "supplier1"<br/> },<br/> "lv2": {<br/> "specId": "spec2",<br/> "supplierId": "supplier1"<br/> },<br/> "lv3": {<br/> "specId": "spec3",<br/> "supplierId": "supplier2"<br/> }<br/>}</pre> | no |
2930
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | The log level to be used in lambda functions within the component. Any log with a lower severity than the configured value will not be logged: https://docs.python.org/3/library/logging.html#levels | `string` | `"INFO"` | no |
3031
| <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 |
3132
| <a name="input_manually_configure_mtls_truststore"></a> [manually\_configure\_mtls\_truststore](#input\_manually\_configure\_mtls\_truststore) | Manually manage the truststore used for API Gateway mTLS (e.g. for prod environment) | `bool` | `false` | no |

infrastructure/terraform/components/api/ddb_table_letters.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ resource "aws_dynamodb_table" "letters" {
22
name = "${local.csi}-letters"
33
billing_mode = "PAY_PER_REQUEST"
44

5-
hash_key = "supplierId"
6-
range_key = "id"
5+
hash_key = "id"
6+
range_key = "supplierId"
77

88
ttl {
99
attribute_name = "ttl"

infrastructure/terraform/components/api/module_lambda_upsert_letter.tf

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

4-
function_name = "upsert-letter"
4+
function_name = "upsert_letter"
55
description = "Update or Insert the letter data in the letters table"
66

77
aws_account_id = var.aws_account_id
@@ -22,7 +22,7 @@ module "upsert_letter" {
2222
function_code_base_path = local.aws_lambda_functions_dir_path
2323
function_code_dir = "upsert-letter/dist"
2424
function_include_common = true
25-
handler_function_name = "handler"
25+
handler_function_name = "upsertLetterHandler"
2626
runtime = "nodejs22.x"
2727
memory = 128
2828
timeout = 29
@@ -34,7 +34,9 @@ module "upsert_letter" {
3434
log_destination_arn = local.destination_arn
3535
log_subscription_role_arn = local.acct.log_subscription_role_arn
3636

37-
lambda_env_vars = merge(local.common_lambda_env_vars, {})
37+
lambda_env_vars = merge(local.common_lambda_env_vars, {
38+
VARIANT_MAP = jsonencode(var.letter_variant_map)
39+
})
3840
}
3941

4042
data "aws_iam_policy_document" "upsert_letter_lambda" {
@@ -57,7 +59,10 @@ data "aws_iam_policy_document" "upsert_letter_lambda" {
5759
effect = "Allow"
5860

5961
actions = [
60-
"dynamodb:PutItem"
62+
"dynamodb:PutItem",
63+
"dynamodb:GetItem",
64+
"dynamodb:Query",
65+
"dynamodb:UpdateItem"
6166
]
6267

6368
resources = [

infrastructure/terraform/components/api/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ variable "eventpub_control_plane_bus_arn" {
141141
default = ""
142142
}
143143

144+
variable "letter_variant_map" {
145+
type = map(object({ supplierId = string, specId = string }))
146+
default = {
147+
"lv1" = { supplierId = "supplier1", specId = "spec1" },
148+
"lv2" = { supplierId = "supplier1", specId = "spec2" },
149+
"lv3" = { supplierId = "supplier2", specId = "spec3" }
150+
}
151+
}
152+
144153
variable "disable_gateway_execute_endpoint" {
145154
type = bool
146155
description = "Disable the execution endpoint for the API Gateway"
@@ -157,4 +166,5 @@ variable "core_environment" {
157166
type = string
158167
description = "Environment of Core"
159168
default = "prod"
169+
160170
}

internal/datastore/src/__test__/db.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ const createLetterTableCommand = new CreateTableCommand({
5151
TableName: "letters",
5252
BillingMode: "PAY_PER_REQUEST",
5353
KeySchema: [
54-
{ AttributeName: "supplierId", KeyType: "HASH" }, // Partition key
55-
{ AttributeName: "id", KeyType: "RANGE" }, // Sort key
54+
{ AttributeName: "id", KeyType: "HASH" }, // Partition key (letter ID)
55+
{ AttributeName: "supplierId", KeyType: "RANGE" }, // Sort key
5656
],
5757
GlobalSecondaryIndexes: [
5858
{

internal/datastore/src/__test__/heathcheck.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ describe("DBHealthcheck", () => {
2424
await deleteTables(db);
2525
});
2626

27+
afterAll(async () => {
28+
await db.container.stop();
29+
});
30+
2731
it("passes when the database is available", async () => {
2832
const dbHealthCheck = new DBHealthcheck(db.docClient, db.config);
2933
await expect(dbHealthCheck.check()).resolves.not.toThrow();

0 commit comments

Comments
 (0)