feat: Support optional name
field in EventBridge resources
#187
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR enhances the EventBridge module to support an optional
name
field within resource definitions (rules
,connections
,api_destinations
,schedule_groups
,schedules
, andpipes
), allowing users to specify custom AWS resource names independently from the Terraform map key identifier. This change is 100% backwards compatible and addresses the use case where users want clean Terraform identifiers while maintaining organizational naming standards for AWS resources.Motivation and Context
Currently, the module uses the map key as both:
module.eventbridge.aws_cloudwatch_event_rule.this["key"]
)key
orkey-rule
ifappend_rule_postfix = true
)This dual purpose creates challenges when users want:
orders
,api
,webhook
)order-processor
,external-api
,customer-webhook
)Example Use Case
An organization wants:
module.eventbridge.aws_cloudwatch_event_rule.this["orders"]
order-processor
Currently, they must use the full name as the map key:
This results in less clean Terraform identifiers when using descriptive AWS names.
Solution
This PR allows users to specify a custom
name
field within resource definitions (while still respecting theappend_*_postfix
variable settings):This achieves:
module.eventbridge.aws_cloudwatch_event_rule.this["orders"]
order-processor
Breaking Changes
No breaking changes. This feature is 100% backwards compatible:
name
field is provided, behavior is identical to the current implementationappend_*_postfix
behavior unchanged - Still applies to both map keys and custom namesHow Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/complete/main.tf
to showcase the optionalname
field feature with theorders
ruleexamples/*
projectsexamples/complete
example to verify custom naming works correctlyemails
,crons
,ecs
) continue to work without thename
field["orders"]
) while AWS resource names are descriptive (order-processor
)pre-commit run -a
on my pull request