Practice Exams:

HashiCorp Terraform Associate 004 Dumps

EXAM: HashiCorp Certified: Terraform Associate (004)
Verified By Experts
Premium Bundle
$40.00
$59.97 $99.97

Terraform Associate 004 Premium Bundle


  • Premium File 167 Questions & Answers
  • Training Course 118 Lectures
  • Study Guide 285 Pages

HashiCorp Terraform Associate 004 Practice Test 21

Question 200

A hospital cloud platform must demonstrate that syntactic validation alone cannot authorize changes to running clinical test infrastructure. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects. Verify: Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement.
  2. Implement: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Verify: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  3. Implement: Run terraform fmt -check and terraform validate in initialized CI working directories to catch invalid references and malformed configuration before planning. Verify: Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement.
  4. Implement: Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects. Verify: Insert a reference to a nonexistent resource in a sandbox, run validate and confirm the CI job fails before an infrastructure plan is approved.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: A hospital cloud platform must demonstrate that syntactic validation alone cannot authorize changes to running clinical test infrastructure. Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects. Confirm it through this test: Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement. Validate generally does not assess actual provider-backed change impact; only planning against the chosen backend and provider can reveal replace or destroy actions.

B.

This action/test pair addresses “Save an execution plan artifact for controlled apply”. Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. The case instead calls for: Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects.

C.

The question is set in this situation: A hospital cloud platform must demonstrate that syntactic validation alone cannot authorize changes to running clinical test infrastructure. The test would be relevant: Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement. But the offered implementation—Run terraform fmt -check and terraform validate in initialized CI working directories to catch invalid references and malformed configuration before planning.—addresses “Use terraform validate to check configuration structure”. The action needed here is: Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects.

D.

The question is set in this situation: A hospital cloud platform must demonstrate that syntactic validation alone cannot authorize changes to running clinical test infrastructure. The action is applicable: Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects. But its proposed test—Insert a reference to a nonexistent resource in a sandbox, run validate and confirm the CI job fails before an infrastructure plan is approved.—addresses “Use terraform validate to check configuration structure”. This requirement is confirmed instead by: Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement.

Question 201

A regulated payments team requires a reviewed plan artifact linked to the exact release commit before any infrastructure modification. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors.
  2. Initialize providers and backend, validate configuration, inspect a plan and apply only reviewed changes under the appropriate identity.
  3. Run terraform plan -destroy or a reviewed terraform destroy in the exact disposable environment and confirm all listed objects are safe to remove.
  4. Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

Answer & Explanations

Correct answer: D

A.

Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors. This addresses “Interpret terraform plan -detailed-exitcode in CI carefully”, where the governing principle is: The detailed exit status separates changed infrastructure from command failure, letting CI enforce review without confusing drift with a failed command. The stated case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

B.

Initialize providers and backend, validate configuration, inspect a plan and apply only reviewed changes under the appropriate identity. This addresses “Follow init-plan-apply workflow before changing infrastructure”, where the governing principle is: Terraform builds an execution plan from configuration, state and remote reality; separating review from apply helps control infrastructure effects. The stated case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

C.

Run terraform plan -destroy or a reviewed terraform destroy in the exact disposable environment and confirm all listed objects are safe to remove. This addresses “Use terraform destroy only after reviewing the removal plan”, where the governing principle is: Destroy asks providers to delete managed resources in the selected state, including dependencies; it can permanently remove data if safeguards are absent. The stated case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

D.

Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts. Verify the result with this test: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

Question 202

A regulated payments team requires a reviewed plan artifact linked to the exact release commit before any infrastructure modification. The infrastructure engineer proposes this change: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Which mechanism explains why it works?

  1. Terraform builds an execution plan from configuration, state and remote reality; separating review from apply helps control infrastructure effects.
  2. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.
  3. The detailed exit status separates changed infrastructure from command failure, letting CI enforce review without confusing drift with a failed command.
  4. Destroy asks providers to delete managed resources in the selected state, including dependencies; it can permanently remove data if safeguards are absent.

Answer & Explanations

Correct answer: B

A.

Terraform builds an execution plan from configuration, state and remote reality; separating review from apply helps control infrastructure effects. That explains “Follow init-plan-apply workflow before changing infrastructure”, not the mechanism behind the described change. The relevant principle is: A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

B.

A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts. The corresponding implementation is: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

C.

The detailed exit status separates changed infrastructure from command failure, letting CI enforce review without confusing drift with a failed command. That explains “Interpret terraform plan -detailed-exitcode in CI carefully”, not the mechanism behind the described change. The relevant principle is: A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

D.

Destroy asks providers to delete managed resources in the selected state, including dependencies; it can permanently remove data if safeguards are absent. That explains “Use terraform destroy only after reviewing the removal plan”, not the mechanism behind the described change. The relevant principle is: A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

Question 203

A regulated payments team requires a reviewed plan artifact linked to the exact release commit before any infrastructure modification. After implementing this change—Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.—which test most directly validates its intended outcome?

  1. Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  2. Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes.
  3. In a sandbox, run init, validate, plan and apply with an approved test resource, then confirm an unchanged subsequent plan.
  4. Create a small isolated test stack, inspect the destroy plan, perform removal and verify the remote objects and state addresses are gone.

Answer & Explanations

Correct answer: A

A.

Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. This check is decisive because a saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

B.

Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes. That would help test “Interpret terraform plan -detailed-exitcode in CI carefully”, not the outcome required in this scenario. The relevant acceptance check is: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

C.

In a sandbox, run init, validate, plan and apply with an approved test resource, then confirm an unchanged subsequent plan. That would help test “Follow init-plan-apply workflow before changing infrastructure”, not the outcome required in this scenario. The relevant acceptance check is: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

D.

Create a small isolated test stack, inspect the destroy plan, perform removal and verify the remote objects and state addresses are gone. That would help test “Use terraform destroy only after reviewing the removal plan”, not the outcome required in this scenario. The relevant acceptance check is: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

Question 204

A regulated payments team requires a reviewed plan artifact linked to the exact release commit before any infrastructure modification. Which proposed shortcut most directly risks production changes that differ from the reviewed execution plan and should therefore be rejected?

  1. Run terraform apply on an unfamiliar production directory before initialization and without reviewing the proposed resource changes.
  2. Run terraform destroy in a shared production backend assuming it deletes only temporary resources from the current terminal session.
  3. Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.
  4. Treat exit code two as a plan crash and silently suppress a real changed-infrastructure review.

Answer & Explanations

Correct answer: C

A.

Run terraform apply on an unfamiliar production directory before initialization and without reviewing the proposed resource changes. That shortcut risks unintended production changes from skipping baseline validation and change review. Here the specific shortcut is: Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

B.

Run terraform destroy in a shared production backend assuming it deletes only temporary resources from the current terminal session. That shortcut risks permanent loss of unrelated managed infrastructure or stored data. Here the specific shortcut is: Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

C.

Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits. The foreseeable failure is production changes that differ from the reviewed execution plan. The safer response is: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

D.

Treat exit code two as a plan crash and silently suppress a real changed-infrastructure review. That shortcut risks invalid infrastructure approvals or missed change alerts caused by misinterpreted CI statuses. Here the specific shortcut is: Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

Question 205

A regulated payments team requires a reviewed plan artifact linked to the exact release commit before any infrastructure modification. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors. Verify: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  2. Implement: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Verify: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  3. Implement: Run terraform plan -destroy or a reviewed terraform destroy in the exact disposable environment and confirm all listed objects are safe to remove. Verify: Create a small isolated test stack, inspect the destroy plan, perform removal and verify the remote objects and state addresses are gone.
  4. Implement: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Verify: Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes.

Answer & Explanations

Correct answer: B

A.

The test would be relevant: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. But the offered implementation—Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors.—addresses “Interpret terraform plan -detailed-exitcode in CI carefully”. The action needed here is: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

B.

Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Confirm it through this test: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

C.

This action/test pair addresses “Use terraform destroy only after reviewing the removal plan”. Run terraform plan -destroy or a reviewed terraform destroy in the exact disposable environment and confirm all listed objects are safe to remove. Create a small isolated test stack, inspect the destroy plan, perform removal and verify the remote objects and state addresses are gone. The case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

D.

The action is applicable: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. But its proposed test—Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes.—addresses “Interpret terraform plan -detailed-exitcode in CI carefully”. This requirement is confirmed instead by: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

Question 206

An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors.
  2. Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects.
  3. Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.
  4. Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

Answer & Explanations

Correct answer: C

A.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors. This addresses “Interpret terraform plan -detailed-exitcode in CI carefully”, where the governing principle is: The detailed exit status separates changed infrastructure from command failure, letting CI enforce review without confusing drift with a failed command. The stated case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

B.

Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects. This addresses “Distinguish terraform validate from a provider-backed execution plan”, where the governing principle is: Validate generally does not assess actual provider-backed change impact; only planning against the chosen backend and provider can reveal replace or destroy actions. The stated case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

C.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts. Verify the result with this test: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

D.

Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. This addresses “Format nested module directories consistently without changing intended behavior”, where the governing principle is: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings. The stated case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

Question 207

An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. The infrastructure engineer proposes this change: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Which mechanism explains why it works?

  1. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.
  2. Validate generally does not assess actual provider-backed change impact; only planning against the chosen backend and provider can reveal replace or destroy actions.
  3. The detailed exit status separates changed infrastructure from command failure, letting CI enforce review without confusing drift with a failed command.
  4. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

Answer & Explanations

Correct answer: D

A.

Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings. That explains “Format nested module directories consistently without changing intended behavior”, not the mechanism behind the described change. The relevant principle is: A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

B.

Validate generally does not assess actual provider-backed change impact; only planning against the chosen backend and provider can reveal replace or destroy actions. That explains “Distinguish terraform validate from a provider-backed execution plan”, not the mechanism behind the described change. The relevant principle is: A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

C.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. The detailed exit status separates changed infrastructure from command failure, letting CI enforce review without confusing drift with a failed command. That explains “Interpret terraform plan -detailed-exitcode in CI carefully”, not the mechanism behind the described change. The relevant principle is: A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

D.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts. The corresponding implementation is: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

Question 208

An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. After implementing this change—Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.—which test most directly validates its intended outcome?

  1. Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  2. Create a fixture with inconsistent nested .tf files, run recursive fmt and compare before and after to confirm only formatting and no remote objects changed.
  3. Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement.
  4. Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. This check is decisive because a saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

B.

Create a fixture with inconsistent nested.tf files, run recursive fmt and compare before and after to confirm only formatting and no remote objects changed. That would help test “Format nested module directories consistently without changing intended behavior”, not the outcome required in this scenario. The relevant acceptance check is: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

C.

Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement. That would help test “Distinguish terraform validate from a provider-backed execution plan”, not the outcome required in this scenario. The relevant acceptance check is: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

D.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes. That would help test “Interpret terraform plan -detailed-exitcode in CI carefully”, not the outcome required in this scenario. The relevant acceptance check is: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

Question 209

An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Which proposed shortcut most directly risks production changes that differ from the reviewed execution plan and should therefore be rejected?

  1. Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.
  2. Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.
  3. Treat exit code two as a plan crash and silently suppress a real changed-infrastructure review.
  4. Approve a production resource rename solely because terraform validate succeeds, without looking at the proposed destroy or create operations.

Answer & Explanations

Correct answer: B

A.

Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure. That shortcut risks unformatted reused modules or false claims that cloud infrastructure has been modified. Here the specific shortcut is: Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

B.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits. The foreseeable failure is production changes that differ from the reviewed execution plan. The safer response is: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

C.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Treat exit code two as a plan crash and silently suppress a real changed-infrastructure review. That shortcut risks invalid infrastructure approvals or missed change alerts caused by misinterpreted CI statuses. Here the specific shortcut is: Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

D.

Approve a production resource rename solely because terraform validate succeeds, without looking at the proposed destroy or create operations. That shortcut risks unreviewed replacements or authorization failures hidden by successful static validation. Here the specific shortcut is: Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

Question 210

An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Verify: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  2. Implement: Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors. Verify: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.
  3. Implement: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Verify: Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes.
  4. Implement: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Verify: Create a fixture with inconsistent nested .tf files, run recursive fmt and compare before and after to confirm only formatting and no remote objects changed.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. Confirm it through this test: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.

B.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. The test would be relevant: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. But the offered implementation—Run terraform plan -detailed-exitcode and distinguish exit code zero for no diff, two for proposed changes, and one for execution errors.—addresses “Interpret terraform plan -detailed-exitcode in CI carefully”. The action needed here is: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

C.

The question is set in this situation: An online publisher wants to confirm the plan reviewed by its networking team is the one later executed by CI. The action is applicable: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context. But its proposed test—Test a no-op configuration, a safe tagged change and a deliberately invalid credential, recording the separate Terraform exit codes.—addresses “Interpret terraform plan -detailed-exitcode in CI carefully”. This requirement is confirmed instead by: Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs.

D.

This action/test pair addresses “Format nested module directories consistently without changing intended behavior”. Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Create a fixture with inconsistent nested.tf files, run recursive fmt and compare before and after to confirm only formatting and no remote objects changed. The case instead calls for: Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.

HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests