SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
Terraform 004 · Domain 3

Core Terraform workflow practice questions

Core Terraform workflow is worth 19% of the Terraform 004 exam — the 2nd-heaviest of the 8 domains. The write → init → plan → apply → destroy workflow, plus formatting. Weight approximates the sub-objective share. 6 fully worked examples are further down this page, answers included.

Exam weight
19%
the 2nd-heaviest of the 8 domains
Questions
76
across 2 topics
Free, no account
5/day
a free account allows 10 a day
Explanations
Every option
right and wrong

Build a practice session

5 free questions left today.

Domains

How many?

5 free questions left today.

Mode

Ready when you are

10 fresh questions drawn across 1 of 8 domains, in Learn mode.

Review what you missed

Every question you answer incorrectly, and every question you flag while practising, is saved here automatically. Finish a session and you can come back to re-drill just those.

6 sample Core Terraform workflow questions, fully explained

Questions from the Terraform 004 bank mapped to domain 3, with the answer key and the reasoning behind every option. None of them repeat the examples on the main Terraform 004 practice page.

Question 1Core Terraform workflow

A developer wants a pre-commit check that catches a misspelled resource argument and a reference to an undeclared variable. The check must run in seconds and must not need cloud credentials or access to state. Which command fits?

Choose one.

  • a
    terraform validate Correct

    validate checks syntax and internal consistency against the provider schemas - unknown argument names and undeclared references are exactly what it reports - and it makes no remote calls, so no credentials or state are needed.

  • b
    terraform fmt -check

    fmt -check only reports files that are not in canonical style. A misspelled argument or an undeclared variable reference is perfectly formattable, so it passes.

  • c
    terraform plan -refresh=false

    Skipping refresh avoids reading real resources, but plan still configures the providers and reads state through the backend, so it needs credentials and state access - and it is slower.

  • d
    terraform console

    console evaluates expressions interactively against the configuration and state; it is not a check of the whole configuration and it loads state, breaking the no-state requirement.

The concept

terraform validate is a static check of the configuration in the working directory. It verifies syntax and internal consistency - valid block structure, known argument names, resolvable references and matching types - using the provider schemas installed by init, and it never contacts a remote service.

Why that’s the answer

Both errors in the scenario are configuration-consistency problems, which is precisely validate's scope, and the constraints (fast, no credentials, no state) rule out plan, which configures providers and reads state even with -refresh=false. fmt -check is the tempting near-twin because it is also a fast CI gate, but it checks style only; console evaluates single expressions against state rather than checking the configuration.

How to reason it out
  1. Identify the kind of error: a misspelled argument and an undeclared reference are consistency errors, not style or infrastructure errors.
  2. Apply the constraints: no credentials and no state access rule out plan and console.
  3. Separate style from correctness: fmt checks layout, validate checks correctness.
  4. Choose terraform validate (after init has installed the provider schemas).

Exam tip: validate = offline correctness check (names, references, types); fmt = style; plan = needs providers and state.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

Question 2Core Terraform workflow

Why is it safe to run terraform plan against a workspace that manages production infrastructure?

Choose one.

  • a
    It applies the changes, then rolls them back once the diff is shown

    plan never applies anything, so there is nothing to roll back. Terraform also has no automatic rollback mechanism at all.

  • b
    It locks the real resources so no one can change them while it runs

    Terraform can lock the state file during an operation, but it never locks real infrastructure, and that is not what makes plan safe.

  • c
    It works fully offline, using just the configuration and state file

    plan reads state and, by default, refreshes it by querying provider APIs. It is read-only toward infrastructure, not offline.

  • d
    It reads state and provider APIs to build a preview, but changes nothing Correct

    plan computes the difference between configuration and state and prints the proposed actions. Nothing is created, changed, or destroyed until apply.

The concept

terraform plan is the preview step of the core workflow. It refreshes its in-memory view of state, compares the desired configuration with the recorded state, and prints the set of create, update, and destroy actions that an apply would perform.

Why that’s the answer

The safety of plan comes from being read-only with respect to infrastructure: it may query provider APIs to read current attributes, but it never issues create, update, or delete calls. That lets teams run plan freely against production to review pending changes. It is not offline (it reads state and providers), it does not lock infrastructure, and it certainly does not apply-then-rollback.

How to reason it out
  1. Edit the configuration to describe the desired infrastructure.
  2. Run terraform plan and read the proposed actions carefully.
  3. Only after review, run terraform apply to execute the changes.

Exam tip: plan is a read-only preview - it can query providers but never changes infrastructure.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

Question 3Core Terraform workflow

In terraform plan output, a resource is prefixed with the ~ symbol. What does this indicate?

Choose one.

  • a
    The resource will be updated in place Correct

    The tilde marks an in-place update: Terraform will change one or more arguments on the existing object without destroying it.

  • b
    The resource will be destroyed and recreated

    Destroy-and-recreate (replacement) is shown with -/+ (or +/- with create_before_destroy), not a plain tilde.

  • c
    The resource will be destroyed

    A pure destroy is marked with a - prefix.

  • d
    The resource is new and will be created

    Creation is marked with a + prefix.

The concept

Plan output uses action symbols: + for create, - for destroy, ~ for update in place, and -/+ for replace (destroy then create). Reading these symbols correctly is essential to reviewing a plan before approving it.

Why that’s the answer

The ~ prefix specifically means Terraform can achieve the desired change by modifying the existing remote object - for example changing a tag or an instance's monitoring setting - so the object keeps its identity. This is very different from -/+, which means the change forces replacement and the object will be destroyed and recreated, potentially causing downtime or data loss. Distinguishing the two is a key review skill.

How to reason it out
  1. Run terraform plan after editing configuration.
  2. Scan the action symbols: + create, ~ update in place, - destroy, -/+ replace.
  3. Pay special attention to -/+ lines and the 'forces replacement' annotations before applying.

Exam tip: ~ means update in place; -/+ means destroy and recreate.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

Question 4Core Terraform workflow

You change the ami argument of an aws_instance resource and run terraform plan. The instance is listed with the -/+ prefix. What will happen to the instance when you apply this plan?

Choose one.

  • a
    The running instance switches to the new AMI in place, without a reboot

    An in-place change would be shown with ~. The -/+ prefix means the provider cannot update this argument on the existing object.

  • b
    The instance is destroyed, then a new one is created from the new AMI Correct

    -/+ is the replacement action: the AMI cannot change on an existing instance, so Terraform destroys the old object and then creates a new one.

  • c
    A new instance is created first, then the old one is destroyed

    Create-then-destroy is the create_before_destroy ordering, shown as +/-. The -/+ prefix is the default order: destroy the old object first, then create the new one.

  • d
    The ami value in state is updated, but the running instance is unchanged

    Updating only recorded values is what a refresh-only run does. A -/+ plan performs real destroy and create operations.

The concept

Some resource arguments are immutable at the provider API level. When such an argument changes, Terraform plans a replacement: destroy the existing object, then create a new one. Plan output marks this with -/+ and annotates the specific argument with 'forces replacement'.

Why that’s the answer

An EC2 instance's AMI cannot be changed on a running instance, so the AWS provider declares ami as a replacement-forcing argument. On apply, Terraform will destroy the current instance and create a replacement booted from the new AMI. Reviewers must catch this in the plan because replacement can mean downtime and loss of instance-local data - which is exactly why plan surfaces the reason next to the changed argument.

How to reason it out
  1. Read the prefix: + create, ~ update in place, - destroy, -/+ replace.
  2. Find the argument annotated as forcing replacement to see what triggered it (here ami).
  3. Decide whether replacement is acceptable (or mitigate with lifecycle settings) before running apply.

Exam tip: -/+ in a plan means apply will destroy and recreate the resource, not update it.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

Question 5Core Terraform workflow

A working directory was initialized weeks ago and has been used for many plans. You add a random_pet resource, which is the first use of the hashicorp/random provider in this configuration. terraform plan now fails saying the provider is not installed. What should you do?

Choose one.

  • a
    Run terraform get first, then run terraform plan again

    terraform get downloads and updates modules only. It never installs provider plugins, so plan would still fail.

  • b
    Run terraform validate first, then run terraform plan again

    validate checks the configuration; it cannot install provider plugins and would itself fail on the missing provider schema.

  • c
    Run terraform providers lock first, then run terraform plan again

    providers lock adds provider selections and checksums to .terraform.lock.hcl without installing the plugins, so the working directory still lacks the provider.

  • d
    Run terraform init first, then run terraform plan again Correct

    init must be re-run whenever the configuration starts requiring a provider (or module, or backend change) that the working directory does not yet have installed.

The concept

terraform init is not a one-time command. It must be re-run whenever the working directory's dependencies change: a new provider is required, a new module is added or a module source changes, or the backend configuration changes.

Why that’s the answer

Adding random_pet makes the configuration depend on the hashicorp/random provider, which was never downloaded during the original init. Re-running terraform init resolves the new requirement, installs the plugin and updates the dependency lock file. The near-twins are tempting because they also deal with dependencies: terraform get handles modules only, and terraform providers lock writes lock-file entries without installing anything. validate installs nothing either.

How to reason it out
  1. Add the new resource and, ideally, declare the provider in required_providers.
  2. Run terraform init; it downloads only what is newly required.
  3. Commit the updated .terraform.lock.hcl and re-run terraform plan.

Exam tip: Re-run terraform init any time you add a provider, add or change a module, or change the backend.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

Question 6Core Terraform workflow

required_providers allows aws "~> 5.0" and the committed lock file records 5.31.0. A bug fix you need ships in 5.40.0, and every teammate and the CI pipeline must end up on that release with the same checksums. What should you do?

Choose one.

  • a
    Change the constraint to "~> 5.40", run terraform init, commit the lock file

    Plain init does not re-select a locked provider. With 5.31.0 locked and the constraint now "~> 5.40", init stops with an error that the locked version does not match the constraint and tells you to use -upgrade.

  • b
    Run terraform init -upgrade, then commit the rewritten .terraform.lock.hcl file Correct

    -upgrade ignores the locked selection, picks the newest release the constraint allows and rewrites the lock file; committing that file gives everyone the same version and checksums.

  • c
    Run terraform init on your machine, then commit the .terraform.lock.hcl file

    Plain init honours the existing lock file and reinstalls 5.31.0 even though newer 5.x releases satisfy "~> 5.0", so the committed lock file still pins the old version.

  • d
    Run terraform get -update, then commit the .terraform.lock.hcl file again

    get -update re-fetches modules only; it never changes provider selections or the lock file.

The concept

The dependency lock file pins the exact provider version and checksums. Plain terraform init always re-selects the locked version; terraform init -upgrade discards the lock pins, re-resolves to the newest versions the constraints allow, and rewrites the lock file, which you then commit.

Why that’s the answer

Two facts decide this. First, the lock file wins over newer releases: plain init keeps installing 5.31.0, so committing the lock file after plain init changes nothing. Second, tightening the constraint is not a way around the lock: when the locked version no longer satisfies the constraint, init fails and asks for -upgrade. init -upgrade re-selects the newest allowed release and rewrites .terraform.lock.hcl; committing that file is what puts teammates and CI on the same version with the same checksums. (If an exact 5.40.0 is required rather than the newest 5.x, combine a tighter constraint with -upgrade.) get -update acts on modules only.

How to reason it out
  1. Recall that plain init reuses the version recorded in the lock file.
  2. Recall that a constraint the locked version no longer meets makes init fail until -upgrade is used.
  3. Run terraform init -upgrade to re-resolve and rewrite the lock file.
  4. Commit .terraform.lock.hcl so every clone installs the same release and checksums.

Exam tip: Moving a locked provider forward always takes terraform init -upgrade plus a commit of the lock file.

Terraform init, validate, and plan: the core workflow explained — the lesson that teaches this.

What Terraform 004 domain 3 tests, topic by topic

The official exam guide breaks Core Terraform workflow into 2 topics. The question bank follows the same split, so a weak topic shows up as a cluster of misses you can go back and read.

Published Terraform 004 practice questions per topic in Core Terraform workflow
TopicWhat it coversQuestions
The core workflow: init, validate, and planOfficial Terraform Associate 004 objective 3 (part 1). Describing the Terraform workflow; initializing a working directory; validating a configuration; generating and reviewing an execution plan.38
Applying, destroying, and formatting configurationOfficial Terraform Associate 004 objective 3 (part 2). Applying changes to infrastructure; destroying Terraform-managed infrastructure; applying formatting and style adjustments to a configuration.38
Total76

Revise Core Terraform workflow before you drill it

Other Terraform 004 domains

Core Terraform workflow: your questions

Core Terraform workflow is domain 3 of the Terraform 004 exam guide and carries 19% of the scored content — the 2nd-heaviest of the 8 domains. On a 57-question paper that works out to roughly 11 questions, though HashiCorp does not publish an exact per-domain count and individual exam forms vary.

Source

The domain weight and topic list on this page come from the official Terraform 004 exam guide.