github.com/hugorut/terraform@v1.1.3/website/docs/language/files/index.mdx (about) 1 --- 2 page_title: Files and Directories - Configuration Language 3 description: >- 4 Learn how to name, organize, and store Terraform configuration files. Also 5 learn how Terraform evaluates modules. 6 --- 7 8 # Files and Directories 9 10 ## File Extension 11 12 Code in the Terraform language is stored in plain text files with the `.tf` file 13 extension. There is also 14 [a JSON-based variant of the language](/language/syntax/json) that is named with 15 the `.tf.json` file extension. 16 17 Files containing Terraform code are often called _configuration files._ 18 19 ## Text Encoding 20 21 Configuration files must always use UTF-8 encoding, and by convention 22 usually use Unix-style line endings (LF) rather than Windows-style 23 line endings (CRLF), though both are accepted. 24 25 ## Directories and Modules 26 27 A _module_ is a collection of `.tf` and/or `.tf.json` files kept together in a 28 directory. 29 30 A Terraform module only consists of the top-level configuration files in a 31 directory; nested directories are treated as completely separate modules, and 32 are not automatically included in the configuration. 33 34 Terraform evaluates all of the configuration files in a module, effectively 35 treating the entire module as a single document. Separating various blocks into 36 different files is purely for the convenience of readers and maintainers, and 37 has no effect on the module's behavior. 38 39 A Terraform module can use [module calls](/language/modules) to 40 explicitly include other modules into the configuration. These child modules can 41 come from local directories (nested in the parent module's directory, or 42 anywhere else on disk), or from external sources like the 43 [Terraform Registry](https://registry.terraform.io). 44 45 ## The Root Module 46 47 Terraform always runs in the context of a single _root module._ A complete 48 _Terraform configuration_ consists of a root module and the tree of child 49 modules (which includes the modules called by the root module, any modules 50 called by those modules, etc.). 51 52 - In Terraform CLI, the root module is the working directory where Terraform is 53 invoked. (You can use command line options to specify a root module outside 54 the working directory, but in practice this is rare. ) 55 - In Terraform Cloud and Terraform Enterprise, the root module for a workspace 56 defaults to the top level of the configuration directory (supplied via version 57 control repository or direct upload), but the workspace settings can specify a 58 subdirectory to use instead.