Back to Education

Infrastructure as code: Terraform and OpenTofu

Define cloud infrastructure, DNS and clusters as code; change it safely with state, modules, plan review and continuous reconciliation.

Duration: 4.5 days (36 hours) Level: Intermediate Target Audience: DevOps and platform engineers, developers who own infrastructure
Terraform OpenTofu IaC Cloud DevOps

Overview

Infrastructure built by hand in a console lives in the memory of whoever built it. Infrastructure defined as code can be reviewed, rebuilt and rolled back. In this training we define servers, networks, DNS and storage with Terraform and its open-source continuation OpenTofu, apply changes through plan review and catch drift between the infrastructure and the code. We build and run our own clusters this way.

Course content

1. Infrastructure as code

  • Declarative versus imperative
  • Terraform and OpenTofu
  • The cost of manual setup

2. Language basics

  • Providers, resources and data sources
  • Variables, locals and outputs
  • count, for_each and dynamic blocks
  • Functions and expressions

3. The state file

  • What state holds
  • Remote backends and locking
  • Secrets in state
  • state mv, rm and import

4. Modules

  • Designing modules
  • Versioning modules
  • Per-environment configuration

5. Cloud resources

  • Servers, networks and firewalls
  • DNS records
  • Object storage and access keys
  • Lab: a server, network and DNS record as code

6. Plan review

  • Reading the plan output
  • The plan in the pull request
  • Catching destructive changes

7. Protection

  • prevent_destroy and lifecycle
  • Narrowing permissions
  • Keeping secrets outside

8. Continuous reconciliation

  • Drift detection
  • A Terraform controller inside Kubernetes
  • Auto-apply and approval gates

9. Operations

  • Provider and version upgrades
  • Recovery: a broken state
  • Lab: catching a harmful change at plan time

Schedule

Each module takes about 4 hours, half a day; 36 hours in total.

  • Day 1: modules 1 and 2
  • Day 2: modules 3 and 4
  • Day 3: modules 5 and 6
  • Day 4: modules 7 and 8
  • Day 5 (half day): module 9

Prerequisites

  • Basic Linux command line
  • Basic experience with a cloud provider (AWS, Azure, Hetzner or similar)
  • Pull requests in Git

Training format

  • On site or remote: at your office or in live virtual sessions.
  • Hands-on: every day ends with lab sessions where you apply that day’s topic to a working example.
  • Lab environment: participants get a prepared working environment and a sample code repository.
  • Tailored to your team: content and examples are adapted to your stack after a short call before the training.
  • Materials: slides, lab guides and reference code stay with you after the training.
Ready to Start?

Ready to start your project?

Let's discuss how we can help bring your ideas to life.