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
892 stars 662 forks source link

Support multiple filters in event source mappings #350

Closed moritzzimmer closed 1 year ago

moritzzimmer commented 1 year ago

Is your request related to a new offering from AWS?

Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.

Is your request related to a problem?

Lambda supports up to five different filters for a single event source. It seems like the module currently only supports defining one filter.

dynamic "filter_criteria" {
    for_each = try(each.value.filter_criteria, null) != null ? [true] : []

    content {
      filter {
        pattern = try(each.value["filter_criteria"].pattern, null)
      }
    }
  }

Describe the solution you'd like.

Support multiple filter elements in filter_criteria (e.g. by providing a list of filters) in the aws_lambda_event_source_mapping:

dynamic "filter_criteria" {
    for_each = lookup(each.value, "filter_criteria", null) != null ? [true] : []

    content {
      dynamic "filter" {
        for_each = try(each.value.filter_criteria, [])
        content {
          pattern = try(filter.value.pattern, "")
        }
      }
    }
  }

example usage:

filter_criteria = [
        {
          pattern = jsonencode({
            data : {
              foo : ["bar"]
            }
          })
        },
        {
          pattern = jsonencode({
            data : {
              bar : ["foo"]
            }
          })
        }
      ]
    }
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

antonbabenko commented 1 year ago

PR is welcome, as always

moritzzimmer commented 1 year ago

I'll work on a PR for this

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 1 year 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.

antonbabenko commented 1 year ago

This issue has been resolved in version 4.10.0 :tada: