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 you.
How DevOps is transforming the way we run software; an overview of infrastructure as code tools, including configuration management, server templating, orchestration, and provisioning; 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.
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.
What is Terraform state; how to store state so multiple team members can access it; how to lock state files to prevent race conditions; how to manage secrets with Terraform; 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.
What are modules; how to create a basic module; how to make a module configurable; local values; versioned modules; module tips and tricks; using modules to define reusable, configurable pieces of infrastructure.
Advanced Terraform syntax; loops; if-statements; if-else statements; for and for-each expressions; built-in functions; zero-downtime deployment; common Terraform gotchas and pitfalls, including count limitations, zero-downtime deployment gotchas, valid plans can fail, refactoring problems, and eventual consistency.
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; Terraform escape hatches.
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; property checking.
How to adopt Terraform as 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; deployment process.
The book includes dozens of code samples. You can find the code here: https://github.com/brikis98/terraform-up-and-running-code.
The book is now in its 2nd edition, which is nearly double the length of the 1st edition (~160 more pages), including two completely new chapters (Production-grade Terraform Code and How to Test Terraform Code), and major changes to all the original chapters and code examples. Check out the 2nd edition announcement blog post for the details on what changed!
Terraform: Up & Running, 2nd edition is available at the online stores below and at your local bookstore.