I think it is obvious, but not.
When I use TF_VAR_* variable in terragrunt, for example, deploy a new tag within target definition in ECS, it doesn't work with TF_VAR_tag=0.1.2
TF_VAR_tag=0.1.2 terragrunt plan
This tag need by dynamic changed after new build and deployment
How can I do that?
We use TF_VAR_xxx all the time with Terragrunt. Can you share your code so we can see why it's not working for you?
@brikis98
I can confirm the problem now. Using gruntwork-io/terragrunt-infrastructure-live-example as sample
If I don't put the variable/value in non-prod/us-east-1/qa/webserver-cluster/terraform.tfvars, when setting TF_VAR_xxx with terragrunt plan|apply, it works.
But if I put some variables in the terraform.tfvars, in case, it is tag="0.0.1", and want to dynamically change the value on fly with TF_VAR_tag=0.1.2 terragrun plan, it always pick the value in terraform.tfvars as 0.0.1
This is actually the design in Terraform. Per their docs:
Values passed within definition files or with -var will take precedence over TF_VAR_ environment variables, as environment variables are considered defaults.