terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 656 forks source link

event source mapping with multiple sqs queues #520

Closed malolnaor closed 6 months ago

malolnaor commented 6 months ago

Is your request related to a problem? Please describe.

We want to invoke lambda function using event source mapping with multiple sqs queues. The following example in the docs seems to support only 1 sqs queue.

  event_source_mapping = {
    sqs = {
      event_source_arn        = aws_sqs_queue.example.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    }

Describe the solution you'd like.

There are 2 options I think of - The first one is to make event_source_arn sqs a list:

sqs = [{
      event_source_arn        = aws_sqs_queue.example.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    },
{
      event_source_arn        = aws_sqs_queue.example2.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    }
]

The second one is to create sqs twice(in current version only the second sqs definition is applied)

sqs = {
      event_source_arn        = aws_sqs_queue.example.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    }
sqs = {
      event_source_arn        = aws_sqs_queue.example2.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    }

Any other syntax is accepted.

malolnaor commented 6 months ago

After reviewing the code I found a way to do this:

sqs = {
      event_source_arn        = aws_sqs_queue.example.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    }
sqs2 = {
      event_source_arn        = aws_sqs_queue.example2.arn
      function_response_types = ["ReportBatchItemFailures"]
      scaling_config = {
        maximum_concurrency = 20
      }
    }

I'm closing this ticket

github-actions[bot] commented 5 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.