Skip to content

Commit 0bada93

Browse files
CCM-11164: update RC (#714)
Co-authored-by: Michael Harrison <[email protected]>
1 parent dee3e74 commit 0bada93

File tree

50 files changed

+2878
-229
lines changed

Some content is hidden

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

50 files changed

+2878
-229
lines changed

infrastructure/terraform/modules/backend-api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ No requirements.
6363
| <a name="module_sqs_template_mgmt_events"></a> [sqs\_template\_mgmt\_events](#module\_sqs\_template\_mgmt\_events) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-sqs.zip | n/a |
6464
| <a name="module_sqs_template_table_events_pipe_dlq"></a> [sqs\_template\_table\_events\_pipe\_dlq](#module\_sqs\_template\_table\_events\_pipe\_dlq) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-sqs.zip | n/a |
6565
| <a name="module_sqs_validate_letter_template_files"></a> [sqs\_validate\_letter\_template\_files](#module\_sqs\_validate\_letter\_template\_files) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-sqs.zip | n/a |
66+
| <a name="module_submit_routing_config_lambda"></a> [submit\_routing\_config\_lambda](#module\_submit\_routing\_config\_lambda) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip | n/a |
6667
| <a name="module_submit_template_lambda"></a> [submit\_template\_lambda](#module\_submit\_template\_lambda) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip | n/a |
68+
| <a name="module_update_routing_config_lambda"></a> [update\_routing\_config\_lambda](#module\_update\_routing\_config\_lambda) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip | n/a |
6769
| <a name="module_update_template_lambda"></a> [update\_template\_lambda](#module\_update\_template\_lambda) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip | n/a |
6870
| <a name="module_upload_letter_template_lambda"></a> [upload\_letter\_template\_lambda](#module\_upload\_letter\_template\_lambda) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip | n/a |
6971
## Outputs

infrastructure/terraform/modules/backend-api/iam_role_api_gateway_execution_role.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ data "aws_iam_policy_document" "api_gateway_execution_policy" {
6161
module.list_template_lambda.function_arn,
6262
module.request_proof_lambda.function_arn,
6363
module.submit_template_lambda.function_arn,
64+
module.submit_routing_config_lambda.function_arn,
65+
module.update_routing_config_lambda.function_arn,
6466
module.update_template_lambda.function_arn,
6567
]
6668
}

infrastructure/terraform/modules/backend-api/locals.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ locals {
2525
LIST_ROUTING_CONFIGS_LAMBDA_ARN = module.list_routing_configs_lambda.function_arn
2626
REQUEST_PROOF_LAMBDA_ARN = module.request_proof_lambda.function_arn
2727
SUBMIT_LAMBDA_ARN = module.submit_template_lambda.function_arn
28+
SUBMIT_ROUTING_CONFIG_LAMBDA_ARN = module.submit_routing_config_lambda.function_arn
2829
UPDATE_LAMBDA_ARN = module.update_template_lambda.function_arn
30+
UPDATE_ROUTING_CONFIG_LAMBDA_ARN = module.update_routing_config_lambda.function_arn
2931
UPLOAD_LETTER_LAMBDA_ARN = module.upload_letter_template_lambda.function_arn
3032
})
3133

infrastructure/terraform/modules/backend-api/module_create_routing_config_lambda.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,15 @@ data "aws_iam_policy_document" "create_routing_config_lambda_policy" {
6565
var.kms_key_arn
6666
]
6767
}
68+
69+
statement {
70+
sid = "AllowSSMParameterRead"
71+
effect = "Allow"
72+
73+
actions = [
74+
"ssm:GetParameter",
75+
]
76+
77+
resources = [local.client_ssm_path_pattern]
78+
}
6879
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
module "submit_routing_config_lambda" {
2+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip"
3+
4+
project = var.project
5+
environment = var.environment
6+
component = var.component
7+
aws_account_id = var.aws_account_id
8+
region = var.region
9+
10+
kms_key_arn = var.kms_key_arn
11+
12+
function_name = "submit-routing-config"
13+
14+
function_module_name = "submit-routing-config"
15+
handler_function_name = "handler"
16+
description = "Submit Routing Config API endpoint"
17+
18+
memory = 512
19+
timeout = 3
20+
runtime = "nodejs20.x"
21+
22+
log_retention_in_days = var.log_retention_in_days
23+
24+
iam_policy_document = {
25+
body = data.aws_iam_policy_document.submit_routing_config_lambda_policy.json
26+
}
27+
28+
lambda_env_vars = local.backend_lambda_environment_variables
29+
function_s3_bucket = var.function_s3_bucket
30+
function_code_base_path = local.lambdas_dir
31+
function_code_dir = "backend-api/dist/submit-routing-config"
32+
33+
send_to_firehose = var.send_to_firehose
34+
log_destination_arn = var.log_destination_arn
35+
log_subscription_role_arn = var.log_subscription_role_arn
36+
}
37+
38+
data "aws_iam_policy_document" "submit_routing_config_lambda_policy" {
39+
statement {
40+
sid = "AllowDynamoAccess"
41+
effect = "Allow"
42+
43+
actions = [
44+
"dynamodb:UpdateItem",
45+
]
46+
47+
resources = [
48+
aws_dynamodb_table.routing_configuration.arn,
49+
]
50+
}
51+
52+
statement {
53+
sid = "AllowKMSAccess"
54+
effect = "Allow"
55+
56+
actions = [
57+
"kms:Decrypt",
58+
"kms:DescribeKey",
59+
"kms:Encrypt",
60+
"kms:GenerateDataKey*",
61+
"kms:ReEncrypt*",
62+
]
63+
64+
resources = [
65+
var.kms_key_arn
66+
]
67+
}
68+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
module "update_routing_config_lambda" {
2+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.22/terraform-lambda.zip"
3+
4+
project = var.project
5+
environment = var.environment
6+
component = var.component
7+
aws_account_id = var.aws_account_id
8+
region = var.region
9+
10+
kms_key_arn = var.kms_key_arn
11+
12+
function_name = "update-routing-config"
13+
14+
function_module_name = "update-routing-config"
15+
handler_function_name = "handler"
16+
description = "Submit Routing Config API endpoint"
17+
18+
memory = 512
19+
timeout = 3
20+
runtime = "nodejs20.x"
21+
22+
log_retention_in_days = var.log_retention_in_days
23+
24+
iam_policy_document = {
25+
body = data.aws_iam_policy_document.update_routing_config_lambda_policy.json
26+
}
27+
28+
lambda_env_vars = local.backend_lambda_environment_variables
29+
function_s3_bucket = var.function_s3_bucket
30+
function_code_base_path = local.lambdas_dir
31+
function_code_dir = "backend-api/dist/update-routing-config"
32+
33+
send_to_firehose = var.send_to_firehose
34+
log_destination_arn = var.log_destination_arn
35+
log_subscription_role_arn = var.log_subscription_role_arn
36+
}
37+
38+
data "aws_iam_policy_document" "update_routing_config_lambda_policy" {
39+
statement {
40+
sid = "AllowDynamoAccess"
41+
effect = "Allow"
42+
43+
actions = [
44+
"dynamodb:UpdateItem",
45+
]
46+
47+
resources = [
48+
aws_dynamodb_table.routing_configuration.arn,
49+
]
50+
}
51+
52+
statement {
53+
sid = "AllowKMSAccess"
54+
effect = "Allow"
55+
56+
actions = [
57+
"kms:Decrypt",
58+
"kms:DescribeKey",
59+
"kms:Encrypt",
60+
"kms:GenerateDataKey*",
61+
"kms:ReEncrypt*",
62+
]
63+
64+
resources = [
65+
var.kms_key_arn
66+
]
67+
}
68+
69+
statement {
70+
sid = "AllowSSMParameterRead"
71+
effect = "Allow"
72+
73+
actions = [
74+
"ssm:GetParameter",
75+
]
76+
77+
resources = [local.client_ssm_path_pattern]
78+
}
79+
}

infrastructure/terraform/modules/backend-api/spec.tmpl.json

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,145 @@
11551155
"type": "AWS_PROXY",
11561156
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${GET_ROUTING_CONFIG_LAMBDA_ARN}/invocations"
11571157
}
1158+
},
1159+
"put": {
1160+
"description": "Update a routing configuration by Id",
1161+
"requestBody": {
1162+
"content": {
1163+
"application/json": {
1164+
"schema": {
1165+
"$ref": "#/components/schemas/CreateUpdateRoutingConfig"
1166+
}
1167+
}
1168+
},
1169+
"description": "Routing configuration update to apply",
1170+
"required": true
1171+
},
1172+
"parameters": [
1173+
{
1174+
"description": "ID of routing configuration to update",
1175+
"in": "path",
1176+
"name": "routingConfigId",
1177+
"required": true,
1178+
"schema": {
1179+
"type": "string"
1180+
}
1181+
}
1182+
],
1183+
"responses": {
1184+
"200": {
1185+
"content": {
1186+
"application/json": {
1187+
"schema": {
1188+
"$ref": "#/components/schemas/RoutingConfigSuccess"
1189+
}
1190+
}
1191+
},
1192+
"description": "200 response",
1193+
"headers": {
1194+
"Content-Type": {
1195+
"schema": {
1196+
"type": "string"
1197+
}
1198+
}
1199+
}
1200+
},
1201+
"default": {
1202+
"content": {
1203+
"application/json": {
1204+
"schema": {
1205+
"$ref": "#/components/schemas/Failure"
1206+
}
1207+
}
1208+
},
1209+
"description": "Error"
1210+
}
1211+
},
1212+
"security": [
1213+
{
1214+
"authorizer": []
1215+
}
1216+
],
1217+
"summary": "Update a routing config",
1218+
"x-amazon-apigateway-integration": {
1219+
"contentHandling": "CONVERT_TO_TEXT",
1220+
"credentials": "${APIG_EXECUTION_ROLE_ARN}",
1221+
"httpMethod": "POST",
1222+
"passthroughBehavior": "WHEN_NO_TEMPLATES",
1223+
"responses": {
1224+
".*": {
1225+
"statusCode": "200"
1226+
}
1227+
},
1228+
"timeoutInMillis": 29000,
1229+
"type": "AWS_PROXY",
1230+
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${UPDATE_ROUTING_CONFIG_LAMBDA_ARN}/invocations"
1231+
}
1232+
}
1233+
},
1234+
"/v1/routing-configuration/{routingConfigId}/submit": {
1235+
"patch": {
1236+
"description": "Finalise a routing configuration by Id",
1237+
"parameters": [
1238+
{
1239+
"description": "ID of routing configuration to finalise",
1240+
"in": "path",
1241+
"name": "routingConfigId",
1242+
"required": true,
1243+
"schema": {
1244+
"type": "string"
1245+
}
1246+
}
1247+
],
1248+
"responses": {
1249+
"200": {
1250+
"content": {
1251+
"application/json": {
1252+
"schema": {
1253+
"$ref": "#/components/schemas/RoutingConfigSuccess"
1254+
}
1255+
}
1256+
},
1257+
"description": "200 response",
1258+
"headers": {
1259+
"Content-Type": {
1260+
"schema": {
1261+
"type": "string"
1262+
}
1263+
}
1264+
}
1265+
},
1266+
"default": {
1267+
"content": {
1268+
"application/json": {
1269+
"schema": {
1270+
"$ref": "#/components/schemas/Failure"
1271+
}
1272+
}
1273+
},
1274+
"description": "Error"
1275+
}
1276+
},
1277+
"security": [
1278+
{
1279+
"authorizer": []
1280+
}
1281+
],
1282+
"summary": "Finalise a routing configuration",
1283+
"x-amazon-apigateway-integration": {
1284+
"contentHandling": "CONVERT_TO_TEXT",
1285+
"credentials": "${APIG_EXECUTION_ROLE_ARN}",
1286+
"httpMethod": "POST",
1287+
"passthroughBehavior": "WHEN_NO_TEMPLATES",
1288+
"responses": {
1289+
".*": {
1290+
"statusCode": "200"
1291+
}
1292+
},
1293+
"timeoutInMillis": 29000,
1294+
"type": "AWS_PROXY",
1295+
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${SUBMIT_ROUTING_CONFIG_LAMBDA_ARN}/invocations"
1296+
}
11581297
}
11591298
},
11601299
"/v1/routing-configurations": {
@@ -1477,7 +1616,7 @@
14771616
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${GET_LAMBDA_ARN}/invocations"
14781617
}
14791618
},
1480-
"post": {
1619+
"put": {
14811620
"description": "Update a template template by Id",
14821621
"parameters": [
14831622
{
@@ -1619,10 +1758,10 @@
16191758
},
16201759
"/v1/template/{templateId}/submit": {
16211760
"patch": {
1622-
"description": "Update a template status by Id",
1761+
"description": "Submit a template by Id",
16231762
"parameters": [
16241763
{
1625-
"description": "ID of template to update",
1764+
"description": "ID of template to submit",
16261765
"in": "path",
16271766
"name": "templateId",
16281767
"required": true,

0 commit comments

Comments
 (0)