Terragrunt: get_env() not recognizing environment vars set by extra_arguments

Created on 13 Dec 2018  路  2Comments  路  Source: gruntwork-io/terragrunt

When setting env_vars inside of a extra_arguments block the environment variables that are set are not recognized by my remote_state block.

image

These variables are set in the environment as seen by my before_hook that simply prints out the env:

image

The get_env() function in the remote_state block should be able to recognize the environment variables that I just set. Instead, it sees them as being blank and uses the default value.

question

Most helpful comment

Ok, thats completely explains that behavior. Thank you for explaining that. It would be nice to have a way to set variables this way. It would be helpful to have the top level tfvars file be the only file that you have to change in order to redeploy a new or slightly modified set of resources. Essentially one place to store / change your "volatile" variables that can change from run to run

All 2 comments

The env_vars in extra_arguments are only set as "extra arguments" for the Terraform command you're running (i.e., for terraform apply). They are not available to any other part of Terragrunt for now, including get_env, which happens while parsing your .tfvars file, potentially before extra_arguments are parsed...

Ok, thats completely explains that behavior. Thank you for explaining that. It would be nice to have a way to set variables this way. It would be helpful to have the top level tfvars file be the only file that you have to change in order to redeploy a new or slightly modified set of resources. Essentially one place to store / change your "volatile" variables that can change from run to run

Was this page helpful?
0 / 5 - 0 ratings