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

fix(forwarder): filter eventbridge triggers by source bucket #175

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions modules/forwarder/eventbridge.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
resource "aws_cloudwatch_event_rule" "this" {
# Ideally we'd only gate this resource on the source bucket names, i.e:
#
# count = length(var.source_bucket_names) > 0 ? 1 : 0
#
# This formulation would potentially depend on resources that can only be
# determined at apply, so instead we adjust our event pattern to filter all
# events out if no source buckets are provided.
name_prefix = local.name_prefix
description = "Trigger copy for object created events"
event_bus_name = "default"

event_pattern = jsonencode(
{
source = ["aws.s3"]
detail-type = ["Object Created"],
},
)
event_pattern = jsonencode({
"source" = ["aws.s3"]
"detail-type" = ["Object Created"],
"detail.bucket.name" = [
# list must have elements, so we introduce an empty match
for name in concat([""], var.source_bucket_names) : { "wildcard" : name }
],
})
}

resource "aws_cloudwatch_event_target" "this" {
Expand Down
Loading