Skip to content

Commit

Permalink
extract xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed May 3, 2024
1 parent e2688a4 commit 9beb39f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 0 additions & 1 deletion lambdas/excel_ingestion/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 0 additions & 1 deletion lambdas/excel_ingestion/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
33 changes: 33 additions & 0 deletions state_machines/rfp_email_form_fill/state_machine.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)"
}
}
}
},
Expand Down

0 comments on commit 9beb39f

Please sign in to comment.