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 filter criteria does not work #271

Closed
sindrig opened this issue Feb 23, 2022 · 2 comments · Fixed by #272
Closed

Event source filter criteria does not work #271

sindrig opened this issue Feb 23, 2022 · 2 comments · Fixed by #272

Comments

@sindrig
Copy link
Contributor

sindrig commented Feb 23, 2022

Description

Following the example here you get an empty filter in the filter_criteria of the resource aws_lambda_event_source_mapping.

Terraform will perform the following actions:

  # module.lambda_function.aws_lambda_event_source_mapping.this["dynamodb"] will be updated in-place
  ~ resource "aws_lambda_event_source_mapping" "this" {
        id                                 = "a4f49422-beff-4a9d-b7c4-8bd94a09bf2c"
        # (20 unchanged attributes hidden)


      + filter_criteria {
          + filter {}
        }
        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
╷
│ Warning: Argument is deprecated
│
│   with module.lambda_function.aws_s3_bucket_object.lambda_package,
│   on .terraform/modules/lambda_function/main.tf line 124, in resource "aws_s3_bucket_object" "lambda_package":
│  124:   bucket        = var.s3_bucket
│
│ Use the aws_s3_object resource instead
│
│ (and one more similar warning elsewhere)
╵

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.lambda_function.aws_lambda_event_source_mapping.this["dynamodb"]: Modifying... [id=a4f49422-beff-4a9d-b7c4-8bd94a09bf2c]
╷
│ Error: error updating Lambda Event Source Mapping (a4f49422-beff-4a9d-b7c4-8bd94a09bf2c): InvalidParameterValueException: Invalid filter pattern definition.
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "6b5a928a-e4ef-42c4-89c0-59a4d92503c4"
│   },
│   Message_: "Invalid filter pattern definition.",
│   Type: "User"
│ }
│
│   with module.lambda_function.aws_lambda_event_source_mapping.this["dynamodb"],
│   on .terraform/modules/lambda_function/main.tf line 223, in resource "aws_lambda_event_source_mapping" "this":
│  223: resource "aws_lambda_event_source_mapping" "this" {

Versions

$ terraform -version
Terraform v1.1.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.2.0
+ provider registry.terraform.io/hashicorp/external v2.2.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0

Module version: 2.34.0

Reproduction

Steps to reproduce the behavior:

event_source_mapping = {
    dynamodb = {
      event_source_arn           = module.services.dynamodb_table_stream_arn
      starting_position          = "LATEST"
      destination_arn_on_failure = aws_sqs_queue.failure.arn
      filter_criteria = {
        pattern = jsonencode({
          eventName = ["INSERT", "MODIFY"]
        })
      }
    }
  }

Expected behavior

A filter criteria like this:

    + filter_criteria {
          + filter {
              + pattern = jsonencode(
                    {
                      + eventName = [
                          + "INSERT",
                          + "MODIFY",
                        ]
                    }
                )
            }
        }

Actual behavior

An empty filter criteria:


      + filter_criteria {
          + filter {}
        }
@sindrig sindrig changed the title Event source filter criteri does not work Event source filter criteria does not work Feb 23, 2022
sindrig added a commit to sindrig/terraform-aws-lambda that referenced this issue Feb 23, 2022
@antonbabenko
Copy link
Member

This issue has been resolved in version 2.34.1 🎉

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants