Skip to content

004 · Domain 8: HCP Terraform · 12% of the exam

Task 8.1: Use HCP Terraform to create infrastructure

Remote runs in HCP Terraform: the VCS-driven, CLI-driven and API-driven workflows, workspace variables, run stages and states, and where the state is kept.

Study it

  • Runs in HCP Terraform: VCS, CLI and API workflows, variables and run stages

    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

A workspace is connected to the main branch of a GitHub repository and uses manual apply. A pull request is merged into main. What happens in HCP Terraform?

  1. ANothing, until an engineer runs terraform apply from a laptop against the workspace
  2. BThe plan from the pull request is applied at once, without a new plan
  3. CA run is queued, and its plan waits for an authorized user to confirm
  4. DA run is queued for every branch in the repository, including the merged one
Show the answer and why
  • ANothing, until an engineer runs terraform apply from a laptop against the workspace

    Incorrect

    VCS-connected workspaces start runs from webhooks on the linked branch.

  • BThe plan from the pull request is applied at once, without a new plan

    Incorrect

    The merge starts a new run that plans the merged commit on its own.

  • CA run is queued, and its plan waits for an authorized user to confirm

    Correct

    In the VCS workflow, commits to the linked branch queue runs automatically; with manual apply, a user with permission must confirm the plan.

  • DA run is queued for every branch in the repository, including the merged one

    Incorrect

    A workspace follows one branch and ignores changes to others.

VCS-driven: a merge queues a run, and with manual apply an authorized person reviews the plan and confirms it.

Question 2 · choose 1

In which order does a normal HCP Terraform run with policies enabled pass through its main stages?

  1. APlan, pending, apply, policy check
  2. BPending, plan, policy check, apply
  3. CApply, plan, policy check, pending
  4. DPolicy check, pending, plan, apply
Show the answer and why
  • APlan, pending, apply, policy check

    Incorrect

    Runs start pending and are checked before apply.

  • BPending, plan, policy check, apply

    Correct

    Runs pass through the pending and plan stages, then the policy checks and cost estimation when they are enabled, and then apply.

  • CApply, plan, policy check, pending

    Incorrect

    Apply always comes last.

  • DPolicy check, pending, plan, apply

    Incorrect

    Policies check a plan, so they come after planning.

Pending, plan, checks, apply: policies always see a finished plan.

Question 3 · choose 1

Two runs are queued in the same workspace within a minute. What does HCP Terraform do with the second one?

  1. AIt stays pending until earlier runs finish
  2. BIt runs in parallel with the first one
  3. CIt replaces the first run, which is discarded
  4. DIt moves to another workspace that is idle
Show the answer and why
  • AIt stays pending until earlier runs finish

    Correct

    Each workspace processes its runs in the order they were queued; a run remains pending until every earlier run has completed.

  • BIt runs in parallel with the first one

    Incorrect

    Runs in one workspace are processed one after another.

  • CIt replaces the first run, which is discarded

    Incorrect

    Queued runs are not discarded automatically by a new run.

  • DIt moves to another workspace that is idle

    Incorrect

    Runs belong to their workspace.

One workspace, one run at a time, in queue order.

Question 4 · choose 1

A team creates a new VCS-driven workspace and waits, but no run starts. What does the documentation say about the first run?

  1. AIt starts only after the first pull request is merged
  2. BIt starts after terraform login is run on a laptop
  3. CIt must be started manually; commits do the rest
  4. DIt starts once the workspace's state file is uploaded
Show the answer and why
  • AIt starts only after the first pull request is merged

    Incorrect

    A manual first run is required.

  • BIt starts after terraform login is run on a laptop

    Incorrect

    login authenticates the CLI; it does not trigger runs.

  • CIt must be started manually; commits do the rest

    Correct

    You must manually trigger an initial run in any new VCS-driven workspace.

  • DIt starts once the workspace's state file is uploaded

    Incorrect

    A new workspace needs no uploaded state.

Kick off the first run by hand; the webhooks take over after that.

Question 5 · choose 1

After a run in an HCP Terraform workspace, where can the team see what the state looked like before and after, and which run produced it?

  1. AIn the local terraform.tfstate of the person who triggered the run
  2. BOnly in the run's log output
  3. CNowhere; HCP Terraform keeps only the latest state
  4. DIn the workspace's States tab, with every version
Show the answer and why
  • AIn the local terraform.tfstate of the person who triggered the run

    Incorrect

    Remote runs keep state in the workspace.

  • BOnly in the run's log output

    Incorrect

    State versions have their own view.

  • CNowhere; HCP Terraform keeps only the latest state

    Incorrect

    Historical versions are kept.

  • DIn the workspace's States tab, with every version

    Correct

    HCP Terraform stores the current and historical state versions, each linked to its run and commit, with a diff.

State history is part of the workspace, useful for audits and analysis.

Question 6 · choose 1

Where is the Terraform version used by remote runs in an HCP Terraform workspace selected?

  1. AIn the dependency lock file
  2. BIn the provider block
  3. CIn the workspace's settings
  4. DIn the organization's billing page
Show the answer and why
  • AIn the dependency lock file

    Incorrect

    The lock file records provider versions.

  • BIn the provider block

    Incorrect

    Provider blocks configure providers.

  • CIn the workspace's settings

    Correct

    Each workspace's general settings include the Terraform version used for its runs.

  • DIn the organization's billing page

    Incorrect

    Versions are set per workspace.

Each workspace pins its own Terraform version.

Practise domain 8 →Practise all domains →