-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Description
Terraform Version
we use anything from 1.5.x
to the new 1.12.x
Use Cases
our directories are :
/terraform/environments/... for the the tfvars/tfinit
/terraform/environments/prod/prod.tfvars prod.tfinit
/terraform/environments/stg/stg.tfvars prod.tfinit
...
/terraform/modules/... for the modules
/terraform/main/... for the main terraform files (tf files....)
instead of doing in /terrform/main
terraform init -backend-config=../environments/prod/prod.tfinit
terraform plan -var-file=../environments/prod/prod.tfvar
I would like to do something like in /terraform/environment/prod
terraform init -backend-config=prod.tfinit -root=../../main
terraform plan -var-file=prod.tfvars -root=../../main
This way the .terraform directory will be build in each env directory and not in the main terraform directory
It allow us also to use direnv
tool, to have .envrc
file in each env directory that preset the AWS_PROFILE
, TFENV_TERRAFORM_VERSION
and other specific setings.
Attempted Solutions
The chdir option today doesn't allow that, it just do a full change directory at the beginning of terraform call, not the same effect.
Proposal
Add a -root=....
option to specify where the main terraform directory with all the tf files is
References
No response