I am hoping someone can help me with an issue I am having with Terraform/Terragrunt. The versions of each that I am currently using are:
- Terragrunt v0.35.9
- Terraform v1.0.11
I am using Terragrunt to deploy project related infrastructure to GCP. I have two seperate Terragrunt projects to split out variables between a test and a production instance of the same GCP solution.
When I run the commands terragrunt init
or terragrunt plan -out tf.plan
using the test .hcl file, the process completes as expected. However when I run either of these commands using the production .hcl file, I get the following error:
│ Error: Invalid legacy provider address
│
│ This configuration or its associated state refers to the unqualified
│ provider "google".
│
│ You must complete the Terraform 0.13 upgrade process before upgrading to
│ later versions.
I have looked to see what others have suggested regarding this error, and I have found the following articles:
- "Invalid legacy provider address" error on Terraform
- https://stackguides.com/questions/65396812/invalid-legacy-provider-address-error-on-terraform
However the solutions in them are for when the version of Terraform is before the current version, not after, as I am on v1.0.11
. Additionally they suggest replacing a provider using the replace-provider
command. However it appears that the GCP provider is already up to date in my terraform project, as when I run the terraform providers
command I get:
Providers required by configuration:
.
└── provider[registry.terraform.io/hashicorp/google] ~> 4.1.0
Which appears to be the correctly formatted provider for GCP, for versions of Terraform after v0.13.x
.
I have also tried deleting the .terragrunt-cache
folder and associated lock file for the production instance and attempted to re-run the terragrunt init
command, but I keep getting the same error. I find this confusing, as this is working for the test .hcl file, which uses the same underlying Terraform .tf files.
I have noticed that in the test instance a providers
folder is being created under the .terragrunt-cache
folder, however due to this error this is not being created in the production instance, as can be seen below:
This screenshot also shows another difference I have noticed between the two Terragrant projects, the production instance is generating a .terragrunt-init-required
file, whereas this is not present in the test instance. From what I can see this is related to the fact that the production instance requires initialisation.
These are the contents of my Terraform main.tf file:
terraform {
backend "gcs" {}
}
provider "google" {
project = var.deployment_project_id
}
And these are the contents of my Terraform provider.tf file (which I added as part of a suggestion I have seen online, but was not required by the test Terragrunt project to initialise correctly):
terraform {
required_version = "~> 1.0.11"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.1.0"
}
}
}
These files are both used by my Terragrunt .hcl files. I would be grateful for any help or ideas on how to resolve this issue.