Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1d53900
Add upsert lambda
francisco-videira-nhs Dec 1, 2025
4334697
Fix names
francisco-videira-nhs Dec 2, 2025
132326d
Fix unit test
francisco-videira-nhs Dec 2, 2025
036c319
Fix unit test dates
francisco-videira-nhs Dec 2, 2025
d6602c3
Fix lambda handler name export
francisco-videira-nhs Dec 2, 2025
92d4d26
Add event-schemas-letter-rendering
francisco-videira-nhs Dec 4, 2025
b040535
Add GitHub NPM registry configuration to .npmrc
m-houston Dec 5, 2025
ffb8d5c
Add version check and Node.js setup to CI workflow
m-houston Dec 5, 2025
c307fc9
TO REVERT AFTER TEST: conditional check for event schema version update
m-houston Dec 5, 2025
46c8402
Refactor event schema version checks in CI workflow
m-houston Dec 5, 2025
f1444fd
Add GitHub NPM registry URL to Node.js setup in workflows
m-houston Dec 5, 2025
59d8846
Log npm response
m-houston Dec 5, 2025
d7a665c
Add NODE_AUTH_TOKEN to GitHub Actions environment for NPM access
m-houston Dec 5, 2025
5741a86
Revert "Add GitHub NPM registry URL to Node.js setup in workflows"
m-houston Dec 5, 2025
c427d03
Move NODE_AUTH_TOKEN to npm view step in CI workflow
m-houston Dec 5, 2025
8981a44
Reapply "Add GitHub NPM registry URL to Node.js setup in workflows"
m-houston Dec 5, 2025
fbf2e9d
Add NODE_AUTH_TOKEN to NPM install steps in workflows
m-houston Dec 5, 2025
113bbe5
Re-enable conditional check on published package check
m-houston Dec 5, 2025
032e48f
Add NODE_AUTH_TOKEN input for GitHub package registry access in workf…
m-houston Dec 5, 2025
f24f37a
Add packages:read to permissions
m-houston Dec 5, 2025
333f352
Merge branch 'main' into feature/fix-github-npm-registry-access
m-houston Dec 5, 2025
0d41d64
Merge remote-tracking branch 'origin/main' into feature/CCM-12997
francisco-videira-nhs Dec 5, 2025
6400400
delete old test
francisco-videira-nhs Dec 5, 2025
6a7efa3
Merge remote-tracking branch 'origin/feature/fix-github-npm-registry-…
francisco-videira-nhs Dec 5, 2025
4001e32
fix trivy scan step
francisco-videira-nhs Dec 5, 2025
66eb971
Fix gh pkg registry test stage
francisco-videira-nhs Dec 8, 2025
b8b45ac
Merge remote-tracking branch 'origin/main' into feature/CCM-12997
francisco-videira-nhs Dec 8, 2025
64d0fe2
fix local npmrc
francisco-videira-nhs Dec 8, 2025
ca58f3b
Fix unit test timestamps, add source
francisco-videira-nhs Dec 12, 2025
65481fd
Merge remote-tracking branch 'origin/main' into feature/CCM-12997
francisco-videira-nhs Dec 12, 2025
8a74c03
Add notification parsing logic
francisco-videira-nhs Dec 12, 2025
cb29729
fix tf var
francisco-videira-nhs Dec 12, 2025
2715285
Fix ddb permissions
francisco-videira-nhs Dec 12, 2025
d6e80aa
Add latest version event schema letter rendering
francisco-videira-nhs Dec 15, 2025
595d4b6
Add trying v1 parse if v2 fails
francisco-videira-nhs Dec 15, 2025
78ece30
Add subject
francisco-videira-nhs Dec 16, 2025
a8fa07e
Split upsert operations
francisco-videira-nhs Dec 18, 2025
6040c12
Merge remote-tracking branch 'origin/main' into feature/CCM-12997
francisco-videira-nhs Dec 18, 2025
b1e1195
Letter variant map to vars
francisco-videira-nhs Dec 18, 2025
fdd73fc
Revert supplierStatusSk
francisco-videira-nhs Dec 18, 2025
05a6b2b
Merge remote-tracking branch 'origin/main' into feature/CCM-12997
francisco-videira-nhs Dec 18, 2025
10ec08f
Fix dependencies
francisco-videira-nhs Dec 18, 2025
547f6b1
Merge branch 'main' into feature/CCM-12997
masl2 Dec 24, 2025
e42d26c
CCM-13697: Letters Key and Source Data Item (#323)
masl2 Dec 24, 2025
448702b
missing close brace
masl2 Dec 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
},
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached",
"source=${localEnv:HOME}/.npmrc,target=/home/vscode/.npmrc,type=bind,consistency=cached"
],
"name": "Devcontainer",
"postCreateCommand": "scripts/devcontainer/postcreatecommand.sh"
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/stage-1-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
needs: detect-terraform-changes
if: needs.detect-terraform-changes.outputs.terraform_changed == 'true'
permissions:
contents: write
contents: write
steps:
- name: "Checkout code"
uses: actions/checkout@v5
Expand Down Expand Up @@ -164,8 +164,6 @@ jobs:
registry-url: 'https://npm.pkg.github.com'
- name: "Setup ASDF"
uses: asdf-vm/actions/setup@v4
- name: "Perform Setup"
uses: ./.github/actions/setup
- name: "Trivy Scan"
uses: ./.github/actions/trivy
count-lines-of-code:
Expand Down Expand Up @@ -288,7 +286,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodejs_version }}
registry-url: 'https://npm.pkg.github.com'
registry-url: "https://npm.pkg.github.com"

- name: check if local version differs from latest published version
id: check-version
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/stage-2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:

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

jobs:
Expand All @@ -49,6 +49,11 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v5
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodejs_version }}
registry-url: "https://npm.pkg.github.com"
- name: "Cache node_modules"
uses: actions/cache@v4
with:
Expand All @@ -73,6 +78,11 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v5
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodejs_version }}
registry-url: "https://npm.pkg.github.com"
- name: "Cache node_modules"
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -142,6 +152,11 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v5
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodejs_version }}
registry-url: "https://npm.pkg.github.com"
- name: "Cache node_modules"
uses: actions/cache@v4
with:
Expand All @@ -168,6 +183,11 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v5
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodejs_version }}
registry-url: "https://npm.pkg.github.com"
- name: "Cache node_modules"
uses: actions/cache@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions infrastructure/terraform/components/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ No requirements.
| <a name="input_aws_account_id"></a> [aws\_account\_id](#input\_aws\_account\_id) | The AWS Account ID (numeric) | `string` | n/a | yes |
| <a name="input_ca_pem_filename"></a> [ca\_pem\_filename](#input\_ca\_pem\_filename) | Filename for the CA truststore file within the s3 bucket | `string` | `null` | no |
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"supapi"` | no |
| <a name="input_core_account_id"></a> [core\_account\_id](#input\_core\_account\_id) | AWS Account ID for Core | `string` | `"000000000000"` | no |
| <a name="input_core_environment"></a> [core\_environment](#input\_core\_environment) | Environment of Core | `string` | `"prod"` | no |
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
| <a name="input_enable_backups"></a> [enable\_backups](#input\_enable\_backups) | Enable backups | `bool` | `false` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
Expand All @@ -22,6 +24,7 @@ No requirements.
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ resource "aws_dynamodb_table" "letters" {
name = "${local.csi}-letters"
billing_mode = "PAY_PER_REQUEST"

hash_key = "supplierId"
range_key = "id"
hash_key = "id"
range_key = "supplierId"

ttl {
attribute_name = "ttl"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "upsert_letter" {
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-lambda.zip"

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

aws_account_id = var.aws_account_id
Expand All @@ -22,7 +22,7 @@ module "upsert_letter" {
function_code_base_path = local.aws_lambda_functions_dir_path
function_code_dir = "upsert-letter/dist"
function_include_common = true
handler_function_name = "handler"
handler_function_name = "upsertLetterHandler"
runtime = "nodejs22.x"
memory = 128
timeout = 29
Expand All @@ -35,7 +35,9 @@ module "upsert_letter" {
log_destination_arn = local.destination_arn
log_subscription_role_arn = local.acct.log_subscription_role_arn

lambda_env_vars = merge(local.common_lambda_env_vars, {})
lambda_env_vars = merge(local.common_lambda_env_vars, {
VARIANT_MAP = jsonencode(var.letter_variant_map)
})
}

data "aws_iam_policy_document" "upsert_letter_lambda" {
Expand All @@ -58,7 +60,10 @@ data "aws_iam_policy_document" "upsert_letter_lambda" {
effect = "Allow"

actions = [
"dynamodb:PutItem"
"dynamodb:PutItem",
"dynamodb:GetItem",
"dynamodb:Query",
"dynamodb:UpdateItem"
]

resources = [
Expand Down
10 changes: 10 additions & 0 deletions infrastructure/terraform/components/api/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ variable "eventpub_control_plane_bus_arn" {
default = ""
}

variable "letter_variant_map" {
type = map(object({ supplierId = string, specId = string }))
default = {
"lv1" = { supplierId = "supplier1", specId = "spec1" },
"lv2" = { supplierId = "supplier1", specId = "spec2" },
"lv3" = { supplierId = "supplier2", specId = "spec3" }
}
}

variable "core_account_id" {
type = string
description = "AWS Account ID for Core"
Expand All @@ -145,4 +154,5 @@ variable "core_environment" {
type = string
description = "Environment of Core"
default = "prod"

}
4 changes: 2 additions & 2 deletions internal/datastore/src/__test__/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const createLetterTableCommand = new CreateTableCommand({
TableName: "letters",
BillingMode: "PAY_PER_REQUEST",
KeySchema: [
{ AttributeName: "supplierId", KeyType: "HASH" }, // Partition key
{ AttributeName: "id", KeyType: "RANGE" }, // Sort key
{ AttributeName: "id", KeyType: "HASH" }, // Partition key (letter ID)
{ AttributeName: "supplierId", KeyType: "RANGE" }, // Sort key
],
GlobalSecondaryIndexes: [
{
Expand Down
4 changes: 4 additions & 0 deletions internal/datastore/src/__test__/heathcheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ describe("DBHealthcheck", () => {
await deleteTables(db);
});

afterAll(async () => {
await db.container.stop();
});

it("passes when the database is available", async () => {
const dbHealthCheck = new DBHealthcheck(db.docClient, db.config);
await expect(dbHealthCheck.check()).resolves.not.toThrow();
Expand Down
Loading