Using different Terraform configuration directories
Until now, in all the recipes we have covered, we executed the Terraform workflow commands in the folder that contains the Terraform configuration to apply.
However, in IaC enterprise scenarios, the Terraform configuration is often separated into multiple folders (see the note below), and to apply the changes we need to navigate to each folder in the correct order.
It is best practice to separate Terraform configurations into multiple folders (also called “modules” or “components”), to isolate the Terraform state, and to have a different life cycle deployment for each component.
In this recipe, we will learn how to run the Terraform CLI and target the Terraform configuration.
Let’s get started!
Getting ready
To illustrate this recipe, we will use a Terraform configuration folder structure that deploys a network infrastructure, then deploys the database, and finally...