HashiCorp Terraform Associate (HashiCorp Certified: Terraform Associate) Practice Test 23

Question 220

In an automated release, the requested result is to avoid assuming Terraform can restore deleted provider objects from state alone. What should the engineer select?

  1. Preserve required records before teardown
  2. Use terraform plan -destroy for teardown review
  3. Remove a resource from state without destroying it
  4. Inspect dependencies during teardown

Explanation

Correct Answer

A:

State is a management map, not a full backup of application data or cloud resources; deletion may be irreversible without separate backups; this behavior should be assessed against the concrete need to avoid assuming Terraform can restore deleted provider objects from state alone. This directly supports the task to avoid assuming Terraform can restore deleted provider objects from state alone during a module implementation.

Incorrect Answers

B:

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 assuming Terraform can restore deleted provider objects from state alone. The stated requirement is to avoid assuming Terraform can restore deleted provider objects from state alone, not to preview the deletions without executing them; this alternative addresses a different control or phase.

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 assuming Terraform can restore deleted provider objects from state alone. 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 assuming Terraform can restore deleted provider objects from state alone.

D:

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 avoid assuming Terraform can restore deleted provider objects from state alone. The distinction matters here: using that mechanism to understand why child objects may be destroyed before prerequisites would still leave the objective to avoid assuming Terraform can restore deleted provider objects from state alone unmet.

Question 221

A pull request contains inconsistent Terraform formatting. The team must both inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations. Which paired choice implements those distinct goals?

  1. Use terraform fmt -write=false + Avoid treating formatting as infrastructure planning
  2. Run terraform fmt -check in CI + Avoid treating formatting as infrastructure planning
  3. Use terraform fmt -write=false + Run terraform fmt -recursive
  4. Separate fmt from provider installation + Apply style checks to module directories

Explanation

Correct Answer

A:

For the first criterion, disabling write avoids persisting formatting edits while retaining the formatting analysis; it is not a semantic validation of the resource schema; this behavior should be assessed against the concrete need to inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations; this directly addresses the need to inspect formatting requirements without modifying files. For the separate second criterion, 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 inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations; this fulfills the need to recognize that whitespace changes are not a plan for cloud operations. Together they cover the independent tasks of inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations without exchanging the responsibilities of these features.

Incorrect Answers

B:

The second measure does meet the recognize that whitespace changes are not a plan for cloud operations requirement, but the first is designed for another concern: 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 inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations. That first component is designed to detect files whose formatting differs from Terraform conventions, which does not accomplish the requested task to inspect formatting requirements without modifying files, even though the other measure satisfies recognize that whitespace changes are not a plan for cloud operations.

C:

The first measure meets the requirement to inspect formatting requirements without modifying files, but its partner serves a different role: 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 inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations. That second component is designed to format Terraform configurations in nested directories, so the still-missing criterion is to recognize that whitespace changes are not a plan for cloud operations, while the first criterion remains inspect formatting requirements without modifying files.

D:

The first measure is intended to avoid expecting style normalization to fetch plugin binaries: 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 inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations. The second measure is intended to enforce a consistent codebase without changing module behavior: 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 inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations. Neither is the directly designated method for the separate goals of inspect formatting requirements without modifying files and recognize that whitespace changes are not a plan for cloud operations in this review.

Question 222

A new engineer is learning the operational workflow. The checklist contains independent tasks: (1) reduce risk by verifying syntax and policy before deploying; (2) ensure the approved actions still correspond to current state. Which two options directly correspond to the respective tasks? Choose TWO.

  1. Avoid applying an outdated reviewed plan
  2. Initialize the working directory before planning
  3. Put automated tests before apply approvals
  4. Use version control alongside the workflow
  5. Apply reviewed changes with terraform apply
  6. Review results with a follow-up plan

Explanation

Correct Answers

A:

Saved plans encode assumptions about the state snapshot and inputs; if the state changes, applying a stale plan may be rejected rather than silently reinterpreted; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying and ensure the approved actions still correspond to current state. This matches the distinct objective to ensure the approved actions still correspond to current state; the remaining chosen features address reduce risk by verifying syntax and policy before deploying.

C:

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 and ensure the approved actions still correspond to current state. This matches the distinct objective to reduce risk by verifying syntax and policy before deploying; the remaining chosen features address ensure the approved actions still correspond to current state.

Incorrect Answers

B:

terraform init sets up the directory so subsequent validation, planning, and applying can use the correct plugins and backend; initialization itself does not deploy resources; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying and ensure the approved actions still correspond to current state. Its main application is to prepare backend, providers, and external module dependencies; the checklist instead asks for reduce risk by verifying syntax and policy before deploying; and ensure the approved actions still correspond to current state. None of those distinct criteria specifically calls for this alternative.

D:

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 and ensure the approved actions still correspond to current state. Its main application is to make infrastructure edits traceable and reviewable; the checklist instead asks for reduce risk by verifying syntax and policy before deploying; and ensure the approved actions still correspond to current state. None of those distinct criteria specifically calls for this alternative.

E:

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 and ensure the approved actions still correspond to current state. Its main application is to execute the actions Terraform has selected for managed infrastructure; the checklist instead asks for reduce risk by verifying syntax and policy before deploying; and ensure the approved actions still correspond to current state. None of those distinct criteria specifically calls for this alternative.

F:

When inputs and real infrastructure are unchanged, a later normal plan generally shows no changes; a follow-up plan can also detect external drift; this behavior should be assessed against the concrete need to reduce risk by verifying syntax and policy before deploying and ensure the approved actions still correspond to current state. Its main application is to verify convergence after a completed deployment; the checklist instead asks for reduce risk by verifying syntax and policy before deploying; and ensure the approved actions still correspond to current state. None of those distinct criteria specifically calls for this alternative.

Question 223

A build worker must initialize a reproducible working directory. The requirement is to recognize initialization artifacts rather than versioned source. Which Terraform mechanism directly meets this requirement?

  1. Use terraform init -upgrade
  2. Use terraform init -migrate-state
  3. Inspect .terraform/ as generated local metadata
  4. Use terraform init -reconfigure
  5. Use terraform init -backend=false cautiously

Explanation

Correct Answer

C:

The directory can hold installed modules, provider metadata, and backend configuration; it should normally be excluded from Git and may contain sensitive settings; this behavior should be assessed against the concrete need to recognize initialization artifacts rather than versioned source. This directly supports the task to recognize initialization artifacts rather than versioned source during an automated release.

Incorrect Answers

A:

Upgrade requests reconsideration of versions within declared constraints; it changes dependency selections, not infrastructure objects by itself; this behavior should be assessed against the concrete need to recognize initialization artifacts rather than versioned source. The stated requirement is to recognize initialization artifacts rather than versioned source, not to reselect newer eligible provider and module packages; this alternative addresses a different control or phase.

B:

Migration attempts to move state into the newly configured backend; backups and confirmation are important before switching active state locations; this behavior should be assessed against the concrete need to recognize initialization artifacts rather than versioned source. That can be useful when the aim is to copy existing state when changing storage backends, but it does not directly deliver the requested ability to recognize initialization artifacts rather than versioned source.

D:

Reconfiguration initializes the directory against the new backend settings; it is not a replacement for migrating state that must be preserved; this behavior should be assessed against the concrete need to recognize initialization artifacts rather than versioned source. It may support a related workflow, but the question specifically requires the mechanism for recognize initialization artifacts rather than versioned source rather than discard the previously remembered backend configuration without migrating state.

E:

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 recognize initialization artifacts rather than versioned source. The stated requirement is to recognize initialization artifacts rather than versioned source, not to skip backend initialization for a specific preparation task; this alternative addresses a different control or phase.

Question 224

A continuous-integration job must catch configuration defects. A reviewer must determine how to detect code style deviations without rewriting files. Which action is the appropriate choice?

  1. Use terraform plan for state-dependent checking
  2. Use preconditions for runtime assumptions
  3. Use terraform fmt -check for formatting enforcement
  4. Use variable validation for input contracts

Explanation

Correct Answer

C:

fmt -check exits nonzero when files need canonical formatting; it is a style check, not a replacement for Terraform semantic validation; this behavior should be assessed against the concrete need to detect code style deviations without rewriting files. This directly supports the task to detect code style deviations without rewriting files during a staged rollout.

Incorrect Answers

A:

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 code style deviations without rewriting files. It may support a related workflow, but the question specifically requires the mechanism for detect code style deviations without rewriting files rather than detect proposed infrastructure differences as well as dynamic provider evaluations.

B:

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 code style deviations without rewriting files. The stated requirement is to detect code style deviations without rewriting files, not to enforce environment-specific prerequisites that static validation cannot prove; this alternative addresses a different control or phase.

D:

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 code style deviations without rewriting files. The distinction matters here: using that mechanism to reject invalid user-supplied values with a targeted message would still leave the objective to detect code style deviations without rewriting files unmet.

Question 225

The immediate Terraform task is to omit the usual state refresh while creating an ordinary plan. Which method handles that task most directly?

  1. Use terraform plan -refresh=false carefully
  2. Use terraform plan -var='name=value'
  3. Run terraform plan without applying
  4. Use terraform show -json tfplan

Explanation

Correct Answer

A:

Skipping remote refresh can produce an inaccurate plan when out-of-band changes have occurred; it is not a drift-detection strategy; this behavior should be assessed against the concrete need to omit the usual state refresh while creating an ordinary plan. This directly supports the task to omit the usual state refresh while creating an ordinary plan during a configuration change.

Incorrect Answers

B:

CLI variable arguments supply run-specific values; they do not permanently modify the variable declaration or backend configuration; this behavior should be assessed against the concrete need to omit the usual state refresh while creating an ordinary plan. It may support a related workflow, but the question specifically requires the mechanism for omit the usual state refresh while creating an ordinary plan rather than override an input variable for one planned run.

C:

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 omit the usual state refresh while creating an ordinary plan. The stated requirement is to omit the usual state refresh while creating an ordinary plan, not to preview the actions needed to reconcile the declared configuration; this alternative addresses a different control or phase.

D:

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 omit the usual state refresh while creating an ordinary plan. That can be useful when the aim is to export machine-readable plan details for a policy tool, but it does not directly deliver the requested ability to omit the usual state refresh while creating an ordinary plan.

Question 226

A Terraform review separates 2 requirements: (1) understand why an unsuccessful apply may still have changed some resources; (2) reconcile the state and observed API results before taking further action. Identify the two features that each directly handle one of those requirements. Choose TWO.

  1. Check apply output for partial failure
  2. Use terraform apply -var-file=prod.tfvars
  3. Use terraform apply -auto-approve for controlled automation
  4. Run terraform apply tfplan for an approved saved plan
  5. Use terraform apply -input=false in unattended execution
  6. Run a new plan after unexpected apply behavior

Explanation

Correct Answers

A:

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 understand why an unsuccessful apply may still have changed some resources and reconcile the state and observed API results before taking further action. This matches the distinct objective to understand why an unsuccessful apply may still have changed some resources; the remaining chosen features address reconcile the state and observed API results before taking further action.

F:

A subsequent plan refreshes tracked objects and identifies outstanding changes; blindly rerunning unrelated commands may hide the failure's scope; this behavior should be assessed against the concrete need to understand why an unsuccessful apply may still have changed some resources and reconcile the state and observed API results before taking further action. This matches the distinct objective to reconcile the state and observed API results before taking further action; the remaining chosen features address understand why an unsuccessful apply may still have changed some resources.

Incorrect Answers

B:

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 understand why an unsuccessful apply may still have changed some resources and reconcile the state and observed API results before taking further action. Its main application is to supply planned environment-specific input values in a direct apply; the checklist instead asks for understand why an unsuccessful apply may still have changed some resources; and reconcile the state and observed API results before taking further action. None of those distinct criteria specifically calls for this alternative.

C:

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 understand why an unsuccessful apply may still have changed some resources and reconcile the state and observed API results before taking further action. Its main application is to skip the interactive approval prompt when the pipeline already has gates; the checklist instead asks for understand why an unsuccessful apply may still have changed some resources; and reconcile the state and observed API results before taking further action. None of those distinct criteria specifically calls for this alternative.

D:

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 understand why an unsuccessful apply may still have changed some resources and reconcile the state and observed API results before taking further action. Its main application is to execute the exact plan artifact rather than replan with new input values; the checklist instead asks for understand why an unsuccessful apply may still have changed some resources; and reconcile the state and observed API results before taking further action. None of those distinct criteria specifically calls for this alternative.

E:

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 understand why an unsuccessful apply may still have changed some resources and reconcile the state and observed API results before taking further action. Its main application is to prevent the run from waiting for interactive variable input; the checklist instead asks for understand why an unsuccessful apply may still have changed some resources; and reconcile the state and observed API results before taking further action. None of those distinct criteria specifically calls for this alternative.

Question 227

A platform pipeline needs deterministic style checks. The requirement is to reduce noisy diff conflicts across contributors. Which Terraform mechanism directly meets this requirement?

  1. Use terraform fmt -write=false
  2. Use standard indentation and alignment from fmt
  3. Separate fmt from provider installation
  4. Avoid treating formatting as infrastructure planning

Explanation

Correct Answer

B:

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 reduce noisy diff conflicts across contributors. This directly supports the task to reduce noisy diff conflicts across contributors during a planned migration.

Incorrect Answers

A:

Disabling write avoids persisting formatting edits while retaining the formatting analysis; it is not a semantic validation of the resource schema; this behavior should be assessed against the concrete need to reduce noisy diff conflicts across contributors. It may support a related workflow, but the question specifically requires the mechanism for reduce noisy diff conflicts across contributors rather than inspect formatting requirements without modifying files.

C:

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 reduce noisy diff conflicts across contributors. That can be useful when the aim is to avoid expecting style normalization to fetch plugin binaries, but it does not directly deliver the requested ability to reduce noisy diff conflicts across contributors.

D:

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 reduce noisy diff conflicts across contributors. The distinction matters here: using that mechanism to recognize that whitespace changes are not a plan for cloud operations would still leave the objective to reduce noisy diff conflicts across contributors unmet.

Question 228

An approval board needs a safe order for infrastructure changes. Two independent changes are requested: first, establish the intended infrastructure before Terraform evaluates changes; second, identify structural issues early in a workflow. Which pair of measures fulfills both?

  1. Write the desired configuration first + Validate configuration before requesting a plan
  2. Review results with a follow-up plan + Validate configuration before requesting a plan
  3. Keep environment state separated + Validate configuration before requesting a plan
  4. Put automated tests before apply approvals + Avoid applying an outdated reviewed plan
  5. Write the desired configuration first + Preview changes with terraform plan

Explanation

Correct Answer

A:

For the first criterion, resource blocks, variables, and modules define the target arrangement; running the CLI without an intended configuration cannot infer a team's architecture goals; this behavior should be assessed against the concrete need to establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow; this directly addresses the need to establish the intended infrastructure before Terraform evaluates changes. For the separate second criterion, validation checks the HCL configuration against available schemas; it is useful in CI but cannot replace a plan based on actual state and provider data; this behavior should be assessed against the concrete need to establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow; this fulfills the need to identify structural issues early in a workflow. Together they cover the independent tasks of establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow without exchanging the responsibilities of these features.

Incorrect Answers

B:

The second measure does meet the identify structural issues early in a workflow requirement, but the first is designed for another concern: When inputs and real infrastructure are unchanged, a later normal plan generally shows no changes; a follow-up plan can also detect external drift; this behavior should be assessed against the concrete need to establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow. That first component is designed to verify convergence after a completed deployment, which does not accomplish the requested task to establish the intended infrastructure before Terraform evaluates changes, even though the other measure satisfies identify structural issues early in a workflow.

C:

The second measure does meet the identify structural issues early in a workflow requirement, but the first is designed for another concern: 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 establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow. That first component is designed to ensure independent deployments do not accidentally share object bindings, which does not accomplish the requested task to establish the intended infrastructure before Terraform evaluates changes, even though the other measure satisfies identify structural issues early in a workflow.

D:

The first measure is intended to reduce risk by verifying syntax and policy before deploying: 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 establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow. The second measure is intended to ensure the approved actions still correspond to current state: Saved plans encode assumptions about the state snapshot and inputs; if the state changes, applying a stale plan may be rejected rather than silently reinterpreted; this behavior should be assessed against the concrete need to establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow. Neither is the directly designated method for the separate goals of establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow in this review.

E:

The first measure meets the requirement to establish the intended infrastructure before Terraform evaluates changes, but its partner serves a different role: Planning compares desired configuration with current state and provider observations; no planned infrastructure actions are applied by the plan command; this behavior should be assessed against the concrete need to establish the intended infrastructure before Terraform evaluates changes and identify structural issues early in a workflow. That second component is designed to inspect intended create, change, and delete actions before execution, so the still-missing criterion is to identify structural issues early in a workflow, while the first criterion remains establish the intended infrastructure before Terraform evaluates changes.

Question 229

During a deployment checklist, one task is to skip installing child modules in a prepared directory, while another is to fetch externally sourced child module code. Select the matching pair of techniques.

  1. Use terraform init -get=false + Reinitialize after adding a module source
  2. Use terraform init -input=false in automation + Use terraform init -migrate-state
  3. Reinitialize after changing provider requirements + Reinitialize after adding a module source
  4. Use terraform init -get=false + Use terraform init -backend-config=FILE
  5. Inspect .terraform/ as generated local metadata + Reinitialize after adding a module source

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 fetch externally sourced child module code; this directly addresses the need to skip installing child modules in a prepared directory. For the separate second criterion, init downloads module packages from their sources; merely declaring a module block does not put remote module code onto disk; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and fetch externally sourced child module code; this fulfills the need to fetch externally sourced child module code. Together they cover the independent tasks of skip installing child modules in a prepared directory and fetch externally sourced child module code without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to disallow interactive answers during initialization: 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 fetch externally sourced child module code. The second measure is intended to copy existing state when changing storage backends: Migration attempts to move state into the newly configured backend; backups and confirmation are important before switching active state locations; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and fetch externally sourced child module code. Neither is the directly designated method for the separate goals of skip installing child modules in a prepared directory and fetch externally sourced child module code in this review.

C:

The second measure does meet the fetch externally sourced child module code requirement, but the first is designed for another concern: Init reconciles the plugin installation and lock selections after changes in required_providers; running only fmt cannot install a newly required plugin; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and fetch externally sourced child module code. That first component is designed to pick up new dependencies and version constraints, which does not accomplish the requested task to skip installing child modules in a prepared directory, even though the other measure satisfies fetch externally sourced child module code.

D:

The first measure meets the requirement to skip installing child modules in a prepared directory, but its partner serves a different role: 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 fetch externally sourced child module code. That second component is designed to supply missing backend settings during initialization, so the still-missing criterion is to fetch externally sourced child module code, while the first criterion remains skip installing child modules in a prepared directory.

E:

The second measure does meet the fetch externally sourced child module code requirement, but the first is designed for another concern: The directory can hold installed modules, provider metadata, and backend configuration; it should normally be excluded from Git and may contain sensitive settings; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory and fetch externally sourced child module code. That first component is designed to recognize initialization artifacts rather than versioned source, which does not accomplish the requested task to skip installing child modules in a prepared directory, even though the other measure satisfies fetch externally sourced child module code.

Question 230

A reviewer has to approve a two-part design: detect unsupported resource arguments or incorrect types; additionally, enforce environment-specific prerequisites that static validation cannot prove. Which option pairs the correct mechanisms?

  1. Recognize provider schema validation + Run terraform validate after init
  2. Run terraform validate -json for machine consumption + Use preconditions for runtime assumptions
  3. Recognize provider schema validation + Use preconditions for runtime assumptions
  4. Use terraform plan for state-dependent checking + Use preconditions for runtime assumptions
  5. Recognize provider schema validation + Check for missing required variable values at planning time
  6. Use terraform fmt -check for formatting enforcement + Interpret a clean validate as limited assurance

Explanation

Correct Answer

C:

For the first 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 unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove; this directly addresses the need to detect unsupported resource arguments or incorrect types. For the separate second criterion, 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 unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove; this fulfills the need to enforce environment-specific prerequisites that static validation cannot prove. Together they cover the independent tasks of detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to detect unsupported resource arguments or incorrect types, 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 unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That second component is designed to check configuration consistency independently of managed infrastructure operations, so the still-missing criterion is to enforce environment-specific prerequisites that static validation cannot prove, while the first criterion remains detect unsupported resource arguments or incorrect types.

B:

The second measure does meet the enforce environment-specific prerequisites that static validation cannot prove 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 unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That first component is designed to obtain structured diagnostics in automation, which does not accomplish the requested task to detect unsupported resource arguments or incorrect types, even though the other measure satisfies enforce environment-specific prerequisites that static validation cannot prove.

D:

The second measure does meet the enforce environment-specific prerequisites that static validation cannot prove requirement, but the first is designed for another concern: 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 unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That first component is designed to detect proposed infrastructure differences as well as dynamic provider evaluations, which does not accomplish the requested task to detect unsupported resource arguments or incorrect types, even though the other measure satisfies enforce environment-specific prerequisites that static validation cannot prove.

E:

The first measure meets the requirement to detect unsupported resource arguments or incorrect types, but its partner serves a different role: A variable declaration may be structurally valid even though a specific run has not supplied its required input; planning or applying requests those values when needed; this behavior should be assessed against the concrete need to detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That second component is designed to understand why validation alone may pass with no values supplied, so the still-missing criterion is to enforce environment-specific prerequisites that static validation cannot prove, while the first criterion remains detect unsupported resource arguments or incorrect types.

F:

The first measure is intended to detect code style deviations without rewriting files: fmt -check exits nonzero when files need canonical formatting; it is a style check, not a replacement for Terraform semantic validation; this behavior should be assessed against the concrete need to detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. The second measure is intended to avoid inferring a successful future apply from successful static checks: Provider API authorization, remote conflicts, and real infrastructure drift can still produce failures; validation checks supported configuration structure rather than deployment success; this behavior should be assessed against the concrete need to detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. Neither is the directly designated method for the separate goals of detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove in this review.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests