Lesson 1 of 4 ยท Terraform Core Concepts

Configuration structure

Terraform reads all .tf files in one folder as a single configuration. Split a growing configuration by purpose rather than by command: providers, variables, resources, and outputs are common starting points. The filenames are for people; Terraform does not require a particular naming scheme.

Example

# providers.tf
provider "aws" {
  region = var.region
}

# variables.tf
variable "region" {
  type = string
}

Step by step

  1. Keep related declarations together.
  2. Use clear names such as providers.tf and outputs.tf.
  3. Keep one environment or reusable module in a deliberate folder.
  4. Format before sharing the configuration.

Common mistakes to avoid

  • Assuming Terraform runs files alphabetically.
  • Scattering one resource across many files without a reason.