You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support for terraform.tfvars was removed in terragrunt 0.19 only because of hashicorp/terraform#19424
That required everyone to basically rename the file to terragrunt.hcl and make some other adjustments. It required creating the inputs{} block with the variables, which are then get converted to env vars and then to actual vars by terraform. As this transformation doesn't always work well, we have to sometimes have two files: terraform.tfvars and terragrunt.hcl, keeping the variables set in terraform.tfvars and terragrunt configuration set in terragrunt.hcl.
There have been some other features added with terragrunt.hcl, for example terraform functions, but they are not used always. At least I haven't found a way to use this functionality at all.
Instead, terragrunt can:
Check for the existence of terraform.tfvars. Check for the terragrunt variable there. If it's there then generate a file called terragrunt.tf with this content: variable "terragrunt" {}.
This way terraform will not complain, all variables will be read correctly and there will be just one configuration file.
If the file is not there, check for terragrunt.hcl file and parse it as usual.
The text was updated successfully, but these errors were encountered:
Moving away from terraform.tfvars was recommended by HashiCorp in #466. I tend to agree, as that's a format native to Terraform, and it's likely to have other backwards incompatible changes in the future.
Moreover, I'm not a fan of code generation. It always sounds simple, but tends to introduce complexity. Just off the top of my head:
We have to scan for terraform.tfvars, parse it, find a terragrunt variable, then find a possible source = "xxx" param, then either check out xxx or look at the .tf files in the current working dir, scan all of those, parse all of those, and make sure none of them declare a terragrunt variable already.
If they don't, we have to generate a file. But where do we write it? If we put it in the current working dir, it will dirty your code base. Putting it in .terragrunt-cache makes more sense, but only works for users with source = "xxx" params that require downloading code into that dir.
What if a terragrunt.tf already exists?
When do we clean up terragrunt.tf?
So, overall, I'm not sure this is a road we want to go down.
Support for
terraform.tfvars
was removed in terragrunt 0.19 only because of hashicorp/terraform#19424That required everyone to basically rename the file to
terragrunt.hcl
and make some other adjustments. It required creating theinputs{}
block with the variables, which are then get converted to env vars and then to actual vars by terraform. As this transformation doesn't always work well, we have to sometimes have two files:terraform.tfvars
andterragrunt.hcl
, keeping the variables set interraform.tfvars
and terragrunt configuration set interragrunt.hcl
.There have been some other features added with
terragrunt.hcl
, for example terraform functions, but they are not used always. At least I haven't found a way to use this functionality at all.Instead, terragrunt can:
terraform.tfvars
. Check for theterragrunt
variable there. If it's there then generate a file calledterragrunt.tf
with this content:variable "terragrunt" {}
.This way terraform will not complain, all variables will be read correctly and there will be just one configuration file.
terragrunt.hcl
file and parse it as usual.The text was updated successfully, but these errors were encountered: