Skip to content

Support multiple filters in event source mappings #350

@moritzzimmer

Description

@moritzzimmer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions