terragrunt: Terraform fails when using remote_state.disable_init
I’m using disable_init to prevent terragrunt from accessing remote state bucket on its own (reason explained below). However, this also disables initializing the backend by terraform: it passes -backend=false to terraform init. As a result, the backend is not initialized and all terragrunt commands result in errors:
$ terragrunt plan
...
[terragrunt] [/tf] 2020/11/11 21:14:49 Running command: terraform init -backend=false
...
Terraform has been successfully initialized!
...
[terragrunt] 2020/11/11 21:14:56 Running command: terraform plan
Backend reinitialization required. Please run "terraform init".
Reason: Initial configuration of the requested backend "gcs"
...
Error: Initialization required. Please see the error message above
I think a better behavior would be have remote_state.disable_init prevent terragrunt itself from creating the state file in the remote bucket (or accessing the remote bucket bucket in any way), but not prevent terraform itself from initializing the state backend.
The reason this is needed in my case is that I’m using impersonate_service_account option in terraform 0.14-rc1, and terragrunt doesn’t understand it yet, so it fails whenever it tries to access the remote bucket. I hoped I could solve it by using emote_state.disable_init, but I run into this problem.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 5
- Comments: 15 (11 by maintainers)
Any update on this? I’m running into the same issue. I’d prefer to avoid using a
generateblock because I wouldn’t be able to take advantage of terragrunt-fetch-dependency-output-from-state, as outlined in https://github.com/gruntwork-io/terragrunt/issues/2279.@yorinasub17 Heya, followed your advice here to use
generateinstead ofremote_state. Our bucket is created beforehand, so was no need. And we wouldnt even worry, until we started using service account that impersonates another service account. Those initial calls terragrunt makes to GCS just failed all the time. Spent almost a month on and off debugging this 😄What I noticed now is that after this, if a module has dependencies doing a simple
terragrunt planexpects ALL dependencies to be in initialzied condition, it goes through all lock files and all that. This is definitely different from what usingremote_statedid. Is this behaviour part of dependency optimization inremote_state? Hoping there is a way to mimic this with usinggeneratefor backend? many thanks 🙏Thanks @jlepere-everlaw,
We’ll discuss this in the team and I’ll let you know about a possible solution a little later.