Skip to content

004 · Domain 3: Core Terraform workflow · 13% of the exam

Task 3.1: Describe the Terraform workflow

Write, plan, apply: how an individual, a team and HCP Terraform run the same loop, where review happens, and which command belongs to which step.

Study it

  • Write, plan, apply for individuals, teams and HCP Terraform

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.

Question 1 · choose 1

An engineer working alone is adding a new subnet to a configuration in a Git repository. Which sequence follows the core Terraform workflow for an individual practitioner?

  1. AApply after every edit to see the result in the cloud, then write a plan at the end of the day for review
  2. BPush the commit, wait for the change to appear in the cloud, then run plan to confirm it
  3. CEdit the configuration and plan repeatedly, apply when the plan looks right, then push the commit
  4. DRun apply first so that state exists, then edit the configuration and plan the difference
Show the answer and why
  • AApply after every edit to see the result in the cloud, then write a plan at the end of the day for review

    Incorrect

    Applying each edit changes real infrastructure before any review; plans come before apply.

  • BPush the commit, wait for the change to appear in the cloud, then run plan to confirm it

    Incorrect

    Without HCP Terraform or CI connected, pushing a commit does not change any infrastructure.

  • CEdit the configuration and plan repeatedly, apply when the plan looks right, then push the commit

    Correct

    Individuals write configuration while running plans as a feedback loop, apply after a final plan review, and then push their repository to a remote.

  • DRun apply first so that state exists, then edit the configuration and plan the difference

    Incorrect

    An apply of an unedited configuration changes nothing useful; the loop starts with writing.

Write, plan, apply: the plan is both the feedback loop while writing and the final check before apply.

Question 2 · choose 1

In the write, plan, apply workflow, at which step does a practitioner see exactly what Terraform intends to create, change and destroy?

  1. AThe write step, as soon as the files are saved
  2. BThe apply step, only after the changes are made
  3. CThe plan step
  4. DThe init step, which compares configuration with the cloud
Show the answer and why
  • AThe write step, as soon as the files are saved

    Incorrect

    Writing produces configuration; it shows no changes to real infrastructure.

  • BThe apply step, only after the changes are made

    Incorrect

    Apply also shows the plan first, but the plan step is where the preview belongs in the workflow.

  • CThe plan step

    Correct

    The plan step previews the changes Terraform will make to match the configuration.

  • DThe init step, which compares configuration with the cloud

    Incorrect

    init prepares the working directory and compares nothing.

Plan is the preview, apply is the action.

Question 3 · choose 1

A team has applied its first version of a configuration. A week later it needs to add a load balancer. Where does this change enter the core workflow?

  1. ABack at the write step; the workflow is a loop
  2. BAt the apply step, because the configuration was already planned once
  3. COutside the workflow, since it applies only to the first build
  4. DAt the init step, which has to be repeated for every new resource
Show the answer and why
  • ABack at the write step; the workflow is a loop

    Correct

    The core workflow is a loop; the next change starts again with writing configuration.

  • BAt the apply step, because the configuration was already planned once

    Incorrect

    Every change needs its own plan.

  • COutside the workflow, since it applies only to the first build

    Incorrect

    The workflow covers every change over the life of the infrastructure.

  • DAt the init step, which has to be repeated for every new resource

    Incorrect

    Adding a resource of an installed provider needs no new init.

Write, plan, apply, and back to write: the same loop for every change.

Question 4 · choose 1

Several engineers edit the same configuration at the same time. In the team version of the write step, how do they avoid colliding with each other's work?

  1. AThey take turns holding the state lock while they edit files
  2. BThey work in version control branches and merge later
  3. CEach engineer keeps a private copy of the state to apply from
  4. DThey edit only in the main branch and run apply after each save
Show the answer and why
  • AThey take turns holding the state lock while they edit files

    Incorrect

    State locks protect state during operations, not editing of files.

  • BThey work in version control branches and merge later

    Correct

    Team members save changes to version control branches to avoid collisions and resolve incompatible changes when merging.

  • CEach engineer keeps a private copy of the state to apply from

    Incorrect

    Private state copies lead to conflicting views of the infrastructure.

  • DThey edit only in the main branch and run apply after each save

    Incorrect

    Applying unreviewed edits defeats the team workflow.

Teams write configuration the way they write code: branches first, merges later.

Question 5 · choose 1

A new team member clones the infrastructure repository and wants to see a plan. Which command must come first?

  1. Aterraform fmt
  2. Bterraform validate
  3. Cterraform console
  4. Dterraform init
Show the answer and why
  • Aterraform fmt

    Incorrect

    Formatting is optional and does not prepare the directory.

  • Bterraform validate

    Incorrect

    validate checks the configuration but does not prepare the directory.

  • Cterraform console

    Incorrect

    console also needs an initialized directory and only evaluates expressions.

  • Dterraform init

    Correct

    A working directory must be initialized before Terraform can perform operations such as plan.

Every fresh clone starts with init.

Practise domain 3 →Practise all domains →