This book is for Sysadmins, Operations Engineers, Release Engineers, Site Reliability Engineers, DevOps Engineers,
Infrastructure Developers, Full Stack Developers, Engineering Managers, CTOs, and anyone else responsible for the
code after it has been written. If you're the one managing infrastructure, deploying code, configuring
servers, scaling clusters, backing up data, monitoring apps, and responding to alerts at 3AM, then this book is for
Ch 1: Why Terraform
How DevOps is transforming the way we run software; an overview of infrastructure as code tools, including
configuration management, server templating, orchestration, and provisioning tools; the benefits of infrastructure as
code; a comparison of Terraform, Chef, Puppet, Ansible, SaltStack, OpenStack Heat, and CloudFormation; how to combine
tools such as Terraform, Packer, Docker, Ansible, and Kubernetes.
Ch 2: Terraform Syntax
Installing Terraform; an overview of Terraform syntax; an overview of the Terraform CLI tool; how to deploy a single
server; how to deploy a web server; how to deploy a cluster of web servers; how to deploy a load balancer; how to
clean up resources you've created.
Ch 3: Terraform state
What Terraform state is; how to store state so that multiple team members can access it; how to lock state files to
prevent race conditions; how to isolate state files to limit the damage from errors; how to use Terraform workspaces;
a best-practices file and folder layout for Terraform projects; how to use read-only state.
Ch 4: Terraform modules
What modules are; how to create a basic module; how to make a module configurable with inputs and outputs; local
values; versioned modules; module gotchas; using modules to define reusable, configurable pieces of infrastructure.
Ch 5: Terraform tips & tricks
Loops with the
for expressions, and the
for string directive; conditionals with the
for expressions, and the
if string directive; built-in functions;
zero-downtime deployment; common Terraform gotchas and pitfalls, including count and for_each limitations,
zero-downtime deployment gotchas, how valid plans can fail, how to refactor Terraform code safely, and what to do
about eventual consistency.
Ch 6: Managing secrets with Terraform (NEW in 3rd edition)
An introduction to secrets management; a comparison of common secret management tools such as HashiCorp Vault,
AWS Secrets Manager and Azure Key Vault; how to manage secrets when working with providers, including authentication
via environment variables, IAM roles, and OIDC; how to manage secrets when working with resources and data sources,
including how to use environment variables, encrypted files, and centralized secret stores; how to securely handle
state files and plan files.
Ch 7: Working with multiple providers (NEW in 3rd edition)
A closer look at how Terraform providers work, including how to install them, how to control the version, and how to
use them in your code; how to use multiple copies of the same provider, including how to deploy to multiple AWS
regions, how to deploy to multiple AWS accounts, and how to build reusable modules that can use multiple providers;
how to use multiple different providers together, including a discussion of multi-cloud, and an example of using
Terraform to run a Kubernetes cluster (EKS) in AWS and deploy Dockerized apps into the cluster.
Ch 8: Production-grade Terraform code
Why DevOps projects always take longer than you expect; the production-grade infrastructure checklist; how to build
Terraform modules for production; small modules; composable modules; testable modules; releasable modules; Terraform
Registry; variable validation; versioning Terraform, Terraform providers, Terraform modules, and Terragrunt;
Terraform escape hatches.
Ch 9: How to test Terraform code
Manual tests for Terraform code; sandbox environments and cleanup; automated tests for Terraform code; Terratest;
unit tests; integration tests; end-to-end tests; dependency injection; running tests in parallel; test stages;
retries; the test pyramid; static analysis; plan testing; server testing.
Ch 10: Using Terraform as a team
How to adopt Terraform as a team; how to convince your boss; a workflow for deploying application code; a workflow for
deploying infrastructure code; version control; the golden rule of Terraform; code reviews; coding guidelines;
Terraform style; CI/CD for Terraform; the deployment process.
The book is now in its 3rd edition, which adds over 100 pages of new content, including two completely new chapters
(Managing Secrets with Terraform and Working with Multiple Providers), and major updates to all the original
chapters. Check out the
3rd edition announcement blog post
for the details on what changed!