Skip to content

Commit 16651dc

Browse files
add supplier-mock config in parameter store whith specificationId mapping
1 parent cfcdfef commit 16651dc

9 files changed

Lines changed: 417 additions & 204 deletions

File tree

infrastructure/terraform/components/api/module_lambda_supplier_mock.tf

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,25 @@ module "supplier_mock" {
3636
log_subscription_role_arn = local.acct.log_subscription_role_arn
3737

3838
lambda_env_vars = merge(local.common_lambda_env_vars, {
39-
ENVIRONMENT = var.environment
40-
GET_LETTERS_FUNCTION_NAME = module.get_letters.function_name
41-
PATCH_LETTER_FUNCTION_NAME = module.patch_letter.function_name
42-
SUPPLIER_MOCK_GET_LETTERS_LIMIT_PARAM_NAME = aws_ssm_parameter.supplier_mock_get_letters_limit[0].name
43-
SUPPLIER_MOCK_SUPPLIER_ID = aws_ssm_parameter.supplier_mock_supplier_id[0].name
39+
ENVIRONMENT = var.environment
40+
GET_LETTERS_FUNCTION_NAME = module.get_letters.function_name
41+
PATCH_LETTER_FUNCTION_NAME = module.patch_letter.function_name
42+
SUPPLIER_MOCK_CONFIG_PARAM_NAME = aws_ssm_parameter.supplier_mock_config[0].name
4443
})
4544
}
4645

47-
resource "aws_ssm_parameter" "supplier_mock_get_letters_limit" {
46+
resource "aws_ssm_parameter" "supplier_mock_config" {
4847
count = var.deploy_supplier_mock_scheduler ? 1 : 0
49-
name = format("/nhs/supapi/supplier-mock/%s/get-letters-limit", var.environment)
50-
description = "Default get_letters limit for supplier mock lambda"
48+
name = format("/nhs/supapi/%s/supplier-mock/config", var.environment)
49+
description = "JSON object containing supplier mock config for supplierID, getLetters limit, specificationId mapping, etc."
5150
type = "String"
52-
value = "100"
53-
54-
lifecycle {
55-
ignore_changes = [value]
56-
}
57-
}
58-
59-
resource "aws_ssm_parameter" "supplier_mock_supplier_id" {
60-
count = var.deploy_supplier_mock_scheduler ? 1 : 0
61-
name = format("/nhs/supapi/supplier-mock/%s/supplier-id", var.environment)
62-
description = "Supplier ID to be used by the supplier mock lambda"
63-
type = "String"
64-
value = "TestSupplier1"
51+
value = jsonencode({
52+
limit = "100"
53+
supplier_id = "TestSupplier1"
54+
specification_id_mapping = {
55+
"test-specification-id-1" = "ACCEPTED"
56+
}
57+
})
6558

6659
lifecycle {
6760
ignore_changes = [value]
@@ -98,16 +91,15 @@ data "aws_iam_policy_document" "supplier_mock_lambda" {
9891
}
9992

10093
statement {
101-
sid = "AllowReadSupplierMockLimitParameter"
94+
sid = "AllowReadSupplierMockConfigParameter"
10295
effect = "Allow"
10396

10497
actions = [
10598
"ssm:GetParameter",
10699
]
107100

108101
resources = [
109-
aws_ssm_parameter.supplier_mock_get_letters_limit[0].arn,
110-
aws_ssm_parameter.supplier_mock_supplier_id[0].arn
102+
aws_ssm_parameter.supplier_mock_config[0].arn
111103
]
112104
}
113105
}

infrastructure/terraform/components/api/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ variable "enable_alarms" {
226226
description = "Enable CloudWatch alarms for this deployed environment"
227227
default = true
228228
}
229-
229+
# Set value back to false before merging to main.
230230
variable "deploy_supplier_mock_scheduler" {
231231
type = bool
232232
description = "Deploy EventBridge Scheduler trigger for supplier mock lambda"

0 commit comments

Comments
 (0)