File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
lambdas/csv_to_glue_catalog Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Automatically creates/deletes Glue Catalog tables when CSV files are uploaded/deleted in S3.
3+ """
4+
15import json
26import logging
37import re
Original file line number Diff line number Diff line change 11# Lambda function to automatically create/delete Glue Catalog tables
2- # Workflow: S3 CSV upload/delete → SQS queue → Lambda (via event source mapping) → Glue Catalog table create/delete
2+ # Workflow: S3 CSV upload/delete → SQS → Lambda (via event source mapping) → Glue Catalog table create/delete (retry on failure → DLQ)
33
44data "aws_iam_policy_document" "csv_to_glue_catalog_lambda_assume_role" {
55 statement {
@@ -130,12 +130,24 @@ module "csv_to_glue_catalog_lambda" {
130130}
131131
132132
133+ resource "aws_sqs_queue" "csv_to_glue_catalog_events_dlq" {
134+ name = " ${ local . short_identifier_prefix } csv-to-glue-catalog-events-dlq"
135+ message_retention_seconds = 1209600 # 14 days
136+
137+ tags = module. tags . values
138+ }
139+
133140resource "aws_sqs_queue" "csv_to_glue_catalog_events" {
134141 name = " ${ local . short_identifier_prefix } csv-to-glue-catalog-events"
135142 visibility_timeout_seconds = 900
136143 message_retention_seconds = 1209600
137144 receive_wait_time_seconds = 20
138145
146+ redrive_policy = jsonencode ({
147+ deadLetterTargetArn = aws_sqs_queue.csv_to_glue_catalog_events_dlq.arn
148+ maxReceiveCount = 2 # 2 attempts before sending to DLQ
149+ })
150+
139151 tags = module. tags . values
140152}
141153
You can’t perform that action at this time.
0 commit comments