Extensible Terraform Project Structure: My learnings

Dipesh Shah
2 min readJan 26, 2021

Terraform is the most talked about tool when it comes to Infrastructure-as-Code (IaC). When someone starts to explore Terraform, first question arises in mind around the terraform project structure. What should be the ideal project structure that provides flexibility and extensibility to all projects across the organization?

I decided to explore Terraform against my Azure cloud environment keeping in mind following goals & benefits-

Terraform: Goals and Benefits

Remote state files: In order to save the terraform state in a centralized remote storage, I used Azure store account to save terraform state files. Separate containers were created for each environment (dev, test, prd) to save environment specific files. Under each environment container, individual state files were maintained for each project and each region where the components are deployed.

Terraform project code: I used Azure Git repository to save my terraform project code.

Azure DevOps Pipelines: Project specific yaml pipelines were used for CI/CD.

Approvals: I used Azure DevOps Environment in CI/CD pipeline to review and approve terraform plan.

Below is the Terraform deployment flow-

--

--

Dipesh Shah

Enterprise Cloud Solution Architect, DevOps Lead, Learner