How to Run Terraform from a Location Other Than the Current Directory

Asked 1 years ago, Updated 1 years ago, 347 views

Typically, Terraform executes the following command with the location of the *.tf(main.tf) file as the current directory:

terraform apply --auto-approve

Is it possible to use Terraform from a location other than the current directory, for example, when using more than one Terraform from Shell?

cd hoge_folder
terraform apply --auto-approve
cd../fuga_folder
terraform apply --auto-approve

It will be

terraform apply --working_folder=hoge_folder

Would it be possible to do something like that?

terraform

2023-02-16 09:46

1 Answers

Looking at the documentation, there seems to be an option called -chdir.

Passing a Different Configuration Directory

If your workflow releases on overriding the root module directory, use the -chdir global option install, which works across all commands and makes Terraform consistent directory for the living directory in the current working directory.


2023-02-16 11:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.