Skip to content

random_string doesn't create correct length #609

@LeBaronDeCharlus

Description

@LeBaronDeCharlus

Terraform CLI and Provider Versions

./terraform -v && ./terraform init --upgrade
Terraform v1.9.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/random v3.6.3
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/random...
- Using previously-installed hashicorp/random v3.6.3

Terraform has been successfully initialized!

Terraform Configuration

resource "random_string" "random" {
  length  = 32
  special = false
}

output "random_string" {
  value = random_string.random.result
}

Expected Behavior

Length should be the exact amount of characters defined in length arg.

Actual Behavior

While asking for a specific number, it creates an unwanted additional one.
If we ask for 30, we get 31 (29 => 30, 28 => 29 etc)

Steps to Reproduce

  1. terraform init
  2. terraform apply | tail -1 | cut -d '"' -f 2| wc

How much impact is this issue causing?

High

Logs

https://gist.github.com/LeBaronDeCharlus/147648c236408cf6c526522af4a5fe2f

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions