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
7.96k stars 967 forks source link

Terragrunt keeps adding latest version of of provider from opentofu registry and ignore terraform version constraint #3437

Open nguyen-vo opened 2 days ago

nguyen-vo commented 2 days ago

Describe the bug

I have my repository set up to support multiple environments using multiple folder and have a single terragrunt.hcl file at the root level. In that file I define the provider constraint to be ~>5.28 using the required_provider block from terraform.

generate "provider" {
  path      = "provider_override.tf"
  if_exists = "overwrite_terragrunt"

  contents  = <<EOF
    terraform {
      required_providers {
        google = {
          source  = "hashicorp/google"
          version = "~>5.28"
        }
      }
    }
    provider "google" {
      project = "${local.project_id}"
      region  = "${local.region_location}"
    }
  EOF
}

Upon running plan command locally, I notice the .terraform.lock.hcl keep getting updates with with the latest version of the provider from opentofu. I got to learn that terragrunt use opentofu as default if it is available. However, I don't have opentofu installed on my machine. I also set the TERRAGRUNT_TFPATH to point to terraform, but no luck

Here is an example of my lock file code

Expected behavior

Nice to haves

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!



## Versions

- Terragrunt version: 0.55.3
- Terraform version:
- Environment details (Ubuntu 20.04, Windows 10, etc.): Mac Montery v12.6.4
nguyen-vo commented 2 days ago

Maybe this is not the bug. What I am trying to do is to get opentofu to align with the version constraint. It keeps download the latest version of the provider which sometimes causes our CI pipeline to fail