Open pipiobjo opened 1 year ago
Hello,
I am also experiencing this behaviour when using Terragrunt extra_arguments
to configure remote state authentication information for GitLab's HTTP-based backend using existing GITLAB_USERNAME
and GITLAB_ACCESS_TOKEN
environment variables.
terraform {
extra_arguments "set_env" {
commands = ["init", "plan", "apply", "refresh", "import", "destroy", "show", "state", "taint", "untaint"]
env_vars = {
# GITLAB_USERNAME should be passed as TF_HTTP_USERNAME
TF_HTTP_USERNAME = get_env("GITLAB_USERNAME")
# GITLAB_PASSWORD should be passed as TF_HTTP_PASSWORD
TF_HTTP_PASSWORD = get_env("GITLAB_ACCESS_TOKEN")
}
}
}
When I include the following dependency, remote authentication fails for the core
module's state backend.
dependency "core" {
config_path = "../core"
}
For now, I am working around the issue by manually setting TF_HTTP_USERNAME
and TF_HTTP_PASSWORD
.
Is this a bug or is this intended behaviour?
Best regards, Edan
Seems like a very serious bug, as there is no way to use dependencies with extra_arguments
In my case this worked: https://github.com/gruntwork-io/terragrunt/issues/1590#issuecomment-800856330
disable_dependency_optimization = true
But this is obviously not a good solution?
Describe the bug Auth Context is not propaged properly after adding dependency to terragrunt module.
To Reproduce
Sample setup to reproduce the issue, which simple creates two resource groups in Azure. Which should use the same Service Principal for authentication. Separated in two terragrunt modules.
Given following file structure:
01-base/terragrunt.hcl
02-network/terragrunt.hcl
dev.hcl
tf-modules/base/main.tf
tf-modules/network/main.tf
Execute apply with following commands in every subfolder:
Leads to both modules being applied and both resource groups being created. Everything fine until here.
Now I want to use the output of the base module in the network module. For that I add the following to the network module:
02-network/terragrunt.hcl
the complete file looks like this:
The first modules finished successfully with
Apply the code with the same commands as before, leads to following error:
Following file structure is created:
If I deactivate the terraform extra_arguments block and set the ENV Variables directly. Everything works as expected. But of course a dynamic switch of different Auth Contexts between modules is not possible.
Expected behavior terraform extra_arguments are evaluated per occurrence, referenced by include block or assigned directly
Versions