Certifications / Terraform Associate 004 · Domain 3: Core Terraform workflow · 13% of the exam
terraform plan: refresh, compare, propose; reading create, update, replace and destroy markers, saved plan files with -out, planning modes and options, and the dependency graph behind the order.
Reading a plan: actions, saved plans, exit codes and targeting
Partly covered by: Topological Sort
Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.
Question 1 · choose 1
A plan shows one resource with the symbol -/+ and the note "forces replacement" next to a changed argument. What will apply do to it? A Destroy the object and create a new one, as that argument cannot change in placeB Update the object in place and keep a backup copy of the old object in the stateC Leave the object alone and change only the value recorded in stateD Create a second object next to it and keep bothShow the answer and why A Destroy the object and create a new one, as that argument cannot change in place
Correct
Some arguments cannot be updated in place; Terraform then plans to destroy and re-create the object, shown as a replace action.
B Update the object in place and keep a backup copy of the old object in the state
Incorrect
An in-place update is shown with ~, and Terraform keeps no backup of remote objects.
C Leave the object alone and change only the value recorded in state
Incorrect
That would be a refresh-only change, not a replace action.
D Create a second object next to it and keep both
Incorrect
Replacement ends with one object; the old one is destroyed.
-/+ marks a replacement; ~ marks an update in place.
Question 2 · choose 1
A cautious engineer asks whether running terraform plan against production could change any infrastructure. What is the answer? A Yes; plan applies changes that do not need confirmationB Yes; plan deletes resources that are no longer in the configurationC No; nothing changes until an applyD No, but it locks the infrastructure until an apply runsShow the answer and why A Yes; plan applies changes that do not need confirmation
Incorrect
plan never applies anything.
B Yes; plan deletes resources that are no longer in the configuration
Incorrect
Deletions are proposed in the plan and happen only on apply.
C No; nothing changes until an apply
Correct
A plan without -out is a speculative description of the effect of the changes, with no intent to apply them.
D No, but it locks the infrastructure until an apply runs
Incorrect
Plan may lock state while it runs; it never locks infrastructure afterwards.
Plans are previews. Apply is the only step that changes infrastructure.
Question 3 · choose 1
A plan output shows a data source with the symbol <= and the word read. What does it mean? A Terraform will delete the data source's object in the cloudB The data source is read during apply, as it depends on unknown valuesC The data source's object is being imported into state as a managed resourceD The data source failed and will be retriedShow the answer and why A Terraform will delete the data source's object in the cloud
Incorrect
Data sources never destroy anything.
B The data source is read during apply, as it depends on unknown values
Correct
Data sources are normally read during planning; when their arguments depend on unknown values, the read is deferred to apply and shown in the plan.
C The data source's object is being imported into state as a managed resource
Incorrect
Import is a separate action for managed resources.
D The data source failed and will be retried
Incorrect
A failure would be an error, not a planned action.
Reading is normally a plan-time step; <= read marks the ones that must wait for apply.
Question 4 · choose 1
After saving a plan with -out=changes.tf, every later terraform command in the directory fails with syntax errors. Why? A Plan files must always be named tfplan, with no file extension at allB Saving a plan corrupts the configuration in the same directoryC The plan file must be deleted before the next plan can runD Files ending in .tf are read as configuration, and a plan is notShow the answer and why A Plan files must always be named tfplan, with no file extension at all
Incorrect
tfplan is a convention; any name works except configuration suffixes.
B Saving a plan corrupts the configuration in the same directory
Incorrect
Saving a plan writes only the plan file.
C The plan file must be deleted before the next plan can run
Incorrect
Later plans fail only because of the .tf suffix.
D Files ending in .tf are read as configuration, and a plan is not
Correct
Plan files may have any name, but a .tf suffix makes Terraform try to interpret the file as configuration.
Name plan files with any suffix that is not a configuration suffix, such as tfplan.
Question 5 · choose 1
A team wants a script to inspect a saved plan, for example to flag any deletion of a database. How should the script read the plan? A Open the plan file directly, since it is stored as plain JSONB Run terraform output -json on the plan fileC Run terraform show -json on the plan fileD Run terraform validate -json on the plan fileShow the answer and why A Open the plan file directly, since it is stored as plain JSON
Incorrect
Plan files use an opaque format not meant for direct reading.
B Run terraform output -json on the plan file
Incorrect
output reads output values from state, not plans.
C Run terraform show -json on the plan file
Correct
terraform show -json prints a saved plan as JSON intended for other programs.
D Run terraform validate -json on the plan file
Incorrect
validate checks configuration, not plans.
Saved plans are opaque; show -json is their machine-readable view.
Question 6 · choose 1
In a plan for a new instance, its public IP address appears as (known after apply). What does this mean? A The provider assigns it on creation, so the plan cannot show it yetB The value is sensitive and is hidden until after applyC The plan failed to read the value from the provider, and the apply may fail for the same reasonD The attribute will be removed from the configuration after applyShow the answer and why A The provider assigns it on creation, so the plan cannot show it yet
Correct
Some attributes are computed by the provider during apply; the plan marks them as known after apply.
B The value is sensitive and is hidden until after apply
Incorrect
Hidden sensitive values are shown as (sensitive value).
C The plan failed to read the value from the provider, and the apply may fail for the same reason
Incorrect
Unknown is a normal plan state for computed attributes.
D The attribute will be removed from the configuration after apply
Incorrect
Configuration is never changed by apply.
Computed attributes are unknown until the object exists; references to them are resolved during apply.
Practice domain 3 → Practice all domains →
← Task 3.3 Task 3.5 →