hashicorp / terraform-provider-random

Utility provider that supports the use of randomness within Terraform configurations.
https://registry.terraform.io/providers/hashicorp/random/latest
Mozilla Public License 2.0
203 stars 117 forks source link

add "pet_name_length" parameter to the random_pet resource #407

Open georgikoemdzhiev opened 1 year ago

georgikoemdzhiev commented 1 year ago

Terraform CLI and Provider Versions

Terraform CLI version: v.1.4.6

Use Cases or Problem Statement

Some resource parameters have a maximum length defined such as the domain_name property of the aws_opensearch_domain resource in the AWS provider (i.e. the domain name must be <= than 28 characters long). In those cases, if we want to use the random_pet resources to generate a random name for the domain_name property, it may generate a name that is longer than the maximum allowed length.

Current:

resource "random_pet" "cluster" {
  length = 1
}

resource "aws_opensearch_domain" "opensearch" {
  domain_name    = "my-team-name-${random_pet.cluster.id}-${var.environment}"
  engine_version = var.engine_version
...

Proposal

Add a pet_name_length property to the random_pet resource

How much impact is this issue causing?

Low

Additional Information

No response

Code of Conduct

d-medvedev1 commented 1 year ago

Do you have an ideas, how many letters will be in word generated by random_pet resource? I tried to generate few dozens and the shortest word I've seen had 3 letters and the longest had 8 letters.

bendbennett commented 1 year ago

Hi @georgikoemdzhiev 👋

Thank you for submitting this enhancement request. We will prioritise looking into this issue further on the basis of the level of community interest indicated by up-votes.

bendbennett commented 1 year ago

Hi @d-medvedev1 👋

The pet names are generated within the _randompet resource using the golang-petname Go module. The number of letters in the generated pet name(s) are dependent upon the length, separator, and prefix attributes supplied. An examination of the lists used within the golang-petname Go module should provide some guidance in this respect.