From 3d38d8ef8f6b47a105746a5bdcf6489f6651624f Mon Sep 17 00:00:00 2001 From: Ian Muscat Date: Fri, 10 Oct 2025 14:39:49 +0200 Subject: [PATCH 1/2] feat: add optional `name` field support Add optional `name` field support across all EventBridge resource types (rules, connections, api_destinations, schedule_groups, schedules, pipes) allowing users to specify custom AWS resource names independently from Terraform map key identifiers. This enhancement enables: - Clean Terraform identifiers (e.g., `["orders"]`) - Descriptive AWS resource names (e.g., `order-processor`) - 100% backwards compatibility with existing configurations - Respect for `append_*_postfix` variable settings The feature is opt-in and requires no migration for existing users. --- main.tf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.tf b/main.tf index 4ad471d..e2d01ce 100644 --- a/main.tf +++ b/main.tf @@ -7,7 +7,7 @@ locals { for index, rule in var.rules : merge(rule, { "name" = index - "Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index + "Name" = var.append_rule_postfix ? "${replace(lookup(rule, "name", index), "_", "-")}-rule" : lookup(rule, "name", index) }) ]) eventbridge_targets = flatten([ @@ -15,7 +15,7 @@ locals { for target in var.targets[index] : merge(target, { "rule" = index - "Name" = var.append_rule_postfix ? "${replace(index, "_", "-")}-rule" : index + "Name" = var.append_rule_postfix ? "${replace(lookup(rule, "name", index), "_", "-")}-rule" : lookup(rule, "name", index) }) ] if length(var.targets) != 0 ]) @@ -23,34 +23,34 @@ locals { for index, conn in var.connections : merge(conn, { "name" = index - "Name" = var.append_connection_postfix ? "${replace(index, "_", "-")}-connection" : index + "Name" = var.append_connection_postfix ? "${replace(lookup(conn, "name", index), "_", "-")}-connection" : lookup(conn, "name", index) }) ]) eventbridge_api_destinations = flatten([ for index, dest in var.api_destinations : merge(dest, { "name" = index - "Name" = var.append_destination_postfix ? "${replace(index, "_", "-")}-destination" : index + "Name" = var.append_destination_postfix ? "${replace(lookup(dest, "name", index), "_", "-")}-destination" : lookup(dest, "name", index) }) ]) eventbridge_schedule_groups = { for index, group in var.schedule_groups : index => merge(group, { - "Name" = var.append_schedule_group_postfix ? "${replace(index, "_", "-")}-group" : index + "Name" = var.append_schedule_group_postfix ? "${replace(lookup(group, "name", index), "_", "-")}-group" : lookup(group, "name", index) }) } eventbridge_schedules = flatten([ for index, sched in var.schedules : merge(sched, { "name" = index - "Name" = var.append_schedule_postfix ? "${replace(index, "_", "-")}-schedule" : index + "Name" = var.append_schedule_postfix ? "${replace(lookup(sched, "name", index), "_", "-")}-schedule" : lookup(sched, "name", index) }) ]) eventbridge_pipes = flatten([ for index, pipe in var.pipes : merge(pipe, { "name" = index - "Name" = var.append_pipe_postfix ? "${replace(index, "_", "-")}-pipe" : index + "Name" = var.append_pipe_postfix ? "${replace(lookup(pipe, "name", index), "_", "-")}-pipe" : lookup(pipe, "name", index) }) ]) From 09f6f0852966e3e62072609b393b3dedc0d55ce0 Mon Sep 17 00:00:00 2001 From: Ian Muscat Date: Fri, 10 Oct 2025 14:53:56 +0200 Subject: [PATCH 2/2] docs: update example --- examples/complete/main.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 8fac152..bcd5f29 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -42,6 +42,8 @@ module "eventbridge" { rules = { orders = { + name = "order-processor" # optional different AWS resource name to Terraform "orders" map key identifier + description = "Capture all order data" event_pattern = jsonencode({ "source" : ["myapp.orders"] }) state = "DISABLED" # conflicts with enabled which is deprecated