Skip to content

Commit 0d9c0f1

Browse files
committed
Revert "Migrate supplier updates so that they pass through new topic"
This reverts commit d39ec64.
1 parent b92543d commit 0d9c0f1

11 files changed

Lines changed: 33 additions & 40 deletions

infrastructure/terraform/components/api/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ locals {
2727
SUPPLIER_ID_HEADER = "nhsd-supplier-id",
2828
APIM_CORRELATION_HEADER = "nhsd-correlation-id",
2929
DOWNLOAD_URL_TTL_SECONDS = 60
30-
AMENDMENTS_TOPIC_ARN = "${module.eventsub.amendments_topic.arn}",
30+
SNS_TOPIC_ARN = "${module.eventsub.eventsub_topic.arn}",
3131
EVENT_SOURCE = "/data-plane/supplier-api/${var.group}/${var.environment}/letters"
3232
}
3333

infrastructure/terraform/components/api/module_lambda_amendment_event_transformer.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ data "aws_iam_policy_document" "amendment_event_transformer" {
9191
]
9292

9393
resources = [
94-
module.eventsub.amendments_topic.arn
94+
module.eventsub.eventsub_topic.arn
9595
]
9696
}
9797
}

infrastructure/terraform/components/api/module_sqs_letter_updates.tf

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@ module "sqs_letter_updates" {
1818

1919
data "aws_iam_policy_document" "letter_updates_queue_policy" {
2020
version = "2012-10-17"
21+
statement {
22+
sid = "AllowSNSToSendMessage"
23+
effect = "Allow"
24+
25+
principals {
26+
type = "Service"
27+
identifiers = ["sns.amazonaws.com"]
28+
}
29+
30+
actions = [
31+
"sqs:SendMessage"
32+
]
33+
34+
resources = [
35+
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${var.project}-${var.environment}-${var.component}-letter-updates-queue"
36+
]
37+
38+
condition {
39+
test = "ArnEquals"
40+
variable = "aws:SourceArn"
41+
values = [module.eventsub.eventsub_topic.arn]
42+
}
43+
}
2144

2245
statement {
2346
sid = "AllowSNSPermissions"
@@ -42,7 +65,7 @@ data "aws_iam_policy_document" "letter_updates_queue_policy" {
4265
condition {
4366
test = "ArnEquals"
4467
variable = "aws:SourceArn"
45-
values = [module.eventsub.eventsub_topic.arn, module.eventsub.amendments_topic.arn]
68+
values = [module.eventsub.eventsub_topic.arn]
4669
}
4770
}
4871
}

infrastructure/terraform/components/api/sns_topic_subscription_eventsub_sqs_letter_updates.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@ resource "aws_sns_topic_subscription" "eventsub_sqs_letter_updates" {
33
protocol = "sqs"
44
endpoint = module.sqs_letter_updates.sqs_queue_arn
55
}
6-
7-
resource "aws_sns_topic_subscription" "amendments_sqs_letter_updates" {
8-
topic_arn = module.eventsub.amendments_topic.arn
9-
protocol = "sqs"
10-
endpoint = module.sqs_letter_updates.sqs_queue_arn
11-
}

infrastructure/terraform/modules/eventsub/cloudwatch_log_group_sns_delivery_logging_failure.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,3 @@ resource "aws_cloudwatch_log_group" "sns_delivery_logging_failure" {
77
kms_key_id = var.kms_key_arn
88
retention_in_days = var.log_retention_in_days
99
}
10-
11-
resource "aws_cloudwatch_log_group" "amendments_sns_delivery_logging_failure" {
12-
count = var.enable_sns_delivery_logging ? 1 : 0
13-
14-
# SNS doesn't allow specifying a log group and is derived as: sns/${region}/${account_id}/${name_of_sns_topic}/Failure
15-
# (for failure logs)
16-
name = "sns/${var.region}/${var.aws_account_id}/${local.csi}-amendments/Failure"
17-
kms_key_id = var.kms_key_arn
18-
retention_in_days = var.log_retention_in_days
19-
}

infrastructure/terraform/modules/eventsub/cloudwatch_log_group_sns_delivery_logging_success.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,3 @@ resource "aws_cloudwatch_log_group" "sns_delivery_logging_success" {
77
kms_key_id = var.kms_key_arn
88
retention_in_days = var.log_retention_in_days
99
}
10-
11-
resource "aws_cloudwatch_log_group" "amendments_sns_delivery_logging_success" {
12-
count = var.enable_sns_delivery_logging ? 1 : 0
13-
14-
# SNS doesn't allow specifying a log group and is derived as: sns/${region}/${account_id}/${name_of_sns_topic}
15-
# (for success logs)
16-
name = "sns/${var.region}/${var.aws_account_id}/${local.csi}-amendments"
17-
kms_key_id = var.kms_key_arn
18-
retention_in_days = var.log_retention_in_days
19-
}

infrastructure/terraform/modules/eventsub/iam_policy_sns_delivery_logging_cloudwatch.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ data "aws_iam_policy_document" "sns_delivery_logging_cloudwatch" {
3939
"${aws_cloudwatch_log_group.sns_delivery_logging_success[0].arn}:log-stream:*",
4040
aws_cloudwatch_log_group.sns_delivery_logging_failure[0].arn,
4141
"${aws_cloudwatch_log_group.sns_delivery_logging_failure[0].arn}:log-stream:*",
42-
aws_cloudwatch_log_group.amendments_sns_delivery_logging_success[0].arn,
43-
"${aws_cloudwatch_log_group.amendments_sns_delivery_logging_success[0].arn}:log-stream:*",
44-
aws_cloudwatch_log_group.amendments_sns_delivery_logging_failure[0].arn,
45-
"${aws_cloudwatch_log_group.amendments_sns_delivery_logging_failure[0].arn}:log-stream:*",
4642
]
4743
}
4844
}

lambdas/api-handler/src/config/__tests__/env.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("lambdaEnv", () => {
2626
process.env.MAX_LIMIT = "2500";
2727
process.env.QUEUE_URL = "url";
2828
process.env.EVENT_SOURCE = "supplier-api";
29-
process.env.AMENDMENTS_TOPIC_ARN = "sns-topic.arn";
29+
process.env.SNS_TOPIC_ARN = "sns-topic.arn";
3030

3131
const { envVars } = require("../env");
3232

@@ -41,7 +41,7 @@ describe("lambdaEnv", () => {
4141
MAX_LIMIT: 2500,
4242
QUEUE_URL: "url",
4343
EVENT_SOURCE: "supplier-api",
44-
AMENDMENTS_TOPIC_ARN: "sns-topic.arn",
44+
SNS_TOPIC_ARN: "sns-topic.arn",
4545
});
4646
});
4747

@@ -66,7 +66,7 @@ describe("lambdaEnv", () => {
6666
process.env.MI_TTL_HOURS = "2160";
6767
process.env.DOWNLOAD_URL_TTL_SECONDS = "60";
6868
process.env.EVENT_SOURCE = "supplier-api";
69-
process.env.AMENDMENTS_TOPIC_ARN = "sns-topic.arn";
69+
process.env.SNS_TOPIC_ARN = "sns-topic.arn";
7070

7171
const { envVars } = require("../env");
7272

@@ -80,7 +80,7 @@ describe("lambdaEnv", () => {
8080
DOWNLOAD_URL_TTL_SECONDS: 60,
8181
MAX_LIMIT: undefined,
8282
EVENT_SOURCE: "supplier-api",
83-
AMENDMENTS_TOPIC_ARN: "sns-topic.arn",
83+
SNS_TOPIC_ARN: "sns-topic.arn",
8484
});
8585
});
8686
});

lambdas/api-handler/src/config/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const EnvVarsSchema = z.object({
1212
QUEUE_URL: z.coerce.string().optional(),
1313
PINO_LOG_LEVEL: z.coerce.string().optional(),
1414
EVENT_SOURCE: z.string(),
15-
AMENDMENTS_TOPIC_ARN: z.string(),
15+
SNS_TOPIC_ARN: z.string(),
1616
});
1717

1818
export type EnvVars = z.infer<typeof EnvVarsSchema>;

lambdas/api-handler/src/handlers/__tests__/amendment-event-transformer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe("createLetterStatusUpdateHandler", () => {
117117
i + 1,
118118
expect.objectContaining({
119119
input: expect.objectContaining({
120-
TopicArn: mockedDeps.env.AMENDMENTS_TOPIC_ARN,
120+
TopicArn: mockedDeps.env.SNS_TOPIC_ARN,
121121
Message: JSON.stringify(
122122
mapLetterToCloudEvent(
123123
updateLetterCommands[i] as Letter,

0 commit comments

Comments
 (0)