Chapter 3 of 8 · HashiCorp Terraform Associate 004

Core Terraform Workflow

Init, validate, plan, apply, destroy and terraform fmt style.

  • 3topics
  • 14 minfast track
  • 2diagrams and exhibits

Topics in this chapter

Take them in order, or jump to the one you need.

  1. 1The Terraform Workflow, Init and ValidateTerraform Associate (004): the write, plan and apply workflow, what terraform init sets up, and what terraform validate checks…Diagram5 min
  2. 2Plan and ApplyTerraform Associate (004): generate and review an execution plan, save it with -out, read plan symbols, and apply changes with or…Diagram5 min
  3. 3Destroy and FormatTerraform Associate (004): destroy managed infrastructure with terraform destroy or plan -destroy, and keep code in canonical…4 min

About this chapter

What this chapter covers

Core Terraform workflow covers the commands you run every day: write configuration, initialize the working directory, validate it, plan, apply, and eventually destroy. It also covers keeping configuration in the canonical style with terraform fmt.

The chapter has three parts: the workflow itself with terraform init and terraform validate, then generating, reviewing and applying an execution plan, then destroying managed infrastructure and formatting configuration.

Questions are single-answer, multiple-answer ("Pick the 2 correct responses below") and true or false statements, mostly direct recall of commands and behavior plus short HCL snippets that open "Consider the following configuration snippet:". There are no exhibits.

How the topics fit together

WriteHCL configurationterraform initReadyproviders, modules, backendterraform validateValidterraform planReviewed planterraform applyInfrastructureInfrastructureterraform destroyRemoved

You write configuration and run terraform init once per working directory, and again after provider, module or backend changes. Validate and format while you write, plan to preview, apply to make the changes, and destroy when the infrastructure is no longer needed.

  • Workflow questions ask for the order of the steps and what each one is for.
  • Init questions ask what terraform init downloads and configures, and when to run it again.
  • Validate questions ask what terraform validate checks and what it does not.
  • Plan and apply questions ask about saved plans, plan symbols, approval and what apply updates.
  • Destroy and format questions ask how to remove infrastructure safely and what terraform fmt changes.
Exam tip

Know which commands touch real infrastructure. Only terraform apply and terraform destroy change it; init, validate, fmt and plan never create, change or delete a resource.

How to use these pages

Each topic page has the same shape, so you can skim for what you need.

  • What it is: the idea in plain words.
  • How it works: the mechanism, with tables and examples.
  • What to remember for the exam: the facts to memorize and how questions are phrased.
  • Common mistakes: the classic traps.
  • Check yourself: three questions to test your understanding.

Ready for more practice?

The full HashiCorp Terraform Associate 004 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by HashiCorp. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.