Terraform and OpenTofu: infrastructure as code for teams

Write, test and review infrastructure code with Terraform or OpenTofu: providers, state, modules, imports, refactoring and safe CI workflows

8 ratings 2,260 students Sample

Created by Rahul Menon

  • Updated September 2026
  • English
  • Intermediate

What you will learn

  • Write clear HCL with variables, outputs, locals and expressions
  • Configure remote state with locking and understand what state contains
  • Design and version reusable modules
  • Import existing resources and refactor code without destroying anything
  • Test infrastructure code and validate plans before applying
  • Run a reviewed plan and apply workflow in CI

Course content

6 sections, 26 lessons, 4h 4m total

Infrastructure as code basics 5 lessons · 44 min
  • Video: Why infrastructure as code Preview 8 min
  • Article: Your first configuration Preview 11 min
  • Article: State: what it is and why it matters 11 min
  • Article: Reading a plan like a reviewer 9 min
  • Quiz: Check your understanding 5 min
The HCL language in depth 4 lessons · 39 min
  • Video: Variables, locals and outputs 10 min
  • Video: count, for_each and dynamic blocks 11 min
  • Article: Expressions and functions 9 min
  • Video: Data sources and dependencies 9 min
Modules 4 lessons · 38 min
  • Video: Writing your first module 11 min
  • Article: Module design: small and composable 10 min
  • Video: Versioning and publishing modules 9 min
  • Video: Using public modules wisely 8 min
Changing existing infrastructure safely 4 lessons · 39 min
  • Article: Importing resources with import blocks 11 min
  • Video: Refactoring with moved blocks 10 min
  • Video: Removing resources from management 8 min
  • Article: Detecting and handling drift 10 min
Testing and policy 4 lessons · 39 min
  • Video: Static checks: fmt, validate and linters 8 min
  • Video: Check blocks and preconditions 10 min
  • Article: The built in test framework 12 min
  • Video: Policy as code 9 min
Team workflows 5 lessons · 45 min
  • Video: Plan on pull request, apply on merge 12 min
  • Article: Environments and directory layout 10 min
  • Video: Upgrading providers and versions 9 min
  • Video: Choosing between Terraform and OpenTofu 8 min
  • Quiz: Final check 6 min

Requirements

  • Basic command line and Git skills
  • Some familiarity with a cloud provider, ideally AWS
  • An AWS account for the hands on parts

Description

Infrastructure as code turns servers, networks and permissions into files you can review, version and reuse. Terraform made the approach mainstream, and OpenTofu, its open source fork under the Linux Foundation, shares the same language and workflow. This course teaches both, with the habits that make infrastructure code safe for a team.

What you will learn

  • The HCL language: resources, variables, outputs, locals and expressions
  • How state works, why it matters and how to store and lock it remotely
  • Modules that are small, documented and versioned
  • Importing existing resources and refactoring safely with moved blocks
  • Testing with validate, plan checks, check blocks and the built in test framework
  • A pull request workflow where every plan is reviewed before it is applied

Terraform or OpenTofu

Since 2023 Terraform has been released under the Business Source License, and OpenTofu was created as an open source fork. For everyday work the two are very similar: the same HCL, providers and workflow. Where features differ, such as OpenTofu's state encryption, I show both. Commands are written as terraform; replace with tofu if you use OpenTofu.

The examples

We build infrastructure on AWS: a VPC, a container service, a database and IAM roles, organised into modules and deployed to two environments. The concepts apply equally to Azure, Google Cloud and other providers.

Who this course is for

  • Engineers moving from console clicks to code
  • Developers who own their service's infrastructure
  • Teams whose Terraform has grown messy and hard to change

Instructor

Rahul Menon

DevOps engineer teaching GitHub Actions and Terraform for small teams that ship every day

  • 4.4 instructor rating
  • 21 reviews
  • 6,820 students
  • 3 courses
  • Sample

I help teams move from manual releases to pipelines they trust. Most of my work is GitHub Actions workflows, Terraform modules and the review habits that keep both maintainable.

I teach CI/CD and infrastructure as code as everyday engineering, not as a separate specialism. That means readable YAML, small reusable pieces, secrets handled properly and plans that a reviewer can understand in two minutes.

Every course uses a sample repository you fork and change. You will break the pipeline on purpose, read the logs and fix it, because that is the skill you will use most.

View profile

Student reviews

4.4 8 ratings
5 star 50%
4 star 38%
3 star 13%
2 star 0%
1 star 0%
Laila F. Sep 19, 2026
Sample

Module design advice is excellent

Small composable modules and not wrapping single resources changed how our platform team designs modules.

Ana M. Sep 6, 2026
Sample

Plan reading is a superpower

The plan review checklist caught a database replacement in our project on the first day I used it.

Kenneth O. Aug 22, 2026
Sample

Import and moved blocks explained

We adopted a whole hand built environment with import blocks and then refactored it with moved blocks, without a single replacement.

Nia W. Aug 8, 2026
Sample

Remote state finally makes sense

The state lesson explained why our team kept fighting lock errors and how to split state properly.

Beatriz S. Jul 4, 2026
Sample

Good coverage of both tools

Nice to see Terraform and OpenTofu side by side. The test framework lesson was the most useful for me.

Ilya K. May 29, 2026
Sample

Solid team workflow section

Plan on pull request and apply on merge with OIDC is now how we work. Would like more on Azure examples.

Diego R. May 1, 2026
Sample

Clear explanations of for_each

The reordering problem with count was exactly what broke our security group rules last year.

Simon P. Mar 8, 2026
Sample

Strong content, AWS heavy

Everything was accurate, but nearly all examples are AWS. Fine for me, maybe less so for others.

$69.99 Enroll now
SampleSample catalog: the instructors, courses, reviews and stats on this site are demo content.