🚀 Learn Terraform #

Welcome to Learn Terraform, a learning website designed to help you understand Terraform thoroughly — from the most basic concepts to the advanced practices used in production environments.

This website doesn’t just explain what Terraform is, but also how and when Terraform should be used, complete with conceptual explanations, workflows, and best practices commonly applied by DevOps practitioners and Cloud Engineers.


🧭 The Purpose of This Website #

Terraform is a very powerful tool, but it often feels confusing to beginners because of the many technical terms (state, provider, resource, module), declarative behavior that differs from imperative scripting, and the big consequences of misconfiguration in cloud environments.

This website is built to provide a coherent and logical learning path, explain why a concept exists — not just how it works, help you build a strong Terraform mental model, and serve as a long-term reference you can use when working with Terraform for real.


📘 What Is Terraform? #

Terraform is an Infrastructure as Code (IaC) tool that lets you define infrastructure — servers, databases, networks, and other cloud services — in declarative code. With Terraform, you can create infrastructure consistently, avoid error-prone manual configuration, track infrastructure changes through version control, and easily reproduce environments (dev, staging, production). Terraform supports many providers such as AWS, GCP, Azure, Kubernetes, and various third-party services.

Terraform in the IaC Ecosystem #

flowchart TD
    subgraph IaC["Infrastructure as Code"]
        TF["<b>Terraform</b><br/>Declarative, Multi-Cloud"]
        CF["CloudFormation<br/>AWS Only"]
        PUL["Pulumi<br/>Imperative, Multi-Cloud"]
        BICEP["Bicep<br/>Azure Only"]
        OT["OpenTofu<br/>Terraform Fork"]
    end

    subgraph Why["Why Terraform?"]
        MC["Multi-Cloud<br/>AWS, GCP, Azure, K8s"]
        DECL["Declarative<br/>Define desired state"]
        STATE["State Management<br/>Track infrastructure"]
        MOD["Module System<br/>Reusable components"]
        COMM["Community<br/>Large ecosystem"]
    end

    TF --> Why

    style TF fill:#7b42bc,color:#fff
    style IaC fill:#f5f5f5
    style Why fill:#e8f5e9

How Terraform Works #

flowchart LR
    subgraph Write["1. Write"]
        HCL["HCL Configuration<br/>.tf files"]
    end

    subgraph Plan["2. Plan"]
        EP["Execution Plan<br/>Preview changes"]
    end

    subgraph Apply["3. Apply"]
        API["Cloud API Calls<br/>Create/Update/Delete"]
    end

    subgraph Track["4. Track"]
        SF["State File<br/>Record actual state"]
    end

    Write --> Plan --> Apply --> Track -->|"Iterate"| Write

    style Write fill:#e3f2fd
    style Plan fill:#fff3e0
    style Apply fill:#e8f5e9
    style Track fill:#f3e5f5

🧠 Learning Material Structure #

The material on this website is arranged progressively following the TOC in the sidebar, so you can follow it from the beginning to the advanced level without concept jumps.

Learning Roadmap #

flowchart TD
    subgraph Fundamentals["🏗️ Fundamentals"]
        BASIC["<b>Basic</b><br/>What & Why"]
        CONCEPT["<b>Concept</b><br/>Declarative, Provider,<br/>Resource, State"]
        INSTALL["<b>Installation</b><br/>Setup & CLI"]
    end

    subgraph Core["⚙️ Core Skills"]
        WF["<b>Workflow</b><br/>init → plan → apply"]
        RES["<b>Resource & Dep</b><br/>Define & manage"]
        STATE["<b>State</b><br/>Local, remote, locking"]
        VAR["<b>Variable</b><br/>Parameterize config"]
        OUT["<b>Output</b><br/>Export values"]
        DS["<b>Datasource</b><br/>Read existing data"]
    end

    subgraph Advanced["🚀 Advanced"]
        MOD["<b>Module</b><br/>Reusable components"]
        ENV["<b>Environment</b><br/>Dev, staging, prod"]
        MP["<b>Multi Provider</b><br/>Multi-cloud setup"]
        CICD["<b>CI/CD</b><br/>Automate pipeline"]
        SEC["<b>Security</b><br/>Protect secrets"]
        BP["<b>Best Practice</b><br/>Production wisdom"]
    end

    BASIC --> CONCEPT --> INSTALL
    INSTALL --> WF --> RES --> STATE
    STATE --> VAR --> OUT --> DS
    DS --> MOD --> ENV --> MP
    MP --> CICD --> SEC --> BP

    style Fundamentals fill:#e3f2fd
    style Core fill:#fff3e0
    style Advanced fill:#e8f5e9

1. Basic #

This section covers the Terraform foundations — the background of Infrastructure as Code, the problems it solves, and comparisons with other approaches.

  • What is Terraform? — The definition of Terraform as an Infrastructure as Code tool and the big picture of the problems it solves.
  • Manual Infrastructure — The challenges and risks of managing infrastructure manually, which form the background of Terraform’s birth.
  • Imperative Tools — A comparison of the imperative approach (scripting) vs declarative in infrastructure management.
  • Alternatives — A comparison of Terraform with Pulumi, Ansible, CloudFormation, and other IaC tools.
  • When Used? — A guide to determining when Terraform is the right choice and when another tool fits better.

2. Concept #

This section covers the main concepts at the core of how Terraform works — understanding this section is very important before moving to practice.

  • Declarative — Terraform’s declarative principle: defining the desired state and letting Terraform determine the how.
  • Provider — The plugin connecting Terraform with external services like AWS, GCP, Azure, and Kubernetes.
  • Resource — The infrastructure unit managed by Terraform, from servers and databases to DNS records.
  • State — Terraform’s source of truth that records the actual infrastructure condition being managed.

3. Installation & Setup #

Technical guides to get started: how to install Terraform, get to know its CLI, and organize projects well.

  • Installation — How to install Terraform on various operating systems and verify a successful installation.
  • CLI — The most frequently used Terraform CLI commands in infrastructure management.
  • Directory Structure — Good, maintainable file and folder organization in a Terraform project.

4. Workflow #

Terraform has a distinctive and consistent workflow. This section explains each stage and the concepts behind it.

flowchart LR
    init["<b>init</b><br/>Setup"] --> plan["<b>plan</b><br/>Preview"]
    plan --> apply["<b>apply</b><br/>Execute"]
    apply --> destroy["<b>destroy</b><br/>Cleanup"]

    style init fill:#e3f2fd
    style plan fill:#fff3e0
    style apply fill:#e8f5e9
    style destroy fill:#ffebee
  • Init — Initializing a Terraform project: downloading provider plugins and preparing the backend.
  • Plan — Creating an execution plan showing what changes Terraform will make.
  • Apply — Applying infrastructure changes based on the execution plan that was created.
  • Destroy — Removing all infrastructure managed by Terraform in a controlled way.
  • Execution Plan — How Terraform plans and visualizes changes before they are applied.
  • Drift Detection — Detecting differences between the Terraform state and the actual infrastructure condition.
  • Idempotency — The principle that running Terraform repeatedly produces consistent, predictable results.

5. Resource & Dependency #

Terraform builds a dependency graph automatically. This section explains how Terraform determines execution order and manages resource lifecycles.

  • What is a Resource? — The basic unit in Terraform representing one infrastructure component.
  • Lifecycle — Rules controlling how Terraform creates, updates, and deletes resources.
  • Dependency — How Terraform builds the dependency graph to determine resource execution order automatically.
  • Operation — The operations Terraform can perform on resources: create, update, replace, and delete.
  • Locking — The locking mechanism preventing concurrent modification of resources and state.

6. State #

State is the most crucial component in Terraform — the source of truth recording all managed infrastructure.

flowchart LR
    subgraph Local["Local State"]
        LS["terraform.tfstate<br/>Single machine"]
    end

    subgraph Remote["Remote State"]
        RS["S3 / GCS / Azure<br/>Team collaboration"]
        RL["Locking + Versioning"]
    end

    Local -->|"Migrate"| Remote

    style Local fill:#ffebee
    style Remote fill:#e8f5e9
  • Local — State stored on a local machine, fine for experiments but not recommended for teams.
  • Remote — State stored on a central backend like S3, GCS, or Terraform Cloud.
  • Locking — The state locking mechanism preventing conflicts when several engineers work simultaneously.
  • Migration — The process of moving state from one backend to another without losing data.
  • Import — Bringing existing resources into Terraform state without recreating them from scratch.
  • Anti-Pattern — Common state management mistakes that can cause serious problems in production.

7. Variable #

This section covers how to make Terraform configurations flexible and reconfigurable without changing code.

  • What is a Variable? — The parameterization mechanism of Terraform configurations for flexibility and reusability.
  • Type & Validation — Terraform variable data types and how to define custom validation rules.
  • File & Environment — How to supply variable values through .tfvars files and environment variables.

8. Output #

Outputs let Terraform configurations export values for use by other modules or consumption by external systems.

  • What is an Output? — How to export values from Terraform resources for use by other modules or users.
  • Output Contract — The pattern of defining outputs as an explicit contract between a module and its callers.
  • Sensitive Output — How to handle outputs containing sensitive data so they aren’t accidentally exposed.

9. Datasource #

Datasources let Terraform read information from existing resources without managing them — important for integration with running infrastructure.

  • What is a Datasource? — How to read information from existing resources without taking over their management.
  • Reference — How to reference datasources in Terraform resource configurations.
  • Datasource Anti-Pattern — Common mistakes in datasource usage that cause excessive coupling.

10. Module & Reusability #

Modules are the key to Terraform scalability — how to group configurations into reusable units.

flowchart TD
    subgraph Root["Root Module"]
        MAIN["main.tf<br/>Calls child modules"]
    end

    subgraph Children["Child Modules"]
        VPC["modules/vpc/"]
        EC2["modules/ec2/"]
        RDS["modules/rds/"]
    end

    MAIN --> VPC
    MAIN --> EC2
    MAIN --> RDS

    style Root fill:#e3f2fd
    style Children fill:#e8f5e9
  • What is a Module? — Reusable Terraform code units for simplifying and standardizing infrastructure.
  • Structure — Clean, understandable, and maintainable file organization in a Terraform module.
  • Root vs Child Module — The different roles of root modules and child modules in the Terraform configuration hierarchy.
  • Versioning — Module version numbering strategies for long-term stability and compatibility.
  • Interface Design — How to design module variables and outputs as a clear, stable contract.
  • Registry — Publishing and consuming modules from the public or private Terraform Registry.

11. Environment #

This section covers strategies for managing multiple environments (dev, staging, production) consistently and safely.

flowchart LR
    subgraph Dev["Development"]
        D["t3.micro<br/>Single AZ<br/>No backup"]
    end

    subgraph Staging["Staging"]
        S["t3.large<br/>Single AZ<br/>7-day backup"]
    end

    subgraph Prod["Production"]
        P["t3.xlarge<br/>Multi-AZ<br/>30-day backup"]
    end

    Dev -->|"Promote"| Staging -->|"Promote"| Prod

    style Dev fill:#e8f5e9
    style Staging fill:#fff3e0
    style Prod fill:#e3f2fd
  • What is an Environment? — The concept of environment separation in infrastructure management with Terraform.
  • Environment Types — Common environment separation patterns and strategies in the industry.
  • Workspace — The Terraform Workspace feature for managing several environments in one configuration.
  • Directory Based — The environment separation approach using separate directory structures.

12. Multi Provider #

This section covers scenarios where a single Terraform configuration needs to interact with more than one provider or more than one region.

  • What is Multi Provider? — Using more than one provider simultaneously in a single Terraform configuration.
  • Cross Provider Reference — How to reference resources across different providers in one configuration.
  • State Sharing — Data sharing strategies between separate Terraform configurations using remote state.

13. CI/CD #

This section covers integrating Terraform into CI/CD pipelines for automated, safe, and controlled infrastructure deployment.

flowchart LR
    A["Push Code"] --> B["CI: validate"]
    B --> C["CI: plan"]
    C --> D["Security Scan"]
    D --> E["Approval"]
    E --> F["CD: apply"]
    F --> G["Notify"]

    style A fill:#e3f2fd
    style F fill:#c8e6c9
    style G fill:#e8f5e9
  • CI Pipeline — Integrating Terraform into a CI pipeline for automatic validation, linting, and testing.
  • Plan Approval Strategy — Patterns for reviewing and approving execution plans before applies run in production.
  • Automated Apply — Strategies and considerations for automating terraform apply in a CD pipeline.
  • Policy as Code — Implementing infrastructure policies using Sentinel or OPA.
  • Drift Detection Automation — Automating periodic infrastructure drift detection and handling.
  • Terraform Cloud — The managed Terraform platform for team collaboration, remote state, and integrated CI/CD.

14. Security #

Terraform touches credentials and important resources. This section covers the security practices that should be applied from the start.

flowchart TD
    subgraph Layers["Security Layers"]
        CODE["Code: .gitignore, sensitive vars"]
        RUNTIME["Runtime: Env vars, Vault"]
        STATE_L["State: Encrypt, access control"]
        PIPELINE["Pipeline: Secret masking, scanning"]
    end

    CODE --> RUNTIME --> STATE_L --> PIPELINE

    style Layers fill:#fff3e0
  • Provider Authentication — How to authenticate Terraform to cloud providers securely without storing credentials in code.
  • Environment & Secret — Managing secrets and credentials through environment variables and external secret managers.
  • Credential Rotation Strategy — Regular credential rotation strategies to minimize the risk of misuse.
  • Secret Exposure Risk — The risk of secret leaks through state files, output logs, and version control.
  • Least Privilege — The principle of granting the minimal access rights needed for Terraform operations.
  • Common Security Mistakes — Frequent security mistakes in Terraform implementations and how to avoid them.

15. Best Practice #

This section summarizes the best patterns and anti-patterns you must understand to manage Terraform at team and production scale.


🎯 Who Should Read This Website? #

flowchart LR
    subgraph Audience["Target Audience"]
        DEV["Developers who want to\nunderstand IaC"]
        DOPS["DevOps & Cloud\nEngineers"]
        TIM["Teams that want to\nstandardize Terraform"]
        LEARN["Anyone who wants to\nlearn Terraform deeply"]
    end

    style Audience fill:#e3f2fd

This website suits developers who want to understand Infrastructure as Code, DevOps Engineers and Cloud Engineers working with Terraform daily, teams wanting to apply Terraform consistently and in a standardized way, and anyone who wants to understand Terraform conceptually and practically — not just memorize its commands.


🚀 How to Use This Website #

  1. Start from the Basic section if you’re new to Terraform.
  2. Follow the material order according to the sidebar TOC to build a complete understanding.
  3. Use this website as a reference when working directly with Terraform in real projects.

Every article is designed to stand alone, but they’re conceptually connected — so you can read sequentially or jump straight to the topic you need.


✨ Closing #

Terraform isn’t just a provisioning tool, but an important foundation in modern DevOps practice. By understanding Terraform correctly, you can build infrastructure that is reproducible, secure, and easy to manage in the long term.

We hope this website helps you understand Terraform more deeply and apply it confidently in the real world.

  • 15 material domains — from foundations to production best practices, arranged systematically according to the sidebar TOC.
  • Start from Basic — first understand why Terraform exists and what problems it solves before learning its commands.
  • State is the core — invest more time understanding state management; mistakes here are the most expensive in production.
  • The workflow must be memorizedinit → plan → apply is the main working cycle; understand what happens at each stage.
  • Modules for scalability — start modularizing from the beginning before the configuration grows hard to manage.
  • Security isn’t optional — credential exposure through state files and logs is a real risk that must be handled from day one.
  • Read the anti-patterns — the Best Practice section contains production failure scenarios you must read before deploying to a real environment.

Next: What is Terraform? →
About | Author | Content Scope | Editorial Policy | Privacy Policy | Disclaimer | Contact