Skip to content

Commit

Permalink
fix: Make it optional to append postfix to the name, connection, or A…
Browse files Browse the repository at this point in the history
…PI destination (terraform-aws-modules#58)
  • Loading branch information
AhmadkSalah authored Jul 28, 2022
1 parent 75c970a commit 980b910
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_api_destinations"></a> [api\_destinations](#input\_api\_destinations) | A map of objects with EventBridge Destination definitions. | `map(any)` | `{}` | no |
| <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 |
| <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 |
| <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 |
| <a name="input_archives"></a> [archives](#input\_archives) | A map of objects with the EventBridge Archive definitions. | `map(any)` | `{}` | no |
| <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 |
| <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 |
Expand Down
2 changes: 2 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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

0 comments on commit 980b910

Please sign in to comment.