Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

514
Views
Terraform : Specifying the working directory when running terraform apply/plan

Is there any way (or workaround) to specify the working directory when running terraform apply or terraform plan ? For example :

terraform apply working_dir/vpc
terraform apply working_dir/dns
terraform apply working_dir/postgres
terraform apply working_dir/service-a
terraform apply working_dir/service-b

I know there's a target option where we can specify the resources to target. But here I need a folder to have more abstraction. The final goal is to be able to setup the infrastructure running the following commands :

make vpc
make dns
make postgres
make service-a
make service-b
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

These days you can also use global option -chdir:

The chdir option instructs Terraform to change its working directory to the given directory before running the given subcommand. This means that any files that Terraform would normally read or write in the current working directory will be read or written in the given directory instead.

For example:

terraform -chdir=environments/production apply
over 4 years ago · Santiago Trujillo Report

0

You can specify a plan or directory when issuing the apply command. Your examples are valid apply commands.

Usage: terraform apply [options] [dir-or-plan]

over 4 years ago · Santiago Trujillo Report

0

Execute below commands from parent directory having multiple directories containing terraform (*.tf) files.

To execute terraform:

terraform init dir-name
terraform validate dir-name
terraform plan -detailed-exitcode -out=plan-name.out dir-name
terraform apply plan-name.out

To destroy use:

terraform destroy dir-name
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!