Skip to content

Commit 980b910

Browse files
authored
fix: Make it optional to append postfix to the name, connection, or API destination (terraform-aws-modules#58)
1 parent 75c970a commit 980b910

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ No modules.
424424
| Name | Description | Type | Default | Required |
425425
|------|-------------|------|---------|:--------:|
426426
| <a name="input_api_destinations"></a> [api\_destinations](#input\_api\_destinations) | A map of objects with EventBridge Destination definitions. | `map(any)` | `{}` | no |
427+
| <a name="input_append_connection_postfix"></a> [append\_connection\_postfix](#input\_append\_connection\_postfix) | Controls whether to append '-connection' to the name of the connection | `bool` | `true` | no |
428+
| <a name="input_append_destination_postfix"></a> [append\_destination\_postfix](#input\_append\_destination\_postfix) | Controls whether to append '-destination' to the name of the destination | `bool` | `true` | no |
429+
| <a name="input_append_rule_postfix"></a> [append\_rule\_postfix](#input\_append\_rule\_postfix) | Controls whether to append '-rule' to the name of the rule | `bool` | `true` | no |
427430
| <a name="input_archives"></a> [archives](#input\_archives) | A map of objects with the EventBridge Archive definitions. | `map(any)` | `{}` | no |
428431
| <a name="input_attach_api_destination_policy"></a> [attach\_api\_destination\_policy](#input\_attach\_api\_destination\_policy) | Controls whether the API Destination policy should be added to IAM role for EventBridge Target | `bool` | `false` | no |
429432
| <a name="input_attach_cloudwatch_policy"></a> [attach\_cloudwatch\_policy](#input\_attach\_cloudwatch\_policy) | Controls whether the Cloudwatch policy should be added to IAM role for EventBridge Target | `bool` | `false` | no |

examples/complete/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ module "eventbridge" {
3535
attach_cloudwatch_policy = true
3636
cloudwatch_target_arns = [aws_cloudwatch_log_group.this.arn]
3737

38+
append_rule_postfix = false
39+
3840
attach_ecs_policy = true
3941
ecs_target_arns = [aws_ecs_task_definition.hello_world.arn]
4042

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ locals {
33
for index, rule in var.rules :
44
merge(rule, {
55
"name" = index
6-
"Name" = "${replace(index, "_", "-")}-rule"
6+
"Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index
77
})
88
])
99
eventbridge_targets = flatten([
1010
for index, rule in var.rules : [
1111
for target in var.targets[index] :
1212
merge(target, {
1313
"rule" = index
14-
"Name" = "${replace(index, "_", "-")}-rule"
14+
"Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index
1515
})
1616
] if length(var.targets) != 0
1717
])
1818
eventbridge_connections = flatten([
1919
for index, conn in var.connections :
2020
merge(conn, {
2121
"name" = index
22-
"Name" = "${replace(index, "_", "-")}-connection"
22+
"Name" = var.append_connection_postfix ? "${replace(index, "_", "-")}-connection" : index
2323
})
2424
])
2525
eventbridge_api_destinations = flatten([
2626
for index, dest in var.api_destinations :
2727
merge(dest, {
2828
"name" = index
29-
"Name" = "${replace(index, "_", "-")}-destination"
29+
"Name" = var.append_destination_postfix ? "${replace(index, "_", "-")}-destination" : index
3030
})
3131
])
3232
}

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ variable "create_role" {
1010
default = true
1111
}
1212

13+
variable "append_rule_postfix" {
14+
description = "Controls whether to append '-rule' to the name of the rule"
15+
type = bool
16+
default = true
17+
}
18+
19+
variable "append_connection_postfix" {
20+
description = "Controls whether to append '-connection' to the name of the connection"
21+
type = bool
22+
default = true
23+
}
24+
25+
variable "append_destination_postfix" {
26+
description = "Controls whether to append '-destination' to the name of the destination"
27+
type = bool
28+
default = true
29+
}
30+
1331
variable "create_bus" {
1432
description = "Controls whether EventBridge Bus resource should be created"
1533
type = bool

0 commit comments

Comments
 (0)