terraform-aws-modules/terraform-aws-lambda

Support multiple filters in event source mappings

moritzzimmer opened this issue · 7 comments

Is your request related to a new offering from AWS?

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

  • Yes ✅: please list the AWS provider version which introduced this functionality

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"]
            }
          })
        }
      ]
    }

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

PR is welcome, as always

I'll work on a PR for this

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

This issue was automatically closed because of stale in 10 days

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.

This issue has been resolved in version 4.10.0 🎉