Skip to content

Commit 92be12b

Browse files
committed
Merge branch 'main' into fix/internal-event-datastore-dep
2 parents 5356f5a + c12c456 commit 92be12b

File tree

40 files changed

+1508
-214
lines changed

40 files changed

+1508
-214
lines changed

.github/workflows/stage-3-build.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,5 @@ jobs:
182182
environment: ${{ needs.pr-create-dynamic-environment.outputs.environment_name }}
183183
apimEnv: "internal-dev-sandbox"
184184
runId: "${{ github.run_id }}"
185-
# TODO: CCM-15527: Do not deploy sandbox - new certs do not appear to auth for docker correctly
186-
buildSandbox: false
185+
buildSandbox: true
187186
releaseVersion: ${{ github.head_ref || github.ref_name }}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.5-${yyyy}${mm}${dd}.${HH}${MM}${SS}+${hash}
1+
1.1.6-${yyyy}${mm}${dd}.${HH}${MM}${SS}+${hash}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
resource "aws_dynamodb_table" "supplier-configuration" {
2+
name = "${local.csi}-supplier-config"
3+
billing_mode = "PAY_PER_REQUEST"
4+
5+
hash_key = "PK"
6+
range_key = "SK"
7+
8+
ttl {
9+
attribute_name = "ttl"
10+
enabled = true
11+
}
12+
13+
attribute {
14+
name = "PK"
15+
type = "S"
16+
}
17+
18+
attribute {
19+
name = "SK"
20+
type = "S"
21+
}
22+
23+
attribute {
24+
name = "entityType"
25+
type = "S"
26+
}
27+
28+
attribute {
29+
name = "volumeGroup"
30+
type = "S"
31+
}
32+
33+
// The type-index GSI allows us to query for all supplier configurations of a given type (e.g. all letter supplier configurations)
34+
global_secondary_index {
35+
name = "EntityTypeIndex"
36+
hash_key = "entityType"
37+
range_key = "SK"
38+
projection_type = "ALL"
39+
}
40+
41+
global_secondary_index {
42+
name = "volumeGroup-index"
43+
hash_key = "PK"
44+
range_key = "volumeGroup"
45+
projection_type = "ALL"
46+
}
47+
48+
point_in_time_recovery {
49+
enabled = true
50+
}
51+
52+
tags = merge(
53+
local.default_tags,
54+
{
55+
NHSE-Enable-Dynamo-Backup-Acct = "True"
56+
}
57+
)
58+
59+
}

infrastructure/terraform/components/api/locals.tf

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ locals {
2020
destination_arn = "arn:aws:logs:${var.region}:${var.shared_infra_account_id}:destination:nhs-main-obs-firehose-logs"
2121

2222
common_lambda_env_vars = {
23-
LETTERS_TABLE_NAME = aws_dynamodb_table.letters.name,
24-
MI_TABLE_NAME = aws_dynamodb_table.mi.name,
25-
LETTER_TTL_HOURS = 12960, # 18 months * 30 days * 24 hours
26-
MI_TTL_HOURS = 2160 # 90 days * 24 hours
27-
SUPPLIER_ID_HEADER = "nhsd-supplier-id",
28-
APIM_CORRELATION_HEADER = "nhsd-correlation-id",
29-
DOWNLOAD_URL_TTL_SECONDS = 60
30-
SNS_TOPIC_ARN = "${module.eventsub.sns_topic.arn}",
31-
EVENT_SOURCE = "/data-plane/supplier-api/${var.group}/${var.environment}/letters"
23+
APIM_CORRELATION_HEADER = "nhsd-correlation-id",
24+
DOWNLOAD_URL_TTL_SECONDS = 60
25+
EVENT_SOURCE = "/data-plane/supplier-api/${var.group}/${var.environment}/letters"
26+
LETTER_TTL_HOURS = 12960, # 18 months * 30 days * 24 hours
27+
LETTERS_TABLE_NAME = aws_dynamodb_table.letters.name,
28+
MI_TABLE_NAME = aws_dynamodb_table.mi.name,
29+
MI_TTL_HOURS = 2160 # 90 days * 24 hours
30+
SNS_TOPIC_ARN = "${module.eventsub.sns_topic.arn}",
31+
SUPPLIER_CONFIG_TABLE_NAME = aws_dynamodb_table.supplier-configuration.name
32+
SUPPLIER_ID_HEADER = "nhsd-supplier-id",
3233
}
3334

3435
core_pdf_bucket_arn = "arn:aws:s3:::comms-${var.core_account_id}-eu-west-2-${var.core_environment}-api-stg-pdf-pipeline"

infrastructure/terraform/components/api/module_lambda_supplier_allocator.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,20 @@ data "aws_iam_policy_document" "supplier_allocator_lambda" {
8282
module.sqs_letter_updates.sqs_queue_arn
8383
]
8484
}
85+
86+
statement {
87+
sid = "AllowDynamoDBAccess"
88+
effect = "Allow"
89+
90+
actions = [
91+
"dynamodb:GetItem",
92+
"dynamodb:Query"
93+
]
94+
95+
resources = [
96+
aws_dynamodb_table.supplier-configuration.arn,
97+
"${aws_dynamodb_table.supplier-configuration.arn}/index/volumeGroup-index"
98+
99+
]
100+
}
85101
}

internal/datastore/jest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const baseJestConfig: Config = {
3131

3232
coveragePathIgnorePatterns: ["/__tests__/"],
3333
transform: { "^.+\\.ts$": "ts-jest" },
34+
transformIgnorePatterns: [
35+
"node_modules/(?!(@nhsdigital/nhs-notify-event-schemas-supplier-config)/)",
36+
],
3437
testPathIgnorePatterns: [".build"],
3538
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
3639

internal/datastore/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"@aws-sdk/client-dynamodb": "^3.984.0",
44
"@aws-sdk/lib-dynamodb": "^3.1008.0",
55
"@internal/helpers": "*",
6+
"@nhsdigital/nhs-notify-event-schemas-supplier-config": "^1.0.1",
67
"pino": "^10.3.0",
78
"zod": "^4.1.11",
89
"zod-mermaid": "^1.0.9"

internal/datastore/src/__test__/db.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export async function setupDynamoDBContainer() {
3737
lettersTtlHours: 1,
3838
letterQueueTtlHours: 1,
3939
miTtlHours: 1,
40+
supplierConfigTableName: "supplier-config",
4041
};
4142

4243
return {
@@ -146,6 +147,31 @@ const createLetterQueueTableCommand = new CreateTableCommand({
146147
{ AttributeName: "queueSortOrderSk", AttributeType: "S" },
147148
],
148149
});
150+
const createSupplierConfigTableCommand = new CreateTableCommand({
151+
TableName: "supplier-config",
152+
BillingMode: "PAY_PER_REQUEST",
153+
KeySchema: [
154+
{ AttributeName: "PK", KeyType: "HASH" }, // Partition key
155+
{ AttributeName: "SK", KeyType: "RANGE" }, // Sort key
156+
],
157+
GlobalSecondaryIndexes: [
158+
{
159+
IndexName: "volumeGroup-index",
160+
KeySchema: [
161+
{ AttributeName: "PK", KeyType: "HASH" }, // Partition key for GSI
162+
{ AttributeName: "volumeGroup", KeyType: "RANGE" }, // Sort key for GSI
163+
],
164+
Projection: {
165+
ProjectionType: "ALL",
166+
},
167+
},
168+
],
169+
AttributeDefinitions: [
170+
{ AttributeName: "PK", AttributeType: "S" },
171+
{ AttributeName: "SK", AttributeType: "S" },
172+
{ AttributeName: "volumeGroup", AttributeType: "S" },
173+
],
174+
});
149175

150176
export async function createTables(context: DBContext) {
151177
const { ddbClient } = context;
@@ -156,6 +182,7 @@ export async function createTables(context: DBContext) {
156182
await ddbClient.send(createMITableCommand);
157183
await ddbClient.send(createSupplierTableCommand);
158184
await ddbClient.send(createLetterQueueTableCommand);
185+
await ddbClient.send(createSupplierConfigTableCommand);
159186
}
160187

161188
export async function deleteTables(context: DBContext) {
@@ -166,6 +193,7 @@ export async function deleteTables(context: DBContext) {
166193
"management-info",
167194
"suppliers",
168195
"letter-queue",
196+
"supplier-config",
169197
]) {
170198
await ddbClient.send(
171199
new DeleteTableCommand({

0 commit comments

Comments
 (0)