Terraform Files Structure
A standard Terraform project is organized into multiple .tf files, with each file typically having a specific responsibility. Terraform automatically loads and merges all .tf files in the same directory. The separation is mainly for readability and organization, not functionality.
Common Terraform Files
main.tf— Primary file for defining resources.*.tf— Other Terraform configuration files. You can split resources and configurations across multiple.tffiles as needed.provider.tf— Defines provider configurations and provider-related settings.outputs.tf— Defines output values that can be displayed or consumed by other modules.variables.tf— Defines input variables.terraform.tfvars— Provides values for input variables and can override their default values.backend.tf— Configures where Terraform stores its state file, such as an Amazon S3 bucket or Azure Blob Storage.modules/— Contains reusable Terraform modules.data.tf— Defines data sources used to retrieve information about existing resources or external data.
Note: Terraform does not require these specific filenames. You can use any
.tffilenames you prefer. Terraform loads all.tffiles in the same directory automatically.
