Skip to content

Commit 66eb330

Browse files
feat: Allow multiple filters in event source mappings (#379)
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
1 parent f4861b7 commit 66eb330

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

examples/event-source-mapping/main.tf

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ 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-
}
34+
filter_criteria = [
35+
{
36+
pattern = jsonencode({
37+
eventName : ["INSERT"]
38+
})
39+
},
40+
{
41+
pattern = jsonencode({
42+
data : {
43+
Temperature : [{ numeric : [">", 0, "<=", 100] }]
44+
Location : ["Oslo"]
45+
}
46+
})
47+
}
48+
]
3949
}
4050
kinesis = {
4151
event_source_arn = aws_kinesis_stream.this.arn

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,12 @@ resource "aws_lambda_event_source_mapping" "this" {
307307
for_each = try(each.value.filter_criteria, null) != null ? [true] : []
308308

309309
content {
310-
filter {
311-
pattern = try(each.value["filter_criteria"].pattern, null)
310+
dynamic "filter" {
311+
for_each = try(flatten([each.value.filter_criteria]), [])
312+
313+
content {
314+
pattern = try(filter.value.pattern, null)
315+
}
312316
}
313317
}
314318
}

0 commit comments

Comments
 (0)