HashiCorp Terraform Associate 004 Practice Test 63
Question 620
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A project intended to stay on a provider's version 5 releases but a broad >= 5.0 constraint unexpectedly selected a breaking 6.x release. The configuration should behave consistently without broadening access. Which proposed remediation solves this failure without masking its cause?
- Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again.
- Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
- Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
- Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
Explanation
Correct Answer
D:Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. Confirm the cause with: Examine required_providers version constraints and the selected version recorded in the dependency lock file. A concrete acceptance test is: Routine initialization stays within the intended major version while explicit change review governs the next major update. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A project….
Incorrect Answers
A:Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again. This could address provider source requirement declaration, but it does not correct the indicated provider version range semantics mechanism. The relevant fix is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
B:Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required. This could address module provider mapping for aliased configurations, but it does not correct the indicated provider version range semantics mechanism. The relevant fix is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
C:Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly. This could address multiple provider instances requiring separate authentication, but it does not correct the indicated provider version range semantics mechanism. The relevant fix is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
Question 621
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer creates three storage resources using for_each but later reads a bare resource attribute as though the declaration has a single instance. The engineer must respect declared resource contracts and data security boundaries. Which proposed remediation solves this failure without masking its cause?
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Use the managed subnet resource's appropriate output attribute directly in the server configuration.
- Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow.
- Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
Explanation
Correct Answer
D:Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. for_each produces keyed instances whose attributes must be accessed by their instance keys or collected expressions. Confirm the cause with: Check the for_each keys and the collection shape of the declared resource instances. A concrete acceptance test is: Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer….
Incorrect Answers
A:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This could address resource precondition for unsafe configuration, but it does not correct the indicated collection references for for_each resources mechanism. The relevant fix is: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
B:Use the managed subnet resource's appropriate output attribute directly in the server configuration. This could address implicit dependency through resource attribute reference, but it does not correct the indicated collection references for for_each resources mechanism. The relevant fix is: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer….
C:Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow. This could address vault credential lookup without hardcoding secret values, but it does not correct the indicated collection references for for_each resources mechanism. The relevant fix is: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
Question 622
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A platform team copies the same network resource blocks into six application roots, and changes to security requirements require editing all six independently. The team must preserve reproducibility across callers. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Identify common resource groups and the controlled parameters that vary by application team.
- Inspect the child module's output blocks and root expressions that refer to module.network values.
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
- Trace the token through module input/output declarations and identify any output that exposes secret data.
Explanation
Correct Answer
A:Identify common resource groups and the controlled parameters that vary by application team. Terraform modules package related resource definitions into reusable components without requiring one shared state for every consumer. A justified correction is: Create a reusable child module with a documented input/output contract and call it from each application's root module. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
B:Inspect the child module's output blocks and root expressions that refer to module.network values. This inspects child output exposure to calling module rather than the reported module blocks reuse standard infrastructure patterns issue. The decisive investigation is: Identify common resource groups and the controlled parameters that vary by application team. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
C:Inspect the parent composition and whether the network child provides an output representing the created subnet. This inspects module outputs coordinate dependencies instead of duplicate data rather than the reported module blocks reuse standard infrastructure patterns issue. The decisive investigation is: Identify common resource groups and the controlled parameters that vary by application team. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
D:Trace the token through module input/output declarations and identify any output that exposes secret data. This inspects sensitive input forwarding between nested modules rather than the reported module blocks reuse standard infrastructure patterns issue. The decisive investigation is: Identify common resource groups and the controlled parameters that vary by application team.
Question 623
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A CI pipeline generates a plan for review but later runs terraform apply without supplying the saved plan, allowing freshly computed changes that were not approved. The operator must obtain auditable evidence before touching production resources. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
- Validation passes with the declared variable name and no longer reports the nonexistent symbol reference.
- The next reviewed plan reflects a deliberate drift decision rather than automatically treating an outside change as approved.
- The formatting gate passes without any provider upgrade or unintended managed-resource change.
Explanation
Correct Answer
A:The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs. An applied saved plan preserves the planned decisions at creation time; plan artifacts can hold secrets and require restricted storage. It tests the correction: Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content. This matters here because a CI pipeline generates a plan for review but later runs terraform apply without supplying the saved plan, allowing….
Incorrect Answers
B:Validation passes with the declared variable name and no longer reports the nonexistent symbol reference. This might validate terraform validate catches undeclared reference, but it does not prove that saved execution plan for controlled deployment was resolved. Confirm instead: The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
C:The next reviewed plan reflects a deliberate drift decision rather than automatically treating an outside change as approved. This might validate plan versus real infrastructure drift, but it does not prove that saved execution plan for controlled deployment was resolved. Confirm instead: The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs. This matters here because a CI pipeline generates a plan for review but later runs terraform apply without supplying the saved plan, allowing….
D:The formatting gate passes without any provider upgrade or unintended managed-resource change. This might validate ci terraform fmt check distinguishes style from validity, but it does not prove that saved execution plan for controlled deployment was resolved. Confirm instead: The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
Question 624
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A resource should be deployed only when its selected storage class meets a business constraint, but the configuration proceeds with unsupported combinations. The engineer must respect declared resource contracts and data security boundaries. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
- Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow.
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Provide the required region input through the module call or a supported root variable assignment mechanism.
Explanation
Correct Answer
C:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. Preconditions assert requirements that must hold before a resource operation can proceed, rather than silently applying risky inputs. Confirm the cause with: Identify the policy invariant and the resource lifecycle point where it should be checked before provisioning. A concrete acceptance test is: The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A resource….
Incorrect Answers
A:Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports. This could address check block observability versus hard failure, but it does not correct the indicated resource precondition for unsafe configuration mechanism. The relevant fix is: Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
B:Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow. This could address vault credential lookup without hardcoding secret values, but it does not correct the indicated resource precondition for unsafe configuration mechanism. The relevant fix is: Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
D:Provide the required region input through the module call or a supported root variable assignment mechanism. This could address variable default versus required input, but it does not correct the indicated resource precondition for unsafe configuration mechanism. The relevant fix is: Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
Question 625
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A maintenance engineer changes a provider constraint but an existing workspace continues using an older locked plugin even though a newer permitted version is needed. The engineers must keep provider choices and identities reproducible. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Inspect the resource type prefixes and required_providers source mappings before running terraform init.
- Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
- Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
- Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again.
Explanation
Correct Answers
B:Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. Terraform init normally honors locked versions; -upgrade allows choosing newer compatible selections under the declared constraints. Confirm the cause with: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. A concrete acceptance test is: The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates. This forms one element of the required two-step diagnosis and correction. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A maintenance….
C:Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Terraform init normally honors locked versions; -upgrade allows choosing newer compatible selections under the declared constraints. A justified correction is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. This forms one element of the required two-step diagnosis and correction. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A maintenance….
Incorrect Answers
A:Inspect the resource type prefixes and required_providers source mappings before running terraform init. This relates to provider plugin manages api resources and data reads rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Then change: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
D:Define explicitly aliased provider configurations and assign the production resource to the intended alias. This relates to provider alias for multiple accounts rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Then change: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
E:Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again. This relates to provider source requirement declaration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Then change: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
Question 626
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A database connection output includes a password but the author marks only the input variable as sensitive and expects every derived output to be safely hidden in command output. The engineer must respect declared resource contracts and data security boundaries. Select TWO: the decisive first check and the change that directly addresses the problem.
- Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
- Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
- Provide the required region input through the module call or a supported root variable assignment mechanism.
- Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
- Review input and output sensitivity declarations and inspect what the plan or output commands will display.
Explanation
Correct Answers
B:Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. Sensitivity metadata affects presentation, not a guarantee that secret bytes have been removed from state or all other surfaces. Confirm the cause with: Review input and output sensitivity declarations and inspect what the plan or output commands will display. A concrete acceptance test is: Routine Terraform output suppresses the marked secret while protected state access remains restricted. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A database….
E:Review input and output sensitivity declarations and inspect what the plan or output commands will display. Sensitivity metadata affects presentation, not a guarantee that secret bytes have been removed from state or all other surfaces. A justified correction is: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A database….
Incorrect Answers
A:Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists. This relates to data source read ordering versus creation rather than the matching diagnosis-and-remediation pair required here. Check: Review input and output sensitivity declarations and inspect what the plan or output commands will display. Then change: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
C:Provide the required region input through the module call or a supported root variable assignment mechanism. This relates to variable default versus required input rather than the matching diagnosis-and-remediation pair required here. Check: Review input and output sensitivity declarations and inspect what the plan or output commands will display. Then change: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A database….
D:Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. This relates to resource addressing with repeated instances rather than the matching diagnosis-and-remediation pair required here. Check: Review input and output sensitivity declarations and inspect what the plan or output commands will display. Then change: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
Question 627
While migrating a manually maintained development environment into reviewed Terraform configuration, the following condition occurs: Two automation systems both change the same cloud storage policy, and repeated Terraform applies continuously undo the other controller's modifications. The team must establish a reproducible and auditable infrastructure change. Which investigation would most directly establish the reported Terraform failure?
- Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
- Identify which attributes Terraform declares and which external system writes to the same managed object between runs.
- Inspect whether the deployment process captures a proposed execution plan and identifies create, update, delete, and replacement actions.
- Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications.
Explanation
Correct Answer
B:Identify which attributes Terraform declares and which external system writes to the same managed object between runs. Declarative reconciliation requires a clear ownership contract; competing controllers can create perpetual drift. A justified correction is: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices. This matters here because while migrating a manually maintained development environment into reviewed Terraform configuration, the following….
Incorrect Answers
A:Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces. This inspects provider-neutral infrastructure pattern without identical resource types rather than the reported terraform resource ownership boundary issue. The decisive investigation is: Identify which attributes Terraform declares and which external system writes to the same managed object between runs.
C:Inspect whether the deployment process captures a proposed execution plan and identifies create, update, delete, and replacement actions. This inspects terraform plan review as change safety barrier rather than the reported terraform resource ownership boundary issue. The decisive investigation is: Identify which attributes Terraform declares and which external system writes to the same managed object between runs.
D:Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications. This inspects terraform configuration as reviewable infrastructure specification rather than the reported terraform resource ownership boundary issue. The decisive investigation is: Identify which attributes Terraform declares and which external system writes to the same managed object between runs.
Question 628
During a controlled module integration test for a production Terraform stack, the following condition occurs: A reusable subnet module expects each entry to contain a CIDR and an enable flag, but callers submit unstructured strings and fail validation. The desired fix must avoid unrelated resource changes. Which proposed remediation solves this failure without masking its cause?
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
- Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
Explanation
Correct Answer
D:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. Structured object types validate named attribute contracts; a plain string cannot substitute for an object with multiple typed fields. Confirm the cause with: Inspect the module's input type constraint and the shape of the supplied nested values. A concrete acceptance test is: Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
Incorrect Answers
A:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This could address resource precondition for unsafe configuration, but it does not correct the indicated object type contract with nested attributes mechanism. The relevant fix is: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
B:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This could address map versus list addressing for environment inputs, but it does not correct the indicated object type contract with nested attributes mechanism. The relevant fix is: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
C:Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required. This could address write-only provider argument for managed secret rotation, but it does not correct the indicated object type contract with nested attributes mechanism. The relevant fix is: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
Question 629
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An automated Terraform run uses an obsolete deployment region even though an operator changed the default region in variables.tf, because another source supplies an overriding value. The engineer must respect declared resource contracts and data security boundaries. Which proposed remediation solves this failure without masking its cause?
- Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
- Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
- Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
- Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
Explanation
Correct Answer
B:Remove or update the overriding variable source and make the intended region input explicit for the controlled run. Terraform variable defaults apply only when no higher-precedence assignment supplies a different value. Confirm the cause with: Inspect command-line var flags, tfvars files, Terraform variable environment entries, and workspace variable values. A concrete acceptance test is: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
Incorrect Answers
A:Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated. This could address ignore_changes ownership of externally managed tag, but it does not correct the indicated variable input precedence and configuration injection mechanism. The relevant fix is: Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
C:Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports. This could address check block observability versus hard failure, but it does not correct the indicated variable input precedence and configuration injection mechanism. The relevant fix is: Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
D:Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. This could address sensitive output display behavior, but it does not correct the indicated variable input precedence and configuration injection mechanism. The relevant fix is: Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
Question 630
While migrating a manually maintained development environment into reviewed Terraform configuration, the following condition occurs: Three product teams rebuild nearly identical staging networks by copying browser instructions, but naming and access rules diverge by team. The team must establish a reproducible and auditable infrastructure change. Which proposed remediation solves this failure without masking its cause?
- Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
- Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
- Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations.
- Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state.
Explanation
Correct Answer
B:Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences. Shared IaC patterns reduce accidental divergence without requiring every environment to have identical parameters. Confirm the cause with: Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally. A concrete acceptance test is: New staging environments satisfy common access requirements while explicit input values account for documented environment differences. This matters here because while migrating a manually maintained development environment into reviewed Terraform configuration, the following….
Incorrect Answers
A:Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices. This could address terraform resource ownership boundary, but it does not correct the indicated reusable environment definitions and reduced configuration drift mechanism. The relevant fix is: Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
C:Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations. This could address version-controlled iac change auditing, but it does not correct the indicated reusable environment definitions and reduced configuration drift mechanism. The relevant fix is: Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
D:Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state. This could address declarative desired state versus imperative console runbook, but it does not correct the indicated reusable environment definitions and reduced configuration drift mechanism. The relevant fix is: Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences. This matters here because while migrating a manually maintained development environment into reviewed Terraform configuration, the following….