HashiCorp Terraform Associate 004: State and Plans
The Terraform Associate 004 exam validates foundational Terraform Community Edition and HCP Terraform knowledge for cloud engineers. HashiCorp’s current preparation path states that the exam tests Terraform 1.12 and includes HCP Terraform content.
The 004 version also adds several areas that were not emphasized in 003: lifecycle rules such as depends_on and create_before_destroy, custom conditions for configuration validation, ephemeral values and write-only arguments, and organizing HCP Terraform workspaces and projects. The exam is still an associate credential, but it expects practical understanding of how Terraform plans and manages infrastructure state.
Start by understanding why declarative infrastructure is useful: repeatability, reviewability, automation, drift detection, and shared ownership. Terraform configuration should describe desired infrastructure rather than become a script that manually performs each step.
Build one small environment from code, destroy it, and recreate it. Any manual step you forgot to document becomes evidence that the environment is not yet truly reproducible.
The internal Terraform infrastructure design article is useful for seeing how infrastructure as code supports architecture rather than existing only as configuration syntax.
Practice provider requirements, configuration, resource blocks, data sources, and provider version constraints. The exam does not require deep knowledge of a particular cloud, but it does expect you to understand how Terraform communicates with external APIs.
Use a data source and a managed resource in the same configuration so the difference between reading existing infrastructure and creating infrastructure is concrete.
Change a provider version deliberately and inspect the lock file. Dependency control is part of reproducible infrastructure, not just an implementation detail.
Practice aliases or multiple provider configurations conceptually so you understand how one Terraform configuration can target different regions, accounts, or service contexts. The important lesson is that provider configuration is part of resource identity and behavior.
Review the provider lock file after initialization and explain why reproducible dependency selection matters. A team should not get different provider behavior simply because two engineers initialized the same code on different days.
Terraform state maps configuration to real infrastructure. Practice local and remote state, locking, sensitive information considerations, refresh, drift, imports, and what happens when state is lost or edited incorrectly.
Create a resource manually outside Terraform, then import or reconcile it. Next, change a managed resource outside Terraform and observe how a plan reports drift.
Treat state as protected operational data. A configuration repository without the correct state does not fully describe the managed environment.
Practice remote state with locking and team access rather than stopping at a local file. Simulate two people attempting a change at the same time and observe why coordination around state matters. The exam is foundational, but the operational lesson is that state is shared infrastructure data, not a disposable cache.
Review sensitive values in state. Marking an output as sensitive can reduce accidental display, but it does not automatically remove the value from state. This distinction is important when designing workflows that handle credentials or other secrets.
Run terraform fmt, validate, plan, and apply as a deliberate sequence. Read the plan closely enough to distinguish create, update, replace, and destroy actions before accepting them.
Add a change that forces replacement and inspect why. Then use lifecycle rules such as create_before_destroy only when the dependency and availability requirement justify them.
A safe Terraform workflow should make destructive intent visible before apply, especially when the same configuration controls many production resources.
Use saved plans in one lab so the exact reviewed actions are the ones applied. Then change the configuration after the plan is created and observe why stale plans can be misleading or invalid. This connects review discipline with the actual Terraform execution model.
Practice refresh-only or drift-oriented workflows conceptually where appropriate. The useful habit is separating a change you intend to make from a difference you merely discovered. Operators need to know whether Terraform should reconcile the infrastructure or first explain why reality changed.
Practice input variables, type constraints, validation, locals, outputs, and module composition. Reuse is valuable when it reduces duplication without hiding important differences between environments.
Create a small module and consume it twice with different inputs. Then decide which value belongs as a variable, which belongs as a local derived expression, and which should be exposed as an output.
The Terraform Associate certification context is useful because the exam stays foundational: focus on clear reusable patterns rather than complex framework-like abstractions.
Add an object-typed variable with validation so one module input represents a coherent structure rather than many loosely related values. Then expose only the outputs another module or user actually needs. This keeps interfaces small and easier to maintain.
Version a module and change its internal implementation without changing its interface. The exercise shows why modules are most useful when consumers depend on stable behavior and outputs rather than internal resource layout.
Practice count, for_each, depends_on, lifecycle, and create_before_destroy on a small configuration. The hard part is not remembering the syntax; it is understanding what dependency or replacement behavior the argument changes.
Use for_each when stable keys matter and observe how changing keys can create or destroy resource instances. This makes identity and address behavior more tangible.
Add a dependency that Terraform cannot infer naturally and use depends_on deliberately. Overusing explicit dependencies can make plans harder to understand, so the relationship should have a real reason.
Add prevent_destroy to a conceptual example and explain when that guardrail is useful and when it could block legitimate maintenance. Lifecycle controls are safety mechanisms, not substitutes for understanding the planned change.
Then compare create_before_destroy with a resource that cannot exist twice because of naming or platform constraints. The rule only helps when the provider and resource model can support the replacement sequence.
Terraform Associate 004 adds custom conditions for validating configuration plus newer patterns around ephemeral values and write-only arguments. Study these as mechanisms for expressing constraints and reducing persistence of sensitive or temporary values.
Build a variable with a validation condition and test both accepted and rejected input. Then review where sensitive information can appear in configuration, plan output, state, and logs.
The purpose is operational safety: catch invalid configuration early and minimize unnecessary persistence of secrets or one-time values.
Use preconditions or postconditions conceptually alongside input validation so you can distinguish validating configuration from validating assumptions about created or observed infrastructure.
The 004 exam highlights newer language features because Terraform workflows increasingly need safer handling of temporary values and stricter contracts. Treat those features as operational safeguards, not isolated syntax trivia.
The 004 exam explicitly includes HCP Terraform, including workspace and project organization. Understand remote runs, shared state, variables, permissions, workspace grouping, and how centralized workflows improve collaboration.
Create or conceptually design separate workspaces for environments or components and explain why one project should group them. The structure should reflect ownership and lifecycle rather than arbitrary naming.
Remote execution does not remove Terraform fundamentals. State, plans, provider behavior, and configuration remain the core; HCP Terraform changes how teams collaborate around them.
Design a workspace structure for development, staging, and production and decide which values belong as workspace variables, variable sets, or code. The best organization follows ownership and lifecycle rather than simply mirroring folder names.
Add policy or approval thinking around remote runs. Central execution can improve consistency, but it also concentrates change authority. Teams need clear permissions, reviewed plans, and controlled promotion so collaboration does not become unrestricted infrastructure access.
Review how credentials reach remote runs. Central execution can reduce local secret sprawl, but the workspace or project now becomes a sensitive control point. Teams should understand variable scope, permissions, and who can approve or trigger runs before treating HCP Terraform as merely hosted state.
The KCNA exam covers Kubernetes and cloud-native foundations. Terraform can provision infrastructure used by Kubernetes without replacing cloud-native platform knowledge.
The Linux+ XK0-006 exam goes deeper into operating-system administration. Terraform manages infrastructure state; Linux+ validates what happens inside many of the systems Terraform may create.
The HashiCorp certification inventory can help with vendor-specific progression. Terraform Associate 004 is strongest when you can explain how desired configuration, provider APIs, state, plans, modules, validation, and HCP Terraform collaborate to make infrastructure changes controlled and repeatable.
Finish by rebuilding one environment from a clean checkout. If state, variables, provider versions, and workflow are all understandable to another engineer, you are practicing the role the exam is designed to validate.
Finish with one code-review exercise. Read a plan and configuration written by someone else and identify destructive changes, hidden dependencies, state-sensitive operations, and assumptions about variables or provider versions.
That exercise mirrors real Terraform work more closely than building only your own familiar configurations. Associate-level competence includes understanding infrastructure changes before approving them.