Skip to content

Commit 159f57a

Browse files
svenlitosvnlto
andauthored
feat: Add event filter criteria capabilities (#242)
Co-authored-by: Sven Lito <[email protected]>
1 parent 6299478 commit 159f57a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

examples/event-source-mapping/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,23 @@ module "lambda_function" {
3131
event_source_arn = aws_dynamodb_table.this.stream_arn
3232
starting_position = "LATEST"
3333
destination_arn_on_failure = aws_sqs_queue.failure.arn
34+
filter_criteria = {
35+
pattern = jsonencode({
36+
eventName : ["INSERT"]
37+
})
38+
}
3439
}
3540
kinesis = {
3641
event_source_arn = aws_kinesis_stream.this.arn
3742
starting_position = "LATEST"
43+
filter_criteria = {
44+
pattern = jsonencode({
45+
data : {
46+
Temperature : [{ numeric : [">", 0, "<=", 100] }]
47+
Location : ["Oslo"]
48+
}
49+
})
50+
}
3851
}
3952
mq = {
4053
event_source_arn = aws_mq_broker.this.arn

main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,14 @@ resource "aws_lambda_event_source_mapping" "this" {
256256
uri = source_access_configuration.value["uri"]
257257
}
258258
}
259+
260+
dynamic "filter_criteria" {
261+
for_each = lookup(each.value, "filter_criteria", null) != null ? [true] : []
262+
263+
content {
264+
filter {
265+
pattern = lookup(filter_criteria, "pattern", null)
266+
}
267+
}
268+
}
259269
}

0 commit comments

Comments
 (0)