Skip to content

Terraform Crash Course

What is Terraform?

Terraform is an Infrastructure as Code (IaC) tool that allows you to define, preview, and deploy cloud infrastructure using a declarative language. It supports multiple cloud providers and services, making it a versatile choice for managing complex infrastructures.

Key Concepts

  1. Providers: Plugins that define and manage resources for specific platforms (e.g., AWS, Azure, GCP).
  2. Resources: The core component in Terraform that defines infrastructure objects.
  3. State: Terraform's way of keeping track of the real-world resources it manages.
  4. Modules: Reusable components that encapsulate groups of resources.

Basic Workflow

  1. Write Terraform configuration files (.tf)
  2. Initialize the working directory with terraform init
  3. Preview changes with terraform plan
  4. Apply changes with terraform apply

Example: Creating an AWS S3 Bucket

provider "aws" {
  region = "us-west-2"
}

resource "aws_s3_bucket" "example" {
  bucket = "my-terraform-bucket"
  acl    = "private"

  tags = {
    Name        = "My Terraform Bucket"
    Environment = "Dev"
  }
}

This quick introduction should give you a basic understanding of Terraform. Explore the rest of our documentation for more in-depth information and best practices.