[SQS and Lambda] Lambda function not properly deployed because queue visibility timeout is less than Function timeout #18099
Labels
bug
Addresses a defect in current functionality.
service/lambda
Issues and PRs that pertain to the lambda service.
service/sqs
Issues and PRs that pertain to the sqs service.
Milestone
AWS lambda is not properly deployed because queue visibility timeout is less than Lambda Function timeout
Terraform CLI and Terraform AWS Provider Version
0.13.6
Affected Resource(s)
aws_lambda
Terraform Configuration Files
sqs queue resource configuration:
resource "aws_sqs_queue" "queue" {
name = "sqs-qeue"
message_retention_seconds = 1209600
visibility_timeout_seconds = 400
}
lambda function configuration:
resource "aws_lambda_function" "document_processing_lambda" {
filename = "lambda_function_payload.zip"
function_name = "lambda_function_name"
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.test"
source_code_hash = filebase64sha256("lambda_function_payload.zip")
runtime = "java11"
memory_size = "2048"
timeout = "900"
environment {
variables = {
env= "staging"
}
}
}
aws_lambda_event_source_mapping
resource "aws_lambda_event_source_mapping" "lambda_sqs" {
depends_on = [aws_sqs_queue.queue]
event_source_arn = aws_sqs_queue.queue.arn
function_name = aws_lambda_function.document_processing_lambda.name
batch_size = 10
}
Panic Output
Expected Behavior
This error should be thrown when deploying:
Error: Error creating Lambda event source mapping: InvalidParameterValueException: Queue visibility timeout: 400 seconds is less than Function timeout: 900 seconds
Actual Behavior
No error is thrown at the first deployment and the lambda function is deployed with an incoherent state and does not consume messages from the SQS queue, all this happens silently and messages were lost from the queue because no error is thrown.
Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: