Skip to content

Commit 5673d2c

Browse files
committed
for PoC, generate new ID for each upsert
1 parent 8f103e9 commit 5673d2c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

infrastructure/instance/s3_config.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,11 @@ resource "aws_s3_bucket_policy" "batch_data_ea_bucket_policy" {
262262
Action : var.environment == "prod" ? [
263263
"s3:ListBucket",
264264
"s3:GetObject",
265+
"s3:PutObject",
265266
] : [
266267
"s3:ListBucket",
267268
"s3:GetObject",
269+
"s3:PutObject",
268270
"s3:DeleteObject"
269271
],
270272
Resource : [

lambdas/filenameprocessor/src/file_name_processor.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,17 @@ def handle_record(record) -> dict:
142142

143143
# NB: we don't have the vaccine type & supplier - we have to rethink the queue_name field.
144144
# Akin will talk to Paul
145+
146+
# ** NB! the current upsert_audit_table() does not allow duplicate message_id.
147+
# Surely we want to overwrite the PROCESSING message. (as a state machine)
148+
# To do: fix that method, and its unit tests.
149+
# For now, as a PoC, we'll generate a new message_id (and a new entry).
150+
message_id = str(uuid4())
145151

146152
if is_file_in_bucket(dest_bucket_name, file_key):
147153
status_code = 200
148154
message = (f"Successfully sent to {dest_bucket_name} for further processing",)
155+
logger.info(message)
149156
file_status = FileStatus.PROCESSED
150157
upsert_audit_table(
151158
message_id,
@@ -155,6 +162,7 @@ def handle_record(record) -> dict:
155162
queue_name,
156163
file_status,
157164
)
165+
logger.info("Deleting object from {bucket_name}")
158166
s3_client.delete_object(
159167
Bucket=bucket_name,
160168
Key=file_key,
@@ -163,6 +171,7 @@ def handle_record(record) -> dict:
163171
else:
164172
status_code = 400
165173
message = (f"Failed to send to {dest_bucket_name} for further processing",)
174+
logger.info(message)
166175
file_status = FileStatus.FAILED
167176
upsert_audit_table(
168177
message_id,

0 commit comments

Comments
 (0)