Open rafa-pizzi opened 3 years ago
Thanks for the detailed bug report! We're a bit buried to dig into this, but will try to do so at the earliest convenience.
In the meantime, a potential workaround is to bypass the dependency optimization feature (and thus replicating the same behavior as v0.23.34
) by doing either of the following:
disable_dependency_optimization = true
on the remote_state
block.remote_state
block with generate
block instead.See the section "Can I speed up dependency fetching?" in the docs for more details on this.
Background:
We have been having issues with terragrunt performance for a while, and we have downgraded from v0.26 to v0.23.34. I noticed newer versions keep downloading providers, even when they are already init'ed. I believe it's related to #1322, which was fixed at v0.28.3 When creating a small example to post here, I'm using the newest version of terragrunt (v0.28.12), and I believe I isolated the problem to TF_DATA_DIR. I also found #1577, but there is not enough information there, and thus this issue may be related.
Issue
Terragrunt does not evaluate dependencies correctly, and throws
Error: Initialization required. Please see the error message above.
Note: this uses azurerm as backend. As long as it's a remote backend, you will be able to reproduce the issue. It seems not to happen on local backends.Reproducing
Basically 3 sections, where app2 depends on app1 and both apps depends on infra. The main.tf are basically a minimum config for terraform and variables and outputs to create a proper dependency
Folder Structure
apps/app1/main.tf
apps/app1/terragrunt.hcl
apps/app2/main.tf
apps/app2/terragrunt.hcl
infra/main.tf
infra/terragrunt.hcl
terragrunt.hcl
Executing
At the root module, set the environments TF_VAR_region and TF_VAR_environment to anything (i.e export TF_VAR_region=us TF_VAR_environment=dev) and execute:
terrragrunt run-all apply --terragrunt-non-interactive
you get the error:Error: Initialization required. Please see the error message above.
Making it work
Remove any .terragrunt-cache and .terraform folders from you local
Comment out the TF_DAT_DIR from the root terragrunt.hcl and execute
terrragrunt run-all apply --terragrunt-non-interactive
again.Alternativelly, using the version we are currently using (terragrunt v0.23.34) execute
terrragrunt apply-all --terragrunt-non-interactive
This version of terragrunt works fine with TF_DATA_DIR