Skip to content

Commit 0cd4fe2

Browse files
merge main
2 parents 231a354 + e837eda commit 0cd4fe2

28 files changed

Lines changed: 1683 additions & 1872 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/.github/ @NHSDigital/nhs-notify-supplier-api-admins
66
*.code-workspace @NHSDigital/nhs-notify-supplier-api-admins
77
/docs/ @NHSDigital/nhs-notify-supplier-api
8-
/infrastructure/terraform/ @NHSDigital/nhs-notify-platform @NHSDigital/nhs-notify-supplier-api-admins
8+
/infrastructure/terraform/ @NHSDigital/nhs-notify-platform
99

1010
# Root level AGENTS.md owned by platform.
1111
AGENTS.md @NHSDigital/nhs-notify-platform

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This repository documents the Supplier API specification and provides an SDK wit
3434
- [CI (Automatic)](#ci-automatic)
3535
- [CD (Manual)](#cd-manual)
3636
- [Licence](#licence)
37+
- [Postman](#postman)
3738

3839
## API Consumers - Getting Started
3940

@@ -138,3 +139,15 @@ Deployments can be made of any [release](https://github.com/NHSDigital/nhs-notif
138139
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.
139140

140141
Any HTML or Markdown documentation is [© Crown Copyright](https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/) and available under the terms of the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).
142+
143+
## Postman
144+
145+
Included in this repo are postman collections that allows the user to interact with the sandbox APIs.
146+
147+
To use the collections:
148+
149+
Download the json files located in the postman directory
150+
Import the files into postman
151+
Select a target environment in postman
152+
Run the collection
153+
The collections must be kept in sync manually

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.2-${yyyy}${mm}${dd}.${HH}${MM}${SS}+${hash}
1+
1.1.5-${yyyy}${mm}${dd}.${HH}${MM}${SS}+${hash}

infrastructure/terraform/components/api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ No requirements.
6363
| <a name="module_post_mi"></a> [post\_mi](#module\_post\_mi) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
6464
| <a name="module_s3bucket_test_letters"></a> [s3bucket\_test\_letters](#module\_s3bucket\_test\_letters) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-s3bucket.zip | n/a |
6565
| <a name="module_sqs_letter_updates"></a> [sqs\_letter\_updates](#module\_sqs\_letter\_updates) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-sqs.zip | n/a |
66+
| <a name="module_sqs_supplier_allocator"></a> [sqs\_supplier\_allocator](#module\_sqs\_supplier\_allocator) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-sqs.zip | n/a |
67+
| <a name="module_supplier_allocator"></a> [supplier\_allocator](#module\_supplier\_allocator) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
6668
| <a name="module_supplier_ssl"></a> [supplier\_ssl](#module\_supplier\_ssl) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-ssl.zip | n/a |
6769
| <a name="module_upsert_letter"></a> [upsert\_letter](#module\_upsert\_letter) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip | n/a |
6870
## Outputs

infrastructure/terraform/components/api/event_source_mapping_status_updates_to_handler.tf

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "aws_lambda_event_source_mapping" "supplier_allocator" {
2+
event_source_arn = module.sqs_supplier_allocator.sqs_queue_arn
3+
function_name = module.supplier_allocator.function_name
4+
batch_size = 10
5+
maximum_batching_window_in_seconds = 5
6+
function_response_types = [
7+
"ReportBatchItemFailures"
8+
]
9+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
module "supplier_allocator" {
2+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip"
3+
4+
function_name = "supplier-allocator"
5+
description = "Allocate a letter to a supplier"
6+
7+
aws_account_id = var.aws_account_id
8+
component = var.component
9+
environment = var.environment
10+
project = var.project
11+
region = var.region
12+
group = var.group
13+
14+
log_retention_in_days = var.log_retention_in_days
15+
kms_key_arn = module.kms.key_arn
16+
17+
iam_policy_document = {
18+
body = data.aws_iam_policy_document.supplier_allocator_lambda.json
19+
}
20+
21+
function_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"]
22+
function_code_base_path = local.aws_lambda_functions_dir_path
23+
function_code_dir = "supplier-allocator/dist"
24+
function_include_common = true
25+
handler_function_name = "supplierAllocatorHandler"
26+
runtime = "nodejs22.x"
27+
memory = 512
28+
timeout = 29
29+
log_level = var.log_level
30+
31+
force_lambda_code_deploy = var.force_lambda_code_deploy
32+
enable_lambda_insights = false
33+
34+
log_destination_arn = local.destination_arn
35+
log_subscription_role_arn = local.acct.log_subscription_role_arn
36+
37+
lambda_env_vars = merge(local.common_lambda_env_vars, {
38+
VARIANT_MAP = jsonencode(var.letter_variant_map)
39+
UPSERT_LETTERS_QUEUE_URL = module.sqs_letter_updates.sqs_queue_url
40+
})
41+
}
42+
43+
data "aws_iam_policy_document" "supplier_allocator_lambda" {
44+
statement {
45+
sid = "KMSPermissions"
46+
effect = "Allow"
47+
48+
actions = [
49+
"kms:Decrypt",
50+
"kms:GenerateDataKey",
51+
]
52+
53+
resources = [
54+
module.kms.key_arn,
55+
]
56+
}
57+
58+
statement {
59+
sid = "AllowSQSRead"
60+
effect = "Allow"
61+
62+
actions = [
63+
"sqs:ReceiveMessage",
64+
"sqs:DeleteMessage",
65+
"sqs:GetQueueAttributes"
66+
]
67+
68+
resources = [
69+
module.sqs_supplier_allocator.sqs_queue_arn
70+
]
71+
}
72+
73+
statement {
74+
sid = "AllowSQSWrite"
75+
effect = "Allow"
76+
77+
actions = [
78+
"sqs:SendMessage"
79+
]
80+
81+
resources = [
82+
module.sqs_letter_updates.sqs_queue_arn
83+
]
84+
}
85+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module "sqs_supplier_allocator" {
2+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-sqs.zip"
3+
4+
aws_account_id = var.aws_account_id
5+
component = var.component
6+
environment = var.environment
7+
project = var.project
8+
region = var.region
9+
name = "supplier-allocator"
10+
11+
sqs_kms_key_arn = module.kms.key_arn
12+
13+
visibility_timeout_seconds = 60
14+
15+
create_dlq = true
16+
sqs_policy_overload = data.aws_iam_policy_document.supplier_allocator_queue_policy.json
17+
}
18+
19+
data "aws_iam_policy_document" "supplier_allocator_queue_policy" {
20+
version = "2012-10-17"
21+
22+
statement {
23+
sid = "AllowSNSPermissions"
24+
effect = "Allow"
25+
26+
principals {
27+
type = "Service"
28+
identifiers = ["sns.amazonaws.com"]
29+
}
30+
31+
actions = [
32+
"sqs:SendMessage",
33+
"sqs:ListQueueTags",
34+
"sqs:GetQueueUrl",
35+
"sqs:GetQueueAttributes",
36+
]
37+
38+
resources = [
39+
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${var.project}-${var.environment}-${var.component}-supplier-allocator-queue"
40+
]
41+
42+
condition {
43+
test = "ArnEquals"
44+
variable = "aws:SourceArn"
45+
values = [module.eventsub.sns_topic.arn]
46+
}
47+
}
48+
}
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
resource "aws_sns_topic_subscription" "eventsub_sqs_letter_updates" {
2-
topic_arn = module.eventsub.sns_topic.arn
3-
protocol = "sqs"
4-
endpoint = module.sqs_letter_updates.sqs_queue_arn
2+
topic_arn = module.eventsub.sns_topic.arn
3+
protocol = "sqs"
4+
endpoint = module.sqs_letter_updates.sqs_queue_arn
5+
raw_message_delivery = true
6+
7+
filter_policy_scope = "MessageBody"
8+
filter_policy = jsonencode({
9+
type = [{ prefix = "uk.nhs.notify.supplier-api.letter" }]
10+
})
511
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "aws_sns_topic_subscription" "eventsub_sqs_supplier_allocator" {
2+
topic_arn = module.eventsub.sns_topic.arn
3+
protocol = "sqs"
4+
endpoint = module.sqs_supplier_allocator.sqs_queue_arn
5+
raw_message_delivery = true
6+
7+
filter_policy_scope = "MessageBody"
8+
filter_policy = jsonencode({
9+
type = [{ prefix = "uk.nhs.notify.letter-rendering.letter-request.prepared" }]
10+
})
11+
}

0 commit comments

Comments
 (0)