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: Make it optional to append postfix to the name, connection, or API destination #58

Merged
merged 12 commits into from
Jul 28, 2022
2 changes: 2 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module "eventbridge" {

attach_cloudwatch_policy = true
cloudwatch_target_arns = [aws_cloudwatch_log_group.this.arn]

append_rule_postfix = false

attach_ecs_policy = true
ecs_target_arns = [aws_ecs_task_definition.hello_world.arn]
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ locals {
for index, rule in var.rules :
merge(rule, {
"name" = index
"Name" = "${replace(index, "_", "-")}-rule"
"Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index
})
])
eventbridge_targets = flatten([
for index, rule in var.rules : [
for target in var.targets[index] :
merge(target, {
"rule" = index
"Name" = "${replace(index, "_", "-")}-rule"
"Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index
})
] if length(var.targets) != 0
])
eventbridge_connections = flatten([
for index, conn in var.connections :
merge(conn, {
"name" = index
"Name" = "${replace(index, "_", "-")}-connection"
"Name" = var.append_connection_postfix ? "${replace(index, "_", "-")}-connection" : index
})
])
eventbridge_api_destinations = flatten([
for index, dest in var.api_destinations :
merge(dest, {
"name" = index
"Name" = "${replace(index, "_", "-")}-destination"
"Name" = var.append_destination_postfix ? "${replace(index, "_", "-")}-destination" : index
})
])
}
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ variable "create_role" {
default = true
}

variable "append_rule_postfix" {
description = "Controls whether to append '-rule' to the name of the rule"
type = bool
default = true
}

variable "append_connection_postfix" {
description = "Controls whether to append '-connection' to the name of the connection"
type = bool
default = true
}

variable "append_destination_postfix" {
description = "Controls whether to append '-destination' to the name of the destination"
type = bool
default = true
}

variable "create_bus" {
description = "Controls whether EventBridge Bus resource should be created"
type = bool
Expand Down