Question 280
A Terraform associate evaluates: A build system needs a deterministic formatting gate before deeper testing. Select TWO complementary responses: the appropriate action AND direct evidence it worked.
Explanation
Correct Answers
The observed situation is: A build system needs a deterministic formatting gate before deeper testing. The acceptance evidence is: A deliberately unformatted file makes the check fail and a formatted file passes without modification. It verifies the corrective approach (Use terraform fmt -check (optionally -recursive) to fail CI on noncanonical formatting without changing committed files.) and controls the risk: Automatically rewriting formatting during a read-only CI check can produce untracked repository changes. Checking an unrelated Terraform setting would not prove the stated requirement was met.
The case says: A build system needs a deterministic formatting gate before deeper testing. The directly relevant Terraform response is: Use terraform fmt -check (optionally -recursive) to fail CI on noncanonical formatting without changing committed files. This addresses the related failure mode: Automatically rewriting formatting during a read-only CI check can produce untracked repository changes. Validate the result by checking: A deliberately unformatted file makes the check fail and a formatted file passes without modification. The selection matches this objective, rather than a different Terraform administration task.
Incorrect Answers
A subsequent validate succeeds with the intended resource names and provider schema. That addresses Detect invalid references and values (official objective 3c), specifically the hazard that a typo in a resource reference or invalid argument can prevent Terraform from constructing a valid graph. Here the necessary action or evidence is the paired action A deliberately unformatted file makes the check fail and a formatted file passes without modification and separate validation Use terraform fmt -check (optionally -recursive) to fail CI on noncanonical formatting without changing committed files, not that separate control.
Running destroy in the wrong selected workspace can remove live resources rather than the intended test stack. This addresses Destroy scope and workspace safety (official objective 3f). The separate hazard is that running destroy in the wrong selected workspace can remove live resources rather than the intended test stack. It does not by itself satisfy the case-specific requirement for Formatting check in CI.
Run terraform fmt to apply canonical HCL layout without assuming it checks provider resource correctness. This does not provide the required Formatting check in CI action-and-evidence pair.