Skip to content

having a 'root' option to point to the directory where the tf files are #37341

@CyrilDevOps

Description

@CyrilDevOps

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy