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 28

Question 270

A training organization is reviewing Terraform student solutions and wants formatting failures separated from semantic configuration mistakes. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Verify: Introduce inconsistent indentation in a test .tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.
  2. Implement: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. Verify: Introduce inconsistent indentation in a test .tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.
  3. Implement: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. 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.
  4. 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.

Answer & Explanations

Correct answer: B

A.

The question is set in this situation: A training organization is reviewing Terraform student solutions and wants formatting failures separated from semantic configuration mistakes. The test would be relevant: Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check. But the offered implementation—Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.—addresses “Format nested module directories consistently without changing intended behavior”. The action needed here is: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style.

B.

The question is set in this situation: A training organization is reviewing Terraform student solutions and wants formatting failures separated from semantic configuration mistakes. Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. Confirm it through this test: Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check. The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory.

C.

The question is set in this situation: A training organization is reviewing Terraform student solutions and wants formatting failures separated from semantic configuration mistakes. The action is applicable: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. But its proposed test—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.—addresses “Format nested module directories consistently without changing intended behavior”. This requirement is confirmed instead by: Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.

D.

This action/test pair addresses “Distinguish terraform validate from a provider-backed execution plan”. Use validate for static configuration checks, then run terraform plan to assess credentials, current state, remote objects and proposed infrastructure effects. Make a valid HCL change that requires replacing a disposable resource and verify validate succeeds while a plan correctly reports replacement. The case instead calls for: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style.

Question 271

A consulting team has multiple internal Terraform modules under one repository and wants consistent formatting across all maintained components. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Initialize providers and backend, validate configuration, inspect a plan and apply only reviewed changes under the appropriate identity.
  2. Reserve terraform apply -auto-approve for tightly controlled automation with prior independent plan approval, identity boundaries and audit records.
  3. Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style.
  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: D

A.

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: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

B.

Reserve terraform apply -auto-approve for tightly controlled automation with prior independent plan approval, identity boundaries and audit records. This addresses “Avoid auto-approval of production changes without policy gates”, where the governing principle is: The flag skips interactive confirmation; it does not validate policy compliance or remove the impact of destructive provider operations. The stated case instead calls for: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

C.

Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. This addresses “Use terraform fmt -check before merging HCL”, where the governing principle is: The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory. The stated case instead calls for: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings. Verify the result with this test: 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.

Question 272

A consulting team has multiple internal Terraform modules under one repository and wants consistent formatting across all maintained components. The infrastructure engineer proposes this change: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Which mechanism explains why it works?

  1. The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory.
  2. Terraform builds an execution plan from configuration, state and remote reality; separating review from apply helps control infrastructure effects.
  3. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.
  4. The flag skips interactive confirmation; it does not validate policy compliance or remove the impact of destructive provider operations.

Answer & Explanations

Correct answer: C

A.

The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory. That explains “Use terraform fmt -check before merging HCL”, not the mechanism behind the described change. The relevant principle is: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

B.

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: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

C.

Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings. The corresponding implementation is: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

The flag skips interactive confirmation; it does not validate policy compliance or remove the impact of destructive provider operations. That explains “Avoid auto-approval of production changes without policy gates”, not the mechanism behind the described change. The relevant principle is: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

Question 273

A consulting team has multiple internal Terraform modules under one repository and wants consistent formatting across all maintained components. After implementing this change—Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.—which test most directly validates its intended outcome?

  1. 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.
  2. Compare a nonproduction apply requiring confirmation with a gated CI apply and verify the gate rather than a prompt protects production changes.
  3. Introduce inconsistent indentation in a test .tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.
  4. In a sandbox, run init, validate, plan and apply with an approved test resource, then confirm an unchanged subsequent plan.

Answer & Explanations

Correct answer: A

A.

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. This check is decisive because recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

B.

Compare a nonproduction apply requiring confirmation with a gated CI apply and verify the gate rather than a prompt protects production changes. That would help test “Avoid auto-approval of production changes without policy gates”, not the outcome required in this scenario. The relevant acceptance check is: 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.

C.

Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check. That would help test “Use terraform fmt -check before merging HCL”, not the outcome required in this scenario. The relevant acceptance check is: 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.

D.

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: 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.

Question 274

A consulting team has multiple internal Terraform modules under one repository and wants consistent formatting across all maintained components. Which proposed shortcut most directly risks unformatted reused modules or false claims that cloud infrastructure has been modified and should therefore be rejected?

  1. Grant broad production privileges to a cron job and run apply -auto-approve for every repository edit with no review or plan evidence.
  2. Treat terraform fmt as a provider-backed deployment validator and skip all other checks after it succeeds.
  3. Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.
  4. Run terraform apply on an unfamiliar production directory before initialization and without reviewing the proposed resource changes.

Answer & Explanations

Correct answer: C

A.

Grant broad production privileges to a cron job and run apply -auto-approve for every repository edit with no review or plan evidence. That shortcut risks unreviewed destructive infrastructure changes applied automatically. Here the specific shortcut is: Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.

B.

Treat terraform fmt as a provider-backed deployment validator and skip all other checks after it succeeds. That shortcut risks invalid or unsafe infrastructure changes masked by a style-only check. Here the specific shortcut is: Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.

C.

Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure. The foreseeable failure is unformatted reused modules or false claims that cloud infrastructure has been modified. The safer response is: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

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: Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.

Question 275

A consulting team has multiple internal Terraform modules under one repository and wants consistent formatting across all maintained components. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Verify: Introduce inconsistent indentation in a test .tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.
  2. 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.
  3. Implement: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. 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.
  4. Implement: Reserve terraform apply -auto-approve for tightly controlled automation with prior independent plan approval, identity boundaries and audit records. Verify: Compare a nonproduction apply requiring confirmation with a gated CI apply and verify the gate rather than a prompt protects production changes.

Answer & Explanations

Correct answer: B

A.

The action is applicable: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. But its proposed test—Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.—addresses “Use terraform fmt -check before merging HCL”. This requirement is confirmed instead by: 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.

B.

Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Confirm it through this test: 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. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

C.

The test would be relevant: 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. But the offered implementation—Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style.—addresses “Use terraform fmt -check before merging HCL”. The action needed here is: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

This action/test pair addresses “Avoid auto-approval of production changes without policy gates”. Reserve terraform apply -auto-approve for tightly controlled automation with prior independent plan approval, identity boundaries and audit records. Compare a nonproduction apply requiring confirmation with a gated CI apply and verify the gate rather than a prompt protects production changes. The case instead calls for: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

Question 276

A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style.
  2. Create an execution plan with terraform plan -out to a protected artifact and apply that exact reviewed plan under the same intended infrastructure context.
  3. Initialize providers and backend, validate configuration, inspect a plan and apply only reviewed changes under the appropriate identity.
  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: D

A.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. This addresses “Use terraform fmt -check before merging HCL”, where the governing principle is: The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory. The stated case instead calls for: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

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. This addresses “Save an execution plan artifact for controlled apply”, where the governing 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. The stated case instead calls for: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

C.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. 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: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings. Verify the result with this test: 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.

Question 277

A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. The infrastructure engineer proposes this change: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Which mechanism explains why it works?

  1. The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory.
  2. Terraform builds an execution plan from configuration, state and remote reality; separating review from apply helps control infrastructure effects.
  3. A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts.
  4. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

Answer & Explanations

Correct answer: D

A.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. The formatter normalizes whitespace and alignment, and the check flag detects differences without modifying the working directory. That explains “Use terraform fmt -check before merging HCL”, not the mechanism behind the described change. The relevant principle is: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

B.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. 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: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

C.

A saved plan fixes the selected actions for approval while still requiring safeguards against stale state and leaked sensitive values in plan artifacts. That explains “Save an execution plan artifact for controlled apply”, not the mechanism behind the described change. The relevant principle is: Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

D.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings. The corresponding implementation is: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

Question 278

A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. After implementing this change—Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.—which test most directly validates its intended outcome?

  1. 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.
  2. 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. Introduce inconsistent indentation in a test .tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.
  4. In a sandbox, run init, validate, plan and apply with an approved test resource, then confirm an unchanged subsequent plan.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. 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. This check is decisive because recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

B.

Generate a protected test plan, review intended creates and deletes, then execute terraform apply with that saved file and verify the resulting object IDs. That would help test “Save an execution plan artifact for controlled apply”, not the outcome required in this scenario. The relevant acceptance check is: 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.

C.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check. That would help test “Use terraform fmt -check before merging HCL”, not the outcome required in this scenario. The relevant acceptance check is: 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.

D.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. 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: 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.

Question 279

A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Which proposed shortcut most directly risks unformatted reused modules or false claims that cloud infrastructure has been modified and should therefore be rejected?

  1. Treat terraform fmt as a provider-backed deployment validator and skip all other checks after it succeeds.
  2. Run terraform apply on an unfamiliar production directory before initialization and without reviewing the proposed resource changes.
  3. Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.
  4. Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits.

Answer & Explanations

Correct answer: C

A.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Treat terraform fmt as a provider-backed deployment validator and skip all other checks after it succeeds. That shortcut risks invalid or unsafe infrastructure changes masked by a style-only check. Here the specific shortcut is: Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.

B.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. 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: Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.

C.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure. The foreseeable failure is unformatted reused modules or false claims that cloud infrastructure has been modified. The safer response is: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

Approve one displayed plan but later run an unrelated unreviewed apply after intervening configuration edits. That shortcut risks production changes that differ from the reviewed execution plan. Here the specific shortcut is: Assume terraform fmt automatically traverses every nested module regardless of flags and that formatting alone updates infrastructure.

Question 280

A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Verify: Introduce inconsistent indentation in a test .tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.
  2. 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.
  3. Implement: Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style. 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.
  4. Implement: Initialize providers and backend, validate configuration, inspect a plan and apply only reviewed changes under the appropriate identity. Verify: In a sandbox, run init, validate, plan and apply with an approved test resource, then confirm an unchanged subsequent plan.

Answer & Explanations

Correct answer: B

A.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. The action is applicable: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. But its proposed test—Introduce inconsistent indentation in a test.tf file, verify fmt -check reports it and a subsequent fmt produces a clean check.—addresses “Use terraform fmt -check before merging HCL”. This requirement is confirmed instead by: 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.

B.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff. Confirm it through this test: 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. Recursive formatting traverses Terraform files in subdirectories; it changes style, not provider resource behavior or actual state bindings.

C.

The question is set in this situation: A university starter kit contains root HCL and nested lesson modules whose whitespace needs normalization before release. The test would be relevant: 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. But the offered implementation—Require terraform fmt -check in CI and apply terraform fmt to the authoring branch when formatting does not match the canonical HCL style.—addresses “Use terraform fmt -check before merging HCL”. The action needed here is: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

D.

This action/test pair addresses “Follow init-plan-apply workflow before changing infrastructure”. Initialize providers and backend, validate configuration, inspect a plan and apply only reviewed changes under the appropriate identity. In a sandbox, run init, validate, plan and apply with an approved test resource, then confirm an unchanged subsequent plan. The case instead calls for: Run terraform fmt -recursive in a reviewed branch when nested module files also need canonical formatting, and inspect the resulting file diff.

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