Terraform Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production; see the section bibliography for the reference material consulted while preparing these pages. |
A single-page, colour-coded summary of the Terraform essentials — the write, plan and apply workflow and the everyday
CLI commands and environment variables, the HCL skeleton, types, expressions and the most useful functions,
meta-arguments, variable precedence and validation, state and backends, modules, import and refactoring blocks,
sensitive, ephemeral and write-only values, testing, quality scanning and policy, CI with OIDC, HCP Terraform and
Stacks, a Terraform versus OpenTofu comparison, a troubleshooting table and a strip of what changed since older
tutorials — handy for quick memorization or as a printable desk reference through the
downloadable PDF. It reflects Terraform 1.17, OpenTofu 1.13, the AWS
provider 6.x, AzureRM 5.x, the Google provider 8.x and hashicorp/setup-terraform v4. The section home page is
Terraform.
For the full explanation, every argument, and additional examples, see the dedicated pages:
Foundations — Introduction and Infrastructure as Code, Getting Started with Terraform, and HCL Syntax and Configuration Files.
Configuration language — Providers, Resources and Data Sources, Variables, Outputs and Locals, Types and Expressions, Functions, Meta-Arguments: count, for_each and depends_on, and Lifecycle, Validation and Checks.
Plan, apply and state — Dependency Graph and Plan, CLI Essentials, State, Backends and Remote State, and Workspaces, Environments and Project Structure.
Modules — Modules and Module Development and Publishing.
Changing existing infrastructure — Import and Query, Refactoring with moved and removed Blocks, Sensitive Data, Ephemeral Values and Write-Only Arguments, and Provisioners, Actions and Post-Apply Operations.
Quality, testing and policy — Testing Terraform and OpenTofu, Code Quality and Security Scanning, and Policy as Code.
Automation and platforms — CI/CD and Automation, HCP Terraform and Terraform Enterprise, and Terraform Stacks.
Clouds and providers — Terraform on AWS, Terraform on Azure, Terraform on Google Cloud, Docker, Kubernetes and Helm Providers, Provider Development, and Machine-Readable Output and Integrations.
OpenTofu — OpenTofu.
Putting it together — Best Practices and Troubleshooting, Bookshelf End to End, and What Changed and Migration.