Skip to content

Commit

Permalink
feat: Add event filter criteria capabilities (#242)
Browse files Browse the repository at this point in the history
Co-authored-by: Sven Lito <[email protected]>
  • Loading branch information
svenlito and svnlto authored Jan 31, 2022
1 parent 6299478 commit 159f57a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/event-source-mapping/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,23 @@ module "lambda_function" {
event_source_arn = aws_dynamodb_table.this.stream_arn
starting_position = "LATEST"
destination_arn_on_failure = aws_sqs_queue.failure.arn
filter_criteria = {
pattern = jsonencode({
eventName : ["INSERT"]
})
}
}
kinesis = {
event_source_arn = aws_kinesis_stream.this.arn
starting_position = "LATEST"
filter_criteria = {
pattern = jsonencode({
data : {
Temperature : [{ numeric : [">", 0, "<=", 100] }]
Location : ["Oslo"]
}
})
}
}
mq = {
event_source_arn = aws_mq_broker.this.arn
Expand Down
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,14 @@ resource "aws_lambda_event_source_mapping" "this" {
uri = source_access_configuration.value["uri"]
}
}

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

content {
filter {
pattern = lookup(filter_criteria, "pattern", null)
}
}
}
}

0 comments on commit 159f57a

Please sign in to comment.