Day 6 - Organizing Terraform Files the Right Way
On Day 6, I learned something simple but powerful: Terraform code should not just work, it should also be easy to read. As projects grow, putting everything into a single main.tf file becomes messy. It may work for a small demo, but once more resources are added, it quickly becomes difficult to maintain. That is where file structure becomes important. Terraform reads all .tf files in the current directory as a single configuration. This means file names do not control the logic of the deployment. Instead, file names are there to help us organize the code better. Dependencies are handled through references between resources, not because one file comes before another. For this exercise, I split the configuration into multiple files: backend.tf for remote state configuration provider.tf for the AWS provider variables.tf for inputs locals.tf for reusable values vpc.tf for networking resources storage.tf for S3 resources outputs.tf for output values terraform.tf...