Skip to content

Commit

Permalink
fix: Allow API destinations to reuse connections (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
magreenbaum committed Feb 5, 2024
1 parent 073a595 commit 78ac5d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions examples/with-api-destination/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ module "eventbridge" {
event_pattern = jsonencode({ "source" : ["myapp.orders"] })
state = "ENABLED" # conflicts with enabled which is deprecated
}
refunds = {
description = "Capture all refund data"
event_pattern = jsonencode({ "source" : ["myapp.refunds"] })
state = "ENABLED" # conflicts with enabled which is deprecated
}
}

targets = {
Expand All @@ -39,6 +44,13 @@ module "eventbridge" {
attach_role_arn = true
}
]
refunds = [
{
name = "send-refunds-to-github"
destination = "refunds_github"
attach_role_arn = true
}
]
}

connections = {
Expand Down Expand Up @@ -152,6 +164,14 @@ module "eventbridge" {
http_method = "POST"
invocation_rate_limit_per_second = 20
}
# reuse github connection
refunds_github = {
description = "my refunds to github endpoint"
invocation_endpoint = "https://smee.io/QaM356V2p1PFFZS"
http_method = "POST"
invocation_rate_limit_per_second = 20
connection_name = "github"
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ resource "aws_cloudwatch_event_api_destination" "this" {
invocation_endpoint = each.value.invocation_endpoint
http_method = each.value.http_method
invocation_rate_limit_per_second = lookup(each.value, "invocation_rate_limit_per_second", null)
connection_arn = aws_cloudwatch_event_connection.this[each.value.name].arn
connection_arn = try(aws_cloudwatch_event_connection.this[each.value.connection_name].arn, aws_cloudwatch_event_connection.this[each.value.name].arn)
}

resource "aws_scheduler_schedule_group" "this" {
Expand Down

0 comments on commit 78ac5d7

Please sign in to comment.