gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.06k stars 977 forks source link

Large number inputs get changed by terragrunt #3514

Open e-r-holt opened 1 week ago

e-r-holt commented 1 week ago

Describe the bug

Numbers reaching into 17~19 digits get changed by terragrunt before making it to terraform for planning

Steps To Reproduce

  1. Create a module that passes one input to an output value
    
    variable "some_number" {
    type = number
    }

output "that_number" { value = var.some_number }

2. Reference the module with a number input ~19 digits
```hcl
terraform {
  source = "module/"
}
inputs = {
  some_number = 111111111111111111
}
  1. Run a plan. Output:
    10:56:04.786 STDOUT tofu: Initializing the backend...
    10:56:04.788 STDOUT tofu: Initializing provider plugins...
    10:56:04.789 STDOUT tofu: OpenTofu has been successfully initialized!
    10:56:04.789 STDOUT tofu: 
    10:56:04.789 STDOUT tofu: You may now begin working with OpenTofu. Try running "tofu plan" to see
    10:56:04.789 STDOUT tofu: any changes that are required for your infrastructure. All OpenTofu commands
    10:56:04.789 STDOUT tofu: should now work.
    10:56:04.789 STDOUT tofu: If you ever set or change modules or backend configuration for OpenTofu,
    10:56:04.789 STDOUT tofu: rerun this command to reinitialize your working directory. If you forget, other
    10:56:04.789 STDOUT tofu: commands will detect it and remind you to do so if necessary.
    10:56:04.823 STDOUT tofu: Changes to Outputs:
    10:56:04.823 STDOUT tofu:   + that_number = 111111111111111100
    10:56:04.823 STDOUT tofu: You can apply this plan to save these new output values to the OpenTofu
    10:56:04.823 STDOUT tofu: state, without changing any real infrastructure.
    10:56:04.823 STDOUT tofu: 
    10:56:04.823 STDOUT tofu: ─────────────────────────────────────────────────────────────────────────────
    10:56:04.823 STDOUT tofu: Note: You didn't use the -out option to save this plan, so OpenTofu can't
    10:56:04.823 STDOUT tofu: guarantee to take exactly these actions if you run "tofu apply" now.

    Expected behavior

The number is passed to tofu unchanged, and output should match input

Nice to haves

Versions

Numbers of this size need to be passed between modules as dependencies for ID references. An example, unique_id's of GCP service accounts.

e-r-holt commented 1 week ago

I also tried storing the value in a var-file, since this issue seems similar, and somebody there suggested var-file values would be a good workaround.

I was not successful with that solution

e-r-holt commented 1 week ago

How neat! I've proven this doesn't happen when you use tofu directly, but it still happens when you store the value in a tofu local.

me@workstation:~/src/test$ tofu plan
var.some_number
  Enter a value: 114229903950591386351

Changes to Outputs:
  + that_number = 114229903950591386351

You can apply this plan to save these new output values to the OpenTofu state, without changing any real infrastructure.