Helmsman Academy
Terraform, end to end

Terraform foundations: HCL, providers, state and the core workflow

6 lessons · about 102 minutes of reading · Helmsman Pro

This page is the public course outline. Lessons, labs, tools and exams open after you sign in to your free account.

Sign in and start

In short

Everything you need to write and run Terraform with confidence: what infrastructure as code is for, providers and version pinning, resources and data sources, typed variables and outputs, dynamic expressions, and state with remote backends and locking.

Before you start: Basic command line and Git. Course 2 (Azure) helps for the examples.

What you'll learn

Lessons

1. Infrastructure as code and where Terraform fits

What infrastructure as code is, why teams adopt it, how Terraform works, and how it compares with Bicep, CloudFormation, Pulumi, Ansible and OpenTofu.

Sign in to open the lesson

2. Install, providers, versions and the lock file

Install Terraform, declare and constrain providers, configure several providers and aliases, and keep every machine on the same versions with .terraform.lock.hcl.

Sign in to open the lesson

3. Resources, data sources, references and dependencies

Write resources and data sources, reference attributes across them, and understand how Terraform builds its dependency graph, including when depends_on is needed.

Sign in to open the lesson

4. Variables, outputs, locals, types and validation

Make configurations reusable and safe with typed input variables, defaults, validation rules, sensitive and ephemeral values, locals, outputs and variable files.

Sign in to open the lesson

5. Expressions, functions, count, for_each and dynamic blocks

Write dynamic configuration: for expressions, conditionals, built-in functions, count versus for_each, splat expressions and dynamic blocks, plus how to test them in terraform console.

Sign in to open the lesson

6. State: local and remote backends, locking and the state commands

What state is and why it matters, local versus remote backends on Azure and AWS, locking, the state commands, and keeping secrets in state safe.

Sign in to open the lesson

Common questions

Name two things Terraform needs that Bicep doesn't.

A state file and a provider plugin download (init).

What does ~> 1.16 allow for required_version?

>= 1.16 and < 2.0.

What is the address of resource "azurerm_subnet" "aks"?

azurerm_subnet.aks

Name three complex types.

Any three of list, set, map, object, tuple.

How do you make a resource optional?

count = var.enabled ? 1 : 0, then refer to it with [0] or one().

Which command lists every address in state?

terraform state list