terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

[Enhancement]: Ability to specify a length for prefixes generated by `name_prefix` type arguments

Open Michagogo opened this issue 1 year ago • 7 comments

Terraform Core Version

1.5.1

AWS Provider Version

5.10.0

Affected Resource(s)

aws_cloudwatch_event_rule

Expected Behavior

When creating a rule and using the name_prefix option to avoid collisions while still composing the name out of several elements, I would expect that the unique suffix appended would be reasonably short, just enough to ensure non-collision, while leaving me with space to produce a meaningful name in the 64 character limit that the rule name field has. A more complex improvement would be to measure the length of the prefix and produce a suffix that is short enough to fit (perhaps throwing an error in the event that there's insufficient space left)

Additionally, at a minimum, if no change is made the documentation should warn about the severely constrained space when using name prefixes.

Actual Behavior

Examining the generated name, it seems that the provider appends a 26-character suffix to the prefix provided, leaving less than 60% of the total space available for the user.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_cloudwatch_event_rule" "test" {
  name_prefix              = "example-prefixthatisfortycharacterslong-"
  schedule_expression = "rate(1 day)"
}

Steps to Reproduce

Attempt to apply the above configuration, observe error. s/forty/37/ and observe success.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

Michagogo avatar Aug 03 '23 10:08 Michagogo