Skip to main content
InterviewHubPRO
Section Overview
Q17

Question 17 of 50

Part 2: Modules, Multi-Environment & GitOps (16 - 30)

34%
Terraform & IaC (50 Qs)•Part 2: Modules, Multi-Environment & GitOps (16 - 30)

Terraform Workspaces vs. Directory-Based Multi-Environment Architecture: Which is better for enterprise?

senior LevelFormsCI/CD & DevOpsSystem Design

In Simple Words:

  • Terraform Workspaces: A single set of HCL files with multiple named states (default, staging, prod).
    • Risk: A single misconfigured variable can accidentally apply to the wrong workspace. Does not allow different module versions between environments.
  • Directory-Based Architecture (Industry Standard):
    • Separate folders: environments/dev/, environments/staging/, environments/prod/.
    • Each has its own distinct remote state file, backend config, and IAM permissions.
    • Allows canary-testing a new module version in Dev without affecting Prod.