From 4d0b3a851ff08e516aee0977c888ad599fcc5d23 Mon Sep 17 00:00:00 2001 From: Joel Balcaen Date: Thu, 2 May 2024 14:36:20 -0300 Subject: [PATCH] update state machine and lambda --- lambdas/rich_pdf_ingestion/src/index.py | 11 +---------- state_machines/rfp_email_form_fill/state_machine.json | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/lambdas/rich_pdf_ingestion/src/index.py b/lambdas/rich_pdf_ingestion/src/index.py index 9702871..ba6df1d 100644 --- a/lambdas/rich_pdf_ingestion/src/index.py +++ b/lambdas/rich_pdf_ingestion/src/index.py @@ -16,10 +16,9 @@ def lambda_handler(event, context): Etract text/tables from a PDF and store in a s3 object """ print(event) - attachment_s3_arn = event['path'] try: - bucket, key = parse_s3_arn(attachment_s3_arn) + bucket, key = event['pdf_s3_uri'].replace("s3://", "").split("/", 1) print(f"Attachment located at bucket: {bucket} and key: {key}") @@ -70,14 +69,6 @@ def extract_text_from_pdf(pdf_file_path): return text - -def parse_s3_arn(s3_arn): - s3_path = s3_arn.replace("arn:aws:s3:::", "") - components = s3_path.split("/") - bucket = components[0] - key = "/".join(components[1:]) - return bucket, key - def fetch_file(bucket, key): local_filename = f"{PATH_TO_WRITE_FILES}/{key.split('/')[-1]}" s3.download_file(bucket, key, local_filename) diff --git a/state_machines/rfp_email_form_fill/state_machine.json b/state_machines/rfp_email_form_fill/state_machine.json index 637023f..80bbf78 100644 --- a/state_machines/rfp_email_form_fill/state_machine.json +++ b/state_machines/rfp_email_form_fill/state_machine.json @@ -272,7 +272,7 @@ "Parameters": { "FunctionName": "arn:aws:lambda:us-east-1:446872271111:function:rich_pdf_ingestion:$LATEST", "Payload": { - "path.$": "$" + "pdf_s3_uri.$": "$" } }, "Resource": "arn:aws:states:::lambda:invoke",