Skip to content

Commit 4e3f64f

Browse files
committed
CCM-11352: use new module
1 parent e6a2fe6 commit 4e3f64f

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

infrastructure/terraform/components/sandbox/module_eventpub.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "eventpub" {
2-
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/eventpub?ref=v2.0.16"
2+
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/eventpub?ref=v2.0.19"
33

44
name = "eventpub"
55

@@ -13,10 +13,12 @@ module "eventpub" {
1313
log_retention_in_days = var.log_retention_in_days
1414
kms_key_arn = data.aws_kms_key.sandbox.arn
1515

16-
enable_event_cache = true
17-
enable_sns_delivery_logging = false
18-
event_cache_buffer_interval = 0
19-
sns_success_logging_sample_percent = 0
16+
enable_event_cache = true
17+
enable_sns_delivery_logging = false
18+
enable_firehose_raw_message_delivery = true
19+
event_cache_buffer_interval = 0
20+
sns_success_logging_sample_percent = 0
21+
force_destroy = true
2022

2123
# In the context of sbx these planes are not needed but the module require them
2224
data_plane_bus_arn = aws_sns_topic.events.arn

tests/test-team/helpers/events/event-cache-helper.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class EventCacheHelper {
3333
}
3434

3535
const files = await Promise.all(
36-
this.filePaths(from).map((path) => {
36+
this.buildFilePaths(from).map((path) => {
3737
return S3Helper.listAll(this.bucketName, path);
3838
})
3939
);
@@ -91,12 +91,9 @@ export class EventCacheHelper {
9191
.split('\n')
9292
.filter((line) => line.trim())
9393
.map((line) => {
94-
const snsWrapper = JSON.parse(line);
95-
96-
const message = JSON.parse(snsWrapper.Message);
97-
98-
const { data, success, error } =
99-
$NHSNotifyTemplateEvent.safeParse(message);
94+
const { data, success, error } = $NHSNotifyTemplateEvent.safeParse(
95+
JSON.parse(line)
96+
);
10097

10198
if (!success) {
10299
throw new Error(
@@ -118,34 +115,32 @@ export class EventCacheHelper {
118115

119116
/*
120117
* Get files paths for the current hour
121-
* and next hour if the different in seconds is greater than toleranceInSeconds
118+
* and next hour if the difference in seconds is greater than toleranceInSeconds
122119
*
123120
* The way firehose stores files is yyyy/mm/dd/hh.
124121
* On a boundary of 15:59:58 you'll find files in both 15 and 16 hour folders
125122
*/
126-
private filePaths(start: Date, toleranceInSeconds = 30): string[] {
127-
const paths = [this.getEventCachePrefix(start)];
123+
private buildFilePaths(start: Date, toleranceInSeconds = 30): string[] {
124+
const paths = [this.buildPathPrefix(start)];
128125

129126
const end = addHours(start, 1);
130127

131128
const difference = differenceInSeconds(end, start);
132129

133130
if (difference >= toleranceInSeconds) {
134-
paths.push(this.getEventCachePrefix(end));
131+
paths.push(this.buildPathPrefix(end));
135132
}
136133

137134
return paths;
138135
}
139136

140137
private buildS3Query(templateIds: string[]): string {
141-
const likeConditions = templateIds
142-
.map((id) => `s.Message LIKE '%${id}%'`)
143-
.join(' OR ');
138+
const formattedIds = templateIds.map((r) => `'${r}'`);
144139

145-
return `SELECT * FROM S3Object s WHERE ${likeConditions}`;
140+
return `SELECT * FROM S3Object s WHERE s.data.id IN (${formattedIds})`;
146141
}
147142

148-
private getEventCachePrefix(date: Date): string {
143+
private buildPathPrefix(date: Date): string {
149144
return date
150145
.toISOString()
151146
.slice(0, 13)

0 commit comments

Comments
 (0)