Terraform

Defines cloud infrastructure as version-controlled code.

CurrentadvancedGuide only -- no course yet

Overview

Terraform lets you define cloud infrastructure (servers, databases, networking) as declarative configuration files, version-controlled and reviewable like application code, rather than clicking through a cloud console -- making infrastructure changes reproducible and auditable.

What it is
An infrastructure-as-code tool for defining and provisioning cloud resources declaratively.
Why it's used
Manually configured infrastructure ('clickops') is hard to reproduce, review, or roll back -- Terraform makes infrastructure changes a reviewable diff, like code.
Where it fits
Used to provision the cloud resources (servers, databases, networks) that an application then runs on.

Core concepts

  • Declarative configuration (.tf files)
  • Providers
  • State files
  • Plan and apply

Example

This declares the desired end state (a bucket should exist); running 'terraform apply' reconciles real infrastructure to match, similar in spirit to how Kubernetes reconciles running containers to a declared desired state.

resource "aws_s3_bucket" "assets" {
  bucket = "my-app-assets"
}

Common use cases

  • Provisioning cloud infrastructure reproducibly
  • Managing infrastructure changes through code review

Project ideas

  • Write a Terraform configuration for a single S3 bucket and walk through what 'terraform plan' would show before applying it

Official references