-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When using:
- a standard (non-FIFO) SQS queue
- a lambda event source mapping with a batching window defined (ex: 300 seconds)
...the maximum batch size for SQS event source mappings is capped at 10. For relevant code, see:
localstack/localstack/services/awslambda/lambda_api.py
Lines 92 to 97 in 7374028
BATCH_SIZE_RANGES = { | |
"kafka": (100, 10000), | |
"kinesis": (100, 10000), | |
"dynamodb": (100, 1000), | |
"sqs": (10, 10), | |
} |
Setting this value to one greater than 10 results in the following error message:
In Docker logs:
localstack_1 | 2021-11-30T18:02:13:INFO:localstack.services.awslambda.lambda_api: BatchSize 100 exceeds the max of 10
On CLI:
An error occurred (InvalidParameterValueException) when calling the CreateEventSourceMapping operation: BatchSize 100 exceeds the max of 10
Expected Behavior
As of Nov 24, 2020, this maximum batch size has changed for standard SQS queues.
Previously, Lambda functions polling from an SQS queue would send messages in batches of up to 10 before invoking the function. Now, customers can also define a time window that Lambda should wait to poll messages from their SQS queue before invoking their function. Lambda will wait for up to 300 seconds to poll messages from the SQS queue. When a batch window is defined, Lambda will also allow customers to define a batch size of up to 10,000 messages.
The current rules can be found here: https://docs.aws.amazon.com/lambda/latest/dg/API_CreateEventSourceMapping.html#API_CreateEventSourceMapping_RequestBody
Batch Size
...
Amazon Simple Queue Service - Default 10. For standard queues the max is 10,000. For FIFO queues the max is 10.
The expectation is that localstack will recognize that a 10,000 >= batch size > 10
is valid for standard SQS queues.
How are you starting LocalStack?
Custom (please describe below)
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack
command, arguments, or docker-compose.yml
)
We run localstack via a docker-compose file. The initial infrastructure (SQS, lambda, etc) is provisioned with terraform.
docker-compose --env-file .env.local up
cd <terraform_folder>
terraform init
terraform workspace select local
terraform apply
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
Then to reproduce the error, you can either add the event source mapping via the terraform plan and use terraform apply
to provision the changes, or you can do it via the CLI inside of the container. For example:
awslocal lambda create-event-source-mapping \
--function-name my-function \
--batch-size 100 \
--maximum-batching-window-in-seconds 300 \
--event-source-arn arn:aws:sqs:us-east-1:000000000000:my-sqs-queue-arn
Environment
Whatever the localstack Docker container runs on.
Host:
- OS: macOS Catalina (v10.15.7)
- LocalStack: `localstack/localstack:latest`
Anything else?
No response