Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event_source_mapping support for batch windows of up to 5 minutes for functions with Amazon SQS #16503

Closed
with-joy opened this issue Dec 1, 2020 · 6 comments · Fixed by #16518
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/lambda Issues and PRs that pertain to the lambda service.
Milestone

Comments

@with-joy
Copy link
Contributor

with-joy commented Dec 1, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

AWS Lambda now supports batch windows of up to 5 minutes for functions with Amazon SQS as an event source. However, adding maximum_batching_window_in_seconds like below it throws an error:

resource "aws_lambda_event_source_mapping" "event_source_mapping" {
  batch_size = 100

  event_source_arn = aws_sqs_queue.some_queue.arn
  enabled          = true
  function_name    = aws_lambda_function.example_lambda.arn
  
  maximum_batching_window_in_seconds = 1
}
Error: Error updating Lambda event source mapping: InvalidParameterValueException: Maximum batch window in seconds must be greater than 0 if maximum batch size is greater than 10
{
  {
     StatusCode: 400,
     RequestID: "8e591cea-c8b2-4077-9f7a-55675c59f0aa"
  },
  Message_: "Maximum batch window in seconds must be greater than 0 if maximum batch size is greater than 10",
  Type: "User"
}

Seems like the param is not passed in the payload during update, eg:

{"BatchSize":100,"Enabled":true,"FunctionName":"arn:aws:lambda:us-east-1:xxxxxxxx:function:example_lambda"}

Please note that there is no issue in creating the event_source_mapping, but only when updating it.

CLI works fine though:

aws lambda update-event-source-mapping \
    --uuid xxxx-xxxxx-xxxx-xxxxx-xxxxxxx \
    --enabled \
    --batch-size 100 \
    --maximum-batching-window-in-seconds 1

New or Affected Resource(s)

Potential Terraform Configuration

resource "aws_lambda_event_source_mapping" "event_source_mapping" {
  batch_size = 100

  event_source_arn = aws_sqs_queue.some_queue.arn
  enabled          = true
  function_name    = aws_lambda_function.example_lambda.arn
  
  maximum_batching_window_in_seconds = 1
}

References

@with-joy with-joy added the enhancement Requests to existing resources that expand the functionality or scope. label Dec 1, 2020
@ghost ghost added the service/lambda Issues and PRs that pertain to the lambda service. label Dec 1, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Dec 1, 2020
@anGie44 anGie44 removed the needs-triage Waiting for first response or review from a maintainer. label Dec 1, 2020
@anGie44
Copy link
Contributor

anGie44 commented Dec 1, 2020

Hi @with-joy, thank you for raising this issue. Linking here the line in question that will need to be updated to account for sqs event sources on Update operations (assuming all the below params are compatible with SQS. if not we could instead move the line params.MaximumBatchingWindowInSeconds = aws.Int64(int64(d.Get("maximum_batching_window_in_seconds").(int))) outside of the if-condition):

if eventSourceArn.Service != "sqs" {

@with-joy
Copy link
Contributor Author

with-joy commented Dec 1, 2020

@anGie44 : thanks for the input. yes, I will try to open a PR with the change

@with-joy
Copy link
Contributor Author

with-joy commented Dec 1, 2020

Hi @anGie44, looks like the other params (in the if block) are not supported by SQS. Therefore have moved out MaximumBatchingWindowInSeconds outside of the if-condition.

@anGie44 anGie44 added this to the v3.20.0 milestone Dec 2, 2020
@anGie44
Copy link
Contributor

anGie44 commented Dec 2, 2020

Thanks again @with-joy! This feature has been merged and will release with v3.20.0 of the Terraform AWS provider.

@ghost
Copy link

ghost commented Dec 3, 2020

This has been released in version 3.20.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Jan 2, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
2 participants