Cheat SheetsTerraform Associate
HashiCorpAssociate

Terraform Associate Cheat Sheet

HashiCorp Certified: Terraform Associate — Quick reference for the exam

CLI Commands

42
TOP= might appear on the exam
Initialization5 cmds
terraform initTOP

Initializes the directory: downloads providers and modules

terraform init -upgrade

Updates providers to the latest version that meets constraints

terraform init -backend=false

Only downloads modules, without configuring the backend

terraform init -reconfigure

Forces backend reconfiguration

terraform init -migrate-stateTOP

Migrates state to the newly configured backend

Comparisons

5
CommandSince versionStatusWhen to use it
terraform taint resource.addr≤v0.15.2DeprecatedDo not use in new code
terraform apply -replace=resource.addrv0.15.2+RecommendedForce recreation of a specific resource

Quick Reference

36

IaC concepts

DeclarativeTOP

Terraform is declarative: you describe the desired state, not the steps

IdempotentTOP

Applying the same config multiple times = same result

ProviderTOP

Plugin that translates HCL into API calls to the cloud provider

Resource

Managed unit of infrastructure (aws_instance, azurerm_vm...)

Data sourceTOP

Reads data from existing infrastructure without creating it

Module

Reusable set of resources (folder with .tf files)

Output

Value exported from the state, accessible by parent modules or the user

Variable

Input parameter that allows reusing configurations

State lifecycle

State fileTOP

terraform.tfstate — maps HCL resources ↔ real resources

Editing state

Never edit the state manually; use terraform state commands

Remote stateTOP

Enables team collaboration and locking

State lockingTOP

Prevents corruption when multiple users apply simultaneously

Backup

terraform.tfstate.backup: automatic copy of the previous state

sensitive=trueTOP

Hides the value in logs but it DOES persist in the state

ephemeral=trueTOP

(v1.10+): the value NEVER persists in state or plan

Providers and Registry

Terraform Registry

registry.terraform.io — public source for providers and modules

required_providers

Declares which providers the project needs, with version constraints

Version constraint ~>TOP

~> 5.0 accepts 5.x but not 6.0

.terraform.lock.hclTOP

Pins exact provider versions, must be committed to git

init -upgrade

Updates providers while respecting constraints

Modules

Root moduleTOP

Directory where terraform is executed

Child module

Referenced with a module {} block from the root or another module

SourcesTOP

Local path, Terraform Registry, GitHub, S3, GCS

terraform get

Downloads modules without initializing providers

count and for_eachTOP

Allow creating multiple instances of a resource/module

HCP Terraform (formerly Terraform Cloud)

HCP Terraform

HashiCorp's official remote backend for state management and execution

HCP Workspaces

Isolated environments with their own state

SentinelTOP

Policy-as-code framework integrated with HCP Terraform

Remote executionTOP

Plans/applies run in the HCP cloud

Private Registry

Private module registry within the organization

Exam tips

terraform taintTOP

DEPRECATED since v0.15.2 → use -replace

terraform refreshTOP

DEPRECATED since v0.15.4 → use plan -refresh-only

terraform fmt

Opinionated: always produces the same result

.tfvars in modules

.tfvars files are not loaded in child modules, only in the root

for_each vs countTOP

for_each requires a set or map; count requires a number

depends_on

Creates an explicit dependency; Terraform resolves implicit dependencies automatically

Ready to practice?

Put what you learned to the test with original Terraform Associate exam questions.

Start Terraform Associate mock exam

Unlimited mock exams with the Pro plan

Back to top