Question 190
A reviewer has to approve a two-part design: distinguish clean plans from plans with proposed changes in CI; additionally, load an explicit environment input file. Which option pairs the correct mechanisms?
- Use
terraform plan -detailed-exitcode + Use terraform show tfplan
- Use
terraform show -json tfplan + Run terraform plan without applying
- Use
terraform plan -detailed-exitcode + Use terraform plan -var-file=env.tfvars
- Use
terraform plan -out=tfplan + Use terraform plan -var-file=env.tfvars
Explanation
Correct Answer
C:For the first criterion, the option uses exit code 0 for no differences, 2 for differences, and 1 for errors; a nonzero value is not always an execution failure; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file; this directly addresses the need to distinguish clean plans from plans with proposed changes in CI. For the separate second criterion, an explicitly selected tfvars file feeds input values into that run; a .tfvars file is not a provider dependency lock; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file; this fulfills the need to load an explicit environment input file. Together they cover the independent tasks of distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure meets the requirement to distinguish clean plans from plans with proposed changes in CI, but its partner serves a different role: Show decodes the saved plan for review; it does not run the provider operations represented by the plan; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. That second component is designed to render a saved execution plan in readable form, so the still-missing criterion is to load an explicit environment input file, while the first criterion remains distinguish clean plans from plans with proposed changes in CI.
B:The first measure is intended to export machine-readable plan details for a policy tool: JSON output exposes structured planned values and actions; the output can contain sensitive values even when terminal formatting hides them; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. The second measure is intended to preview the actions needed to reconcile the declared configuration: Plan evaluates dependencies and current state and reports create/update/replace/delete intentions; it normally performs no desired resource changes; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. Neither is the directly designated method for the separate goals of distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file in this review.
D:The second measure does meet the load an explicit environment input file requirement, but the first is designed for another concern: A saved plan captures selections and inputs for later use; it may include secrets and backend settings, so the artifact requires access controls; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. That first component is designed to save a plan for later explicit approval and application, which does not accomplish the requested task to distinguish clean plans from plans with proposed changes in CI, even though the other measure satisfies load an explicit environment input file.
Question 191
A Terraform rollout has separate acceptance criteria: skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply. Which combined approach directly satisfies the two criteria?
- Run
terraform apply to execute current configuration + Check apply output for partial failure
- Run
terraform apply tfplan for an approved saved plan + Use terraform apply -var-file=prod.tfvars
- Use
terraform apply -auto-approve for controlled automation + Use terraform apply -var-file=prod.tfvars
- Use
terraform apply -auto-approve for controlled automation + Use terraform apply -input=false in unattended execution
Explanation
Correct Answer
C:For the first criterion, the option removes the manual confirmation stage; it is not an alternative to reviewing changes, securing credentials, or verifying policies; this behavior should be assessed against the concrete need to skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply; this directly addresses the need to skip the interactive approval prompt when the pipeline already has gates. For the separate second criterion, variable files set input variables for that run; their contents do not overwrite provider schemas or module source code; this behavior should be assessed against the concrete need to skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply; this fulfills the need to supply planned environment-specific input values in a direct apply. Together they cover the independent tasks of skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure is intended to generate and carry out the necessary actions for managed infrastructure: Without a saved plan argument, apply creates a plan and normally requests approval before performing it; provider APIs then implement the proposed operations; this behavior should be assessed against the concrete need to skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply. The second measure is intended to understand why an unsuccessful apply may still have changed some resources: Terraform may have completed earlier provider operations before a later step fails; state can record successful actions, so investigate the next plan rather than assuming a full rollback; this behavior should be assessed against the concrete need to skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply. Neither is the directly designated method for the separate goals of skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply in this review.
B:The second measure does meet the supply planned environment-specific input values in a direct apply requirement, but the first is designed for another concern: Applying a saved plan uses its captured decisions and state assumptions; a changed state can invalidate it instead of silently applying a different plan; this behavior should be assessed against the concrete need to skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply. That first component is designed to execute the exact plan artifact rather than replan with new input values, which does not accomplish the requested task to skip the interactive approval prompt when the pipeline already has gates, even though the other measure satisfies supply planned environment-specific input values in a direct apply.
D:The first measure meets the requirement to skip the interactive approval prompt when the pipeline already has gates, but its partner serves a different role: The run fails if required input cannot be obtained in noninteractive mode; this avoids jobs hanging on missing variables; this behavior should be assessed against the concrete need to skip the interactive approval prompt when the pipeline already has gates and supply planned environment-specific input values in a direct apply. That second component is designed to prevent the run from waiting for interactive variable input, so the still-missing criterion is to supply planned environment-specific input values in a direct apply, while the first criterion remains skip the interactive approval prompt when the pipeline already has gates.
Question 192
An engineer needs to avoid deleting resources belonging to a different environment as part of a planned migration. Which option is the best fit?
- Use
terraform destroy -target=ADDRESS cautiously
- Check the selected workspace before destroying
- Remove a resource from state without destroying it
- Use
terraform plan -destroy for teardown review
Explanation
Correct Answer
B:Terraform operates on the selected state and current configuration; similar resource names in separate states can refer to entirely different real objects; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment. This directly supports the task to avoid deleting resources belonging to a different environment during a maintenance request.
Incorrect Answers
A:Targeting is intended for exceptional recovery, not routine architecture management; the rest of the state can remain dependent on objects that were removed; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment. It may support a related workflow, but the question specifically requires the mechanism for avoid deleting resources belonging to a different environment rather than limit a teardown to a selected resource or dependency subset.
C:terraform state rm or a supported removed block can forget an object; it is different from instructing a provider to delete infrastructure; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment. That can be useful when the aim is to stop Terraform management while leaving a real object intact, but it does not directly deliver the requested ability to avoid deleting resources belonging to a different environment.
D:A destroy plan lists what would be removed and can be saved for approval; it is appropriate before potentially disruptive cleanup; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment. The distinction matters here: using that mechanism to preview the deletions without executing them would still leave the objective to avoid deleting resources belonging to a different environment unmet.
Question 193
A repository maintainer wants to normalize HCL without changing infrastructure. Two independent changes are requested: first, detect files whose formatting differs from Terraform conventions; second, display the textual adjustments a formatter would make. Which pair of measures fulfills both?
- Run
terraform fmt -check in CI + Run terraform fmt -diff
- Run
terraform fmt -check in CI + Apply style checks to module directories
- Separate
fmt from provider installation + Run terraform fmt -diff
- Run
terraform fmt -recursive + Use standard indentation and alignment from fmt
Explanation
Correct Answer
A:For the first criterion, check mode reports whether formatting changes are needed and can fail a pipeline; it does not itself rewrite source files; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make; this directly addresses the need to detect files whose formatting differs from Terraform conventions. For the separate second criterion, diff mode shows the before-and-after formatting changes; it cannot indicate whether a proposed resource change is safe; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make; this fulfills the need to display the textual adjustments a formatter would make. Together they cover the independent tasks of detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make without exchanging the responsibilities of these features.
Incorrect Answers
B:The first measure meets the requirement to detect files whose formatting differs from Terraform conventions, but its partner serves a different role: Module source code is Terraform configuration and can be formatted with the same tool; formatting never pins which module release is used; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make. That second component is designed to enforce a consistent codebase without changing module behavior, so the still-missing criterion is to display the textual adjustments a formatter would make, while the first criterion remains detect files whose formatting differs from Terraform conventions.
C:The second measure does meet the display the textual adjustments a formatter would make requirement, but the first is designed for another concern: Formatting reads local HCL and does not initialize backends or download provider packages; dependency preparation remains the role of init; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make. That first component is designed to avoid expecting style normalization to fetch plugin binaries, which does not accomplish the requested task to detect files whose formatting differs from Terraform conventions, even though the other measure satisfies display the textual adjustments a formatter would make.
D:The first measure is intended to format Terraform configurations in nested directories: Recursive mode traverses child directories rather than just the current location; it is useful in repositories containing multiple roots and modules; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make. The second measure is intended to reduce noisy diff conflicts across contributors: Canonical layout gives team members predictable formatting; hand-crafted alignment rules are not necessary to make Terraform parse HCL correctly; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make. Neither is the directly designated method for the separate goals of detect files whose formatting differs from Terraform conventions and display the textual adjustments a formatter would make in this review.
Question 194
A delivery pipeline is being designed around Terraform stages. The requirement is to reduce risk by verifying syntax and policy before deploying. Which Terraform mechanism directly meets this requirement?
- Use version control alongside the workflow
- Put automated tests before apply approvals
- Keep environment state separated
- Apply reviewed changes with
terraform apply
Explanation
Correct Answer
B:Formatting, validation, and policy checks can gate promotion; they do not guarantee real cloud capacity or authorization at execution time; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying. This directly supports the task to reduce risk by verifying syntax and policy before deploying during a planned migration.
Incorrect Answers
A:Git captures code changes and supports peer review; Terraform state and provider API results remain separate operational concerns; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying. That can be useful when the aim is to make infrastructure edits traceable and reviewable, but it does not directly deliver the requested ability to reduce risk by verifying syntax and policy before deploying.
C:Multiple root working directories or CLI workspaces can carry different states; the isolation of state prevents Terraform from treating two environments as one inventory; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying. It may support a related workflow, but the question specifically requires the mechanism for reduce risk by verifying syntax and policy before deploying rather than ensure independent deployments do not accidentally share object bindings.
D:Apply coordinates provider operations and updates state after effects are known; it needs valid authentication and can still fail if the API rejects an operation; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying. The stated requirement is to reduce risk by verifying syntax and policy before deploying, not to execute the actions Terraform has selected for managed infrastructure; this alternative addresses a different control or phase.
Question 195
During a module implementation, one task is to skip installing child modules in a prepared directory, while another is to disallow interactive answers during initialization. Select the matching pair of techniques.
- Use
terraform init -get=false + Use terraform init -input=false in automation
- Run
terraform init in the root module directory + Use terraform init -input=false in automation
- Use
terraform init -backend=false cautiously + Use terraform init -backend-config=FILE
- Use
terraform init -get=false + Use terraform init -lockfile=readonly
Explanation
Correct Answer
A:For the first criterion, this option avoids module download/update during initialization; it is appropriate only when required modules are already available; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and disallow interactive answers during initialization; this directly addresses the need to skip installing child modules in a prepared directory. For the separate second criterion, noninteractive jobs fail instead of waiting for a prompt when required values cannot be supplied; this supports predictable CI behavior; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and disallow interactive answers during initialization; this fulfills the need to disallow interactive answers during initialization. Together they cover the independent tasks of skip installing child modules in a prepared directory and disallow interactive answers during initialization without exchanging the responsibilities of these features.
Incorrect Answers
B:The second measure does meet the disallow interactive answers during initialization requirement, but the first is designed for another concern: Init configures the selected backend and installs required providers and child modules; it is safe to repeat but may need additional flags after backend changes; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and disallow interactive answers during initialization. That first component is designed to initialize the working directory and fetch dependencies, which does not accomplish the requested task to skip installing child modules in a prepared directory, even though the other measure satisfies disallow interactive answers during initialization.
C:The first measure is intended to skip backend initialization for a specific preparation task: Disabling backend setup avoids configuring remote state, but some later operations require an initialized backend; it does not create a temporary safe state automatically; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and disallow interactive answers during initialization. The second measure is intended to supply missing backend settings during initialization: Partial backend configuration can be completed from a separate file; values supplied this way may still be recorded in local Terraform metadata or saved plans; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and disallow interactive answers during initialization. Neither is the directly designated method for the separate goals of skip installing child modules in a prepared directory and disallow interactive answers during initialization in this review.
D:The first measure meets the requirement to skip installing child modules in a prepared directory, but its partner serves a different role: Read-only dependency locking catches selection drift in automated builds; the lock file applies to providers rather than pinning arbitrary local module directories; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and disallow interactive answers during initialization. That second component is designed to enforce a committed provider selection without lockfile edits, so the still-missing criterion is to disallow interactive answers during initialization, while the first criterion remains skip installing child modules in a prepared directory.
Question 196
A reviewer has to approve a two-part design: detect proposed infrastructure differences as well as dynamic provider evaluations; additionally, detect unsupported resource arguments or incorrect types. Which option pairs the correct mechanisms?
- Run
terraform validate -json for machine consumption + Recognize provider schema validation
- Use
terraform plan for state-dependent checking + Recognize provider schema validation
- Use variable
validation for input contracts + Use preconditions for runtime assumptions
- Use
terraform plan for state-dependent checking + Run terraform validate after init
Explanation
Correct Answer
B:For the first criterion, plan evaluates the current infrastructure context and produces intended actions; validate cannot establish whether remote permissions and quotas will permit those actions; this behavior should be assessed against the concrete need to detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types; this directly addresses the need to detect proposed infrastructure differences as well as dynamic provider evaluations. For the separate second criterion, provider plugins supply schemas used for structural checking; passing validation does not mean the remote API will accept every eventual requested operation; this behavior should be assessed against the concrete need to detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types; this fulfills the need to detect unsupported resource arguments or incorrect types. Together they cover the independent tasks of detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the detect unsupported resource arguments or incorrect types requirement, but the first is designed for another concern: JSON output allows tooling to read validation findings systematically; it does not change whether the configuration will be applied; this behavior should be assessed against the concrete need to detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types. That first component is designed to obtain structured diagnostics in automation, which does not accomplish the requested task to detect proposed infrastructure differences as well as dynamic provider evaluations, even though the other measure satisfies detect unsupported resource arguments or incorrect types.
C:The first measure is intended to reject invalid user-supplied values with a targeted message: The validation rule belongs to the variable declaration and returns a Boolean; it is distinct from the CLI's whole-configuration validation subcommand; this behavior should be assessed against the concrete need to detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types. The second measure is intended to enforce environment-specific prerequisites that static validation cannot prove: A lifecycle precondition can validate context-dependent values before acting on a resource; a general syntax check alone cannot confirm runtime facts; this behavior should be assessed against the concrete need to detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types. Neither is the directly designated method for the separate goals of detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types in this review.
D:The first measure meets the requirement to detect proposed infrastructure differences as well as dynamic provider evaluations, but its partner serves a different role: Validate checks syntax, types, and provider-schema rules without generating a cloud execution plan; initialization is normally required so schemas and modules are present; this behavior should be assessed against the concrete need to detect proposed infrastructure differences as well as dynamic provider evaluations and detect unsupported resource arguments or incorrect types. That second component is designed to check configuration consistency independently of managed infrastructure operations, so the still-missing criterion is to detect unsupported resource arguments or incorrect types, while the first criterion remains detect proposed infrastructure differences as well as dynamic provider evaluations.
Question 197
During an infrastructure audit, the team must accomplish all of these distinct aims: (1) interpret an attribute whose value is not available during planning; (2) distinguish modification of an existing object from creation or destruction. Select exactly the two relevant mechanisms. Choose TWO.
- Read
~ as in-place update intent
- Use
terraform plan -var-file=env.tfvars
- Use
terraform show -json tfplan
- Understand a
(known after apply) value
- Use
terraform plan -detailed-exitcode
Explanation
Correct Answers
A:The plan symbol indicates updating a tracked resource without replacing its identity; whether a particular field supports this depends on the provider; this behavior should be assessed against the concrete need to interpret an attribute whose value is not available during planning and distinguish modification of an existing object from creation or destruction. This matches the distinct objective to distinguish modification of an existing object from creation or destruction; the remaining chosen features address interpret an attribute whose value is not available during planning.
D:Computed provider attributes may be unknown until resource creation; terraform carries unknown values through dependent expressions rather than fabricating them; this behavior should be assessed against the concrete need to interpret an attribute whose value is not available during planning and distinguish modification of an existing object from creation or destruction. This matches the distinct objective to interpret an attribute whose value is not available during planning; the remaining chosen features address distinguish modification of an existing object from creation or destruction.
Incorrect Answers
B:An explicitly selected tfvars file feeds input values into that run; a .tfvars file is not a provider dependency lock; this behavior should be assessed against the concrete need to interpret an attribute whose value is not available during planning and distinguish modification of an existing object from creation or destruction. Its main application is to load an explicit environment input file; the checklist instead asks for interpret an attribute whose value is not available during planning; and distinguish modification of an existing object from creation or destruction. None of those distinct criteria specifically calls for this alternative.
C:JSON output exposes structured planned values and actions; the output can contain sensitive values even when terminal formatting hides them; this behavior should be assessed against the concrete need to interpret an attribute whose value is not available during planning and distinguish modification of an existing object from creation or destruction. Its main application is to export machine-readable plan details for a policy tool; the checklist instead asks for interpret an attribute whose value is not available during planning; and distinguish modification of an existing object from creation or destruction. None of those distinct criteria specifically calls for this alternative.
E:The option uses exit code 0 for no differences, 2 for differences, and 1 for errors; a nonzero value is not always an execution failure; this behavior should be assessed against the concrete need to interpret an attribute whose value is not available during planning and distinguish modification of an existing object from creation or destruction. Its main application is to distinguish clean plans from plans with proposed changes in CI; the checklist instead asks for interpret an attribute whose value is not available during planning; and distinguish modification of an existing object from creation or destruction. None of those distinct criteria specifically calls for this alternative.
Question 198
An engineer needs to prevent two runs from racing to write incompatible snapshots as part of a planned migration. Which option is the best fit?
- Keep sensitive saved plans secure
- Use
terraform apply -auto-approve for controlled automation
- Check apply output for partial failure
- Avoid concurrent applies against shared state
Explanation
Correct Answer
D:A locking-capable backend serializes state modifications; even with a lock, proper approvals and pipeline serialization remain important; this behavior should be assessed against the concrete need to prevent two runs from racing to write incompatible snapshots. This directly supports the task to prevent two runs from racing to write incompatible snapshots during a maintenance request.
Incorrect Answers
A:Plan files are not sanitized public reports; their embedded values and backend details require protective storage and restricted access; this behavior should be assessed against the concrete need to prevent two runs from racing to write incompatible snapshots. That can be useful when the aim is to avoid leaking provider settings and input values through artifacts, but it does not directly deliver the requested ability to prevent two runs from racing to write incompatible snapshots.
B:The option removes the manual confirmation stage; it is not an alternative to reviewing changes, securing credentials, or verifying policies; this behavior should be assessed against the concrete need to prevent two runs from racing to write incompatible snapshots. The distinction matters here: using that mechanism to skip the interactive approval prompt when the pipeline already has gates would still leave the objective to prevent two runs from racing to write incompatible snapshots unmet.
C:Terraform may have completed earlier provider operations before a later step fails; state can record successful actions, so investigate the next plan rather than assuming a full rollback; this behavior should be assessed against the concrete need to prevent two runs from racing to write incompatible snapshots. It may support a related workflow, but the question specifically requires the mechanism for prevent two runs from racing to write incompatible snapshots rather than understand why an unsuccessful apply may still have changed some resources.
Question 199
An infrastructure team is planning a safe teardown. The requirement is to understand why child objects may be destroyed before prerequisites. Which Terraform mechanism directly meets this requirement?
- Check the selected workspace before destroying
- Inspect dependencies during teardown
- Use
terraform destroy -auto-approve only with safeguards
- Use
terraform destroy -target=ADDRESS cautiously
Explanation
Correct Answer
B:Terraform reverses dependency relationships where necessary to delete objects safely; explicit and implicit graph edges influence safe order; this behavior should be assessed against the concrete need to understand why child objects may be destroyed before prerequisites. This directly supports the task to understand why child objects may be destroyed before prerequisites during an automated release.
Incorrect Answers
A:Terraform operates on the selected state and current configuration; similar resource names in separate states can refer to entirely different real objects; this behavior should be assessed against the concrete need to understand why child objects may be destroyed before prerequisites. The stated requirement is to understand why child objects may be destroyed before prerequisites, not to avoid deleting resources belonging to a different environment; this alternative addresses a different control or phase.
C:Automatic approval suppresses the prompt but not provider deletion restrictions or external dependencies; the operation remains destructive; this behavior should be assessed against the concrete need to understand why child objects may be destroyed before prerequisites. The distinction matters here: using that mechanism to bypass interactive confirmation for a controlled teardown job would still leave the objective to understand why child objects may be destroyed before prerequisites unmet.
D:Targeting is intended for exceptional recovery, not routine architecture management; the rest of the state can remain dependent on objects that were removed; this behavior should be assessed against the concrete need to understand why child objects may be destroyed before prerequisites. It may support a related workflow, but the question specifically requires the mechanism for understand why child objects may be destroyed before prerequisites rather than limit a teardown to a selected resource or dependency subset.
Question 200
A pull request contains inconsistent Terraform formatting. A reviewer must determine how to detect files whose formatting differs from Terraform conventions. Which action is the appropriate choice?
- Avoid treating formatting as infrastructure planning
- Separate
fmt from provider installation
- Run
terraform fmt -check in CI
- Apply style checks to module directories
Explanation
Correct Answer
C:Check mode reports whether formatting changes are needed and can fail a pipeline; it does not itself rewrite source files; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions. This directly supports the task to detect files whose formatting differs from Terraform conventions during a staged rollout.
Incorrect Answers
A:A formatted file must still be evaluated by terraform plan to reveal resource changes; formatting commands do not contact APIs to execute changes; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions. It may support a related workflow, but the question specifically requires the mechanism for detect files whose formatting differs from Terraform conventions rather than recognize that whitespace changes are not a plan for cloud operations.
B:Formatting reads local HCL and does not initialize backends or download provider packages; dependency preparation remains the role of init; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions. The stated requirement is to detect files whose formatting differs from Terraform conventions, not to avoid expecting style normalization to fetch plugin binaries; this alternative addresses a different control or phase.
D:Module source code is Terraform configuration and can be formatted with the same tool; formatting never pins which module release is used; this behavior should be assessed against the concrete need to detect files whose formatting differs from Terraform conventions. The distinction matters here: using that mechanism to enforce a consistent codebase without changing module behavior would still leave the objective to detect files whose formatting differs from Terraform conventions unmet.