OpenTofu Tutorial for Beginners

This free OpenTofu tutorial takes you from “what is infrastructure as code?” to writing configuration, managing state, building modules, keeping secrets safe, testing, automating with GitHub Actions and deploying to Kubernetes and Azure. Every part is hands-on and runs free on your own computer, and from Part 2 on, every command and output is real.

Start with Part 1 and go in order. Each part builds on the one before, and the parts below are linked as they’re published.

Who This Series Is For

  • complete beginners who have never written infrastructure as code
  • developers and IT staff who want to stop setting up servers by hand
  • Terraform users who want to learn OpenTofu and the features only it has

What You Need

A Mac, a Windows 11 PC or an Ubuntu machine where you’re allowed to install software, with Docker on it from Part 3. No programming knowledge is needed. Almost every part is free and needs no account; a few use a free GitHub account, and the optional Azure parts at the end need an Azure subscription.

Install and Set Up OpenTofu

Each operating system has its own step-by-step guide, linked here as it’s published:

  • How to Install OpenTofu on macOS
  • How to Install OpenTofu on Windows 11
  • How to Install OpenTofu on Ubuntu
  • How to Set Up VS Code for OpenTofu

All Parts

Module A: Start Here

Module B: Write Configuration

  • Part 4: Variables, tfvars and Outputs
  • Part 5: Locals, Expressions and tofu console
  • Part 6: Functions
  • Part 7: Data Sources
  • Part 8: count, for_each and enabled
  • Part 9: Dependencies, Networks, Volumes, Dynamic Blocks and the Graph
  • Part 10: Lifecycle Rules
  • Part 11: Validation, Conditions and Check Blocks

Module C: Add a Database

  • Part 12: PostgreSQL in Docker, Managed with OpenTofu

Module D: Modules

  • Part 13: Your First Module
  • Part 14: Module Sources and Versions
  • Part 15: OCI Registries for Modules and Providers

Module E: State

  • Part 16: Inside OpenTofu State
  • Part 17: Refactor Safely: moved, removed, state mv and rm
  • Part 18: Import Existing Infrastructure
  • Part 19: Remote State in PostgreSQL with Locking
  • Part 20: S3 Backend with Native Locking
  • Part 21: Encrypt State and Plan Files
  • Part 22: Workspaces and Sharing Outputs

Module F: Secrets

  • Part 23: Ephemeral Values and Write-Only Attributes
  • Part 24: Secrets with OpenBao

Module G: Operations

  • Part 25: Plan and Apply Options
  • Part 26: CLI Configuration and Provider Installation
  • Part 27: Logs and Tracing
  • Part 28: Provisioners and terraform_data

Module H: Test and Team

  • Part 29: Test Your Configuration with tofu test
  • Part 30: Mock Providers and Overrides
  • Part 31: Multiple Provider Instances
  • Part 32: Manage GitHub with OpenTofu
  • Part 33: GitHub Actions CI/CD

Module I: Kubernetes

  • Part 34: Kubernetes for Free with kind
  • Part 35: Helm Charts and Kubernetes Secrets

Module J: Azure for Free

  • Part 36: Deploy to Azure for Free: Resource Group and App Service F1
  • Part 37: Azure Static Web Apps Free and Clean Up

Module K: Finish

  • Part 38: Migrate from Terraform to OpenTofu
  • Part 39: Final Project, Cheat Sheet and What to Learn Next

The Practice Project

Every part works on the same made-up bookshop website, so you watch one real project grow from a single web page to a website with a database, running on Docker, Kubernetes and Azure. It uses the same invented books as the PostgreSQL Tutorial. If you start in the middle of the series, each part begins with the complete files you need.

More DevOps Series

This series is part of the DevOps Series. To browse every topic, see the Blog Series page.

OpenTofu® is a registered trademark of LF Projects, LLC. Other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by the OpenTofu project.

Up ↑