Terraform on AWS

Welcome

A practical, first-principles guide to Terraform — what each concept does, how the pieces fit together, when to reach for them, and where the failure modes are. The concepts are universal; AWS is the provider the examples are built on.

13 chapters 80 topics covered 8 hours audio Knowledge check on every topic For all levels

About This Course

Terraform has a reputation for being easy to start and hard to run well. Writing a few resources and running apply takes an afternoon. Running it for a team, across environments and accounts, without the state file becoming a source of fear — that is where most of the real learning lives, and where most tutorials stop.

This course covers both ends. It explains Terraform from first principles, in the order that makes the pieces click: what Infrastructure as Code actually buys you, the one idea the whole tool rests on — declarative state reconciled against reality — then resources, the state file, variables, iteration, and modules, then the parts of running Terraform in production that bite you: state operations, drift, testing, CI/CD, and scale.

Every topic follows a consistent structure: what it is, how it works, when to use it, when not to, the common mistakes that cost people real outages and money, and the best practices. Where two approaches compete — count versus for_each, workspaces versus directories, Terraform versus OpenTofu — the course compares them and says when each one fits rather than leaving that work to you.

Who This Is For

Engineers who build or operate cloud infrastructure, and those preparing to. A beginner can read it in order to build a mental model from zero. An experienced engineer can jump to a chapter to fill a gap or settle a decision — and plenty of senior engineers who ship complex systems still have soft spots in the basics, which is normal. It assumes you are comfortable on the command line and have used a cloud console, but it does not assume any prior Terraform.

A Note on Terraform, OpenTofu, and AWS

The course teaches HashiCorp Terraform 1.x. In 2023 HashiCorp changed Terraform's license, and the community forked the last open-source version as OpenTofu, now under the Linux Foundation. The two are almost entirely compatible; where they diverge on a feature, the course says so. Everything you learn about the language, state, and workflow applies to both.

Terraform is provider-agnostic — it manages AWS, Google Cloud, Kubernetes, GitHub, and hundreds more through the same language. But every code example has to target something concrete, so this course uses the AWS provider throughout. The concepts transfer to any provider; AWS is simply the vehicle that makes the examples real instead of abstract.

What You Should Already Know

  • Command-line comfort — running commands, environment variables, editing files in a shell
  • A basic feel for a cloud provider — what a virtual machine, a network, and a storage bucket are
  • Version control with Git at a basic level — commits, branches, and pull requests
  • What an API and a JSON document are, at the level of what they do
  • No prior Terraform or Infrastructure-as-Code experience required

How the Course Is Built

The thirteen chapters are ordered so the early ones teach the core and the later ones build on it. Foundations and the core workflow come first, then the state file, the language features (variables, iteration, modules), then providers and a chapter of real AWS infrastructure. The later chapters cover organizing large codebases, collaboration and CI/CD, testing, production operations, and the advanced patterns that show up at scale.

A few principles run through every chapter. They are worth stating up front, because they explain why the course is shaped the way it is.

Understand before you apply
Terraform rewards a mental model over memorized syntax. Every concept is explained from the problem it solves before how to write it.
The state file is the center
Almost every confusion in Terraform traces back to state. The course treats it as the core concept it is, not an implementation detail.
The trade-offs are the point
A feature that is right for one situation is wrong for another. The course says so, and explains when not to reach for something.
Production is operations
Infrastructure you can trust differs from a demo in the unglamorous work: locking, drift, testing, upgrades, and blast radius. That work gets its own chapters.

Chapter Map

Chapter 1
Foundations
What Infrastructure as Code is and the idea Terraform rests on. How it compares to other IaC and configuration tools, installing the CLI, providers and the Registry, your first plan and apply, and the shape of HCL.
Chapter 2
The Core Workflow
The refresh / plan / apply cycle you run all day. Resources and how they are addressed, data sources, implicit and explicit dependencies, the dependency graph, and the lifecycle meta-arguments that override default behavior.
Chapter 3
State
The file that maps your config to real resources. Why it exists, what it stores, remote backends and locking, workspaces, importing existing infrastructure, refactoring with moved blocks, and the secrets problem.
Chapter 4
Variables, Outputs, and Expressions
Parameterizing a configuration: input variables and validation, outputs as a module's return values, local values, the expression language and its operators, the built-in function library, and dynamic blocks.
Chapter 5
Iteration and Conditionals
Creating many resources from one block. count and for_each and the consequential choice between them, for expressions for reshaping data, conditional expressions, and splat expressions.
Chapter 6
Modules
The unit of reuse. What a module is, its input/output interface, calling and sourcing modules, the public Registry, versioning, composition without deep nesting, and designing a module others adopt happily.
Chapter 7
Providers in Depth
The AWS provider up close: configuration and aliases, multiple regions and accounts, the credential chain and OIDC, version constraints on the most volatile dependency you have, and the dependency lock file.
Chapter 8
Managing Real Infrastructure
The language grounded in real AWS resources: VPCs and subnets, compute and auto scaling, IAM and least privilege, secrets and sensitive inputs, and why provisioners are a last resort.
Chapter 9
Organizing Larger Codebases
Structure at scale: project and repository layout, environments as workspaces or directories, root versus shared modules, DRY patterns and their limits, and when Terragrunt earns its place.
Chapter 10
Collaboration and Automation
Terraform as a team sport: shared backends, running it in CI/CD, plan and apply approval gates, HCP Terraform, drift detection and reconciliation, and cost estimation in the pull request.
Chapter 11
Testing and Validation
Quality gates for infrastructure code: fmt and validate, static analysis and security scanning, the native test framework, policy as code, and contract testing for shared modules.
Chapter 12
Production Operations
Operating Terraform over time: large state and performance, state surgery, upgrading providers and versions, zero-downtime replacement, disaster recovery for state, and debugging with TF_LOG.
Chapter 13
Advanced Patterns
Where Terraform goes at scale: custom providers, ephemeral and write-only arguments, Terraform Stacks, generating configuration with CDKTF, pairing with Ansible, landing zones, and brownfield adoption.

Disclaimer

This course is an independent educational project created and maintained by Sergey Okinchuk. It is provided for learning and reference purposes only.

No affiliation. This course is not affiliated with, sponsored by, endorsed by, or officially connected to HashiCorp (an IBM company), the OpenTofu project, the Linux Foundation, Amazon Web Services, or any other company or project mentioned. All opinions, interpretations, and recommendations expressed are those of the author.

Trademarks. "Terraform" and "HashiCorp" are trademarks of HashiCorp, an IBM company. "OpenTofu" is a trademark of the Linux Foundation. "AWS" and "Amazon Web Services" are trademarks of Amazon.com, Inc. or its affiliates. All other product names, logos, and brands are the property of their respective owners. Use of these names and marks is for identification and educational purposes only and does not imply any endorsement.

Accuracy and currency. Terraform and the AWS provider evolve quickly — the provider ships releases most weeks, and language features, defaults, and command-line flags drift between versions. Facts in this course reflect the author's understanding at the time of writing and may not be current. Always consult the official Terraform documentation and AWS provider documentation as the authoritative sources before making operational decisions.

No warranty. This material is provided "as is" without warranty of any kind. Configuration and commands are illustrative, not production-ready, and may incur cost if applied to a real cloud account. The author accepts no liability for any loss or damage arising from reliance on the content.