Skip to content

Commit 49d3f76

Browse files
committed
fix: create pre-built Lambda ZIP file to resolve deployment issues
1 parent c2d2ac3 commit 49d3f76

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed
Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,2 @@
1-
# Create Lambda function zip file using archive_file data source
2-
data "archive_file" "lambda_zip" {
3-
type = "zip"
4-
output_path = "${path.module}/lambda_function.zip"
5-
6-
source {
7-
content = <<-EOF
8-
import json
9-
10-
def lambda_handler(event, context):
11-
# Log event size to demonstrate payload limit breach
12-
event_size = len(json.dumps(event))
13-
print(f"Event size: {event_size} bytes, Records: {len(event.get('Records', []))}")
14-
15-
return {'statusCode': 200, 'body': f'Processed {len(event.get("Records", []))} messages'}
16-
EOF
17-
filename = "lambda_function.py"
18-
}
19-
}
1+
# Lambda function zip file (pre-created)
2+
# The lambda_function.zip file is created manually and committed to the repository
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import json
2+
3+
def lambda_handler(event, context):
4+
# Log event size to demonstrate payload limit breach
5+
event_size = len(json.dumps(event))
6+
print(f"Event size: {event_size} bytes, Records: {len(event.get('Records', []))}")
7+
8+
return {'statusCode': 200, 'body': f'Processed {len(event.get("Records", []))} messages'}
404 Bytes
Binary file not shown.

modules/scenarios/message-size-breach/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ resource "aws_sqs_queue" "image_processing_dlq" {
4141

4242
# Lambda function for processing images
4343
resource "aws_lambda_function" "image_processor" {
44-
filename = data.archive_file.lambda_zip.output_path
44+
filename = "${path.module}/lambda_function.zip"
4545
function_name = "image-processor-${var.example_env}"
4646
role = aws_iam_role.lambda_role.arn
4747
handler = "lambda_function.lambda_handler"
48-
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
48+
source_code_hash = filebase64sha256("${path.module}/lambda_function.zip")
4949
runtime = "python3.9"
5050
timeout = var.lambda_timeout
5151

0 commit comments

Comments
 (0)