diff --git a/lambdas/excel_ingestion/lambda.tf b/lambdas/excel_ingestion/lambda.tf index b303501..a629ab6 100644 --- a/lambdas/excel_ingestion/lambda.tf +++ b/lambdas/excel_ingestion/lambda.tf @@ -20,7 +20,6 @@ module "lambda_function_container_image" { memory_size = 256 role_name = "${local.lambda_function_name}-role" attach_policy_statements = true - # see https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/346 source_path = "${path.module}/src" policy_statements = { diff --git a/lambdas/excel_ingestion/src/index.py b/lambdas/excel_ingestion/src/index.py index 63f350b..807a3c5 100644 --- a/lambdas/excel_ingestion/src/index.py +++ b/lambdas/excel_ingestion/src/index.py @@ -13,7 +13,6 @@ def lambda_handler(event, context): """ try: print(event) - bucket, key = event['xlsx_s3_uri'].replace("s3://", "").split("/", 1) print(f"File located at bucket: {bucket} and key: {key}") diff --git a/state_machines/rfp_email_form_fill/state_machine.json b/state_machines/rfp_email_form_fill/state_machine.json index dfca97b..a3b73a4 100644 --- a/state_machines/rfp_email_form_fill/state_machine.json +++ b/state_machines/rfp_email_form_fill/state_machine.json @@ -280,6 +280,11 @@ "Variable": "$", "StringMatches": "*.docx", "Next": "Extract text from DOCX" + }, + { + "Variable": "$", + "StringMatches": "*.xlsx", + "Next": "Extract CSV from XLSX" } ], "Default": "Filter out unsupported attachment", @@ -355,6 +360,34 @@ "ResultSelector": { "extracted_text.$": "States.Array($.Payload.attachment_uri)" } + }, + "Extract CSV from XLSX": { + "Type": "Task", + "Resource": "arn:aws:states:::lambda:invoke", + "OutputPath": "$.extracted_csv_uri", + "Parameters": { + "Payload": { + "xlsx_s3_uri.$": "$" + }, + "FunctionName": "arn:aws:lambda:us-east-1:446872271111:function:levio-esta-excel-ingestion-dev:$LATEST" + }, + "Retry": [ + { + "ErrorEquals": [ + "Lambda.ServiceException", + "Lambda.AWSLambdaException", + "Lambda.SdkClientException", + "Lambda.TooManyRequestsException" + ], + "IntervalSeconds": 1, + "MaxAttempts": 3, + "BackoffRate": 2 + } + ], + "End": true, + "ResultSelector": { + "extracted_csv_uri.$": "States.Array($.Payload.extracted_csv_uri)" + } } } },