Open abhinaba-chakraborty-by opened 3 years ago
Ah yes that does look like a bug, specifically, it should skip the direct remote state based dependency fetching when disable_init
is true. We're a bit buried at the moment to implement this, but if anyone wants to submit a PR, the function in question is here: https://github.com/gruntwork-io/terragrunt/blob/579258163dd05878f2b3cfa53611c0f5fb8a728e/config/dependency.go#L427
As far as workarounds go, does it work if you add disable_dependency_optimization = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))
to the remote_state
block?
No @yorinasub17 , I tried adding disable_dependency_optimization = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))
to the remote_state
block , but it was of no help.
Ah upon further inspection, I see that we are handling errors from the output command and special casing when there is no output to return the mocks. That is sort of expected behavior given that the dependency handlers are assuming a clean output
call, and output
depends on being able to read the state properly (e.g. we don't want to silently fail and return mocks for auth issues).
Does it work if you have skip_outputs = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))
on the dependency
block?
Yep it worked!! Thanks a lot for the workaround :-) @yorinasub17
can something like this be fixed please?
I have fixed this issue by just adding init
command in mock_outputs_allowed_terraform_commands
:
dependency "network" {
config_path = "../network"
mock_outputs_allowed_terraform_commands = ["validate", "init"]
mock_outputs = {
private_subnets_ids = [
"subnet-xxxxxxxxxxxxxxxxx"
]
nat_public_ips = [
"xx.xxx.xxx.xxx"
]
}
}
dependencies {
paths = ["../network"]
}
inputs = {
private_subnets_ids = dependency.network.outputs.private_subnets_ids
nat_public_ips = dependency.network.outputs.nat_public_ips
}
Running into this issue too :(
Happy to pick up on this if not assigned, btw is the preferred flow picking from the To Do pile?
I am having a project structure as follows: . ├── README.md ├── modules │ ├── function-app-consumption │ │ ├── locals.tf │ │ ├── main.tf │ │ ├── output.tf │ │ └── variables.tf │ └── storage-account │ ├── main.tf │ ├── output.tf │ └── variables.tf └── sandbox ├── eastus │ ├── regional.tfvars │ ├── functionapp-svc │ │ └── terragrunt.hcl │ └── storageaccount-function │ └── terragrunt.hcl ├── environment.tfvars └── terragrunt.hcl
I want to deploy the infrastructure in "sandbox" environment. the root terragrunt.hcl file for that env. looks like this:
I am using the TERRAGRUNT_DISABLE_INIT environment variable to disable backend initialization while running the
validate-all
command. like this:It works fine when there is no dependency defined in any of the modules. But when a module has a dependency like this:
It starts failing , complaining that it requires backend initialization.
As we can see from the logs, the command
terraform init -backend=false
is not run , instead, the commandterraform init -get=false -get-plugins=false
gets executed. This seems to be a bug.