Terraform

What structure layout do you use for your projects?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

There is no right or wrong answer, just what you personally adopted or your team, and being able to explain why.

One common approach is to have a separate directory for each environment.

terraform_project/
  staging/
  production/

Each environment has its own backend (as you don't want to use the same authentication and access controls for all environments)

Going further, under each environment you'll separate between components, applications and services

terraform_project/
  staging/
    applications/
      some-app-service-1/
      some-app-service-2/
    databases/
      mongo/
      postgres/
    networking/