HashiCorp Terraform Associate 004 Practice Test 9
Question 80
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A developer switches Terraform CLI workspaces using a local backend and assumes all named workspaces write to the same terraform.tfstate file. The operation must not delete or duplicate existing production objects. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Compare the refreshed real object with its prior state and declared configuration to identify an outside change.
- Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- Select the intended workspace before planning and check the corresponding workspace-specific state directory.
- Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
Explanation
Correct Answers
B:Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Local backend workspaces have separate state snapshots, though they share the same configuration and local backend mechanism. A justified correction is: Select the intended workspace before planning and check the corresponding workspace-specific state directory. This forms one element of the required two-step diagnosis and correction.
D:Select the intended workspace before planning and check the corresponding workspace-specific state directory. Local backend workspaces have separate state snapshots, though they share the same configuration and local backend mechanism. Confirm the cause with: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. A concrete acceptance test is: A plan in staging reads staging bindings while a default workspace plan remains independent. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Compare the refreshed real object with its prior state and declared configuration to identify an outside change. This relates to out-of-band drift detection in managed resource rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Then change: Select the intended workspace before planning and check the corresponding workspace-specific state directory.
C:Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled. This relates to state locking prevents concurrent writes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Then change: Select the intended workspace before planning and check the corresponding workspace-specific state directory.
E:Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This relates to local backend path and exposure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Then change: Select the intended workspace before planning and check the corresponding workspace-specific state directory.
Question 81
During an operational review of a Terraform state backend, the following condition occurs: A team configures remote object storage for state and assumes every backend automatically provides the same distributed locking guarantees. The team must preserve managed-object identity and safe collaboration. Which outcome most directly validates the intended fix?
- The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
- Concurrent runs against the same state are serialized according to the backend's supported locking contract.
- A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination.
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
Explanation
Correct Answer
B:Concurrent runs against the same state are serialized according to the backend's supported locking contract. Remote storage and robust state locking are related but distinct backend capabilities; locking depends on backend implementation. It tests the correction: Select a backend with supported state-locking capabilities and configure its required access controls appropriately. This matters here because a team configures remote object storage for state and assumes every backend automatically provides the same….
Incorrect Answers
A:The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit. This might validate out-of-band drift detection in managed resource, but it does not prove that backend-specific state locking support was resolved. Confirm instead: Concurrent runs against the same state are serialized according to the backend's supported locking contract.
C:A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination. This might validate force unlock requires stale-lock verification, but it does not prove that backend-specific state locking support was resolved. Confirm instead: Concurrent runs against the same state are serialized according to the backend's supported locking contract.
D:Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs. This might validate backend credentials kept out of plan artifacts, but it does not prove that backend-specific state locking support was resolved. Confirm instead: Concurrent runs against the same state are serialized according to the backend's supported locking contract.
Question 82
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A Terraform project uses the same cloud provider in development and production accounts but a resource unexpectedly lands in the default development account. The engineers must keep provider choices and identities reproducible. Which diagnostic check provides the strongest evidence for the underlying problem?
- Check which resource attributes are computed by the provider and how state records them after successful operations.
- Review the child module provider requirements and root module providers mapping for the child call.
- Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration.
- Review required_providers declarations, provider source addresses, existing lock entries, and initialization output.
Explanation
Correct Answer
C:Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. A provider alias selects an alternate configured provider instance; resource blocks must reference it to avoid a default-account fallback. A justified correction is: Define explicitly aliased provider configurations and assign the production resource to the intended alias. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A Terraform….
Incorrect Answers
A:Check which resource attributes are computed by the provider and how state records them after successful operations. This inspects resource attribute outputs supplied by state rather than the reported provider alias for multiple accounts issue. The decisive investigation is: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration.
B:Review the child module provider requirements and root module providers mapping for the child call. This inspects module provider mapping for aliased configurations rather than the reported provider alias for multiple accounts issue. The decisive investigation is: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration.
D:Review required_providers declarations, provider source addresses, existing lock entries, and initialization output. This inspects provider source requirement declaration rather than the reported provider alias for multiple accounts issue. The decisive investigation is: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A Terraform….
Question 83
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. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
- Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
- Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
- The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
Explanation
Correct Answer
B:Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions. Structured object types validate named attribute contracts; a plain string cannot substitute for an object with multiple typed fields. It tests the correction: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
Incorrect Answers
A:The plan selects the correct per-environment instance size without relying on arbitrary key ordering. This might validate map versus list addressing for environment inputs, but it does not prove that object type contract with nested attributes was resolved. Confirm instead: Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
C:Development and production plan different approved retention settings with otherwise shared definitions and no copied modules. This might validate conditional expressions for environment configuration, but it does not prove that object type contract with nested attributes was resolved. Confirm instead: Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
D:The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit. This might validate create_before_destroy lifecycle for availability, but it does not prove that object type contract with nested attributes was resolved. Confirm instead: Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
Question 84
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A name-sensitive network endpoint needs replacement, but Terraform plans to remove the old endpoint first and an application would become unavailable. The engineer must respect declared resource contracts and data security boundaries. What measurable postchange observation would confirm that the correction worked?
- The plan defers the lookup when needed and avoids failing on a remote object that is not yet created.
- Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone.
- The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
- The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
Explanation
Correct Answer
D:The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit. create_before_destroy changes replacement ordering but cannot override remote API uniqueness rules or capacity limits. It tests the correction: Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.
Incorrect Answers
A:The plan defers the lookup when needed and avoids failing on a remote object that is not yet created. This might validate data source read ordering versus creation, but it does not prove that create_before_destroy lifecycle for availability was resolved. Confirm instead: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
B:Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone. This might validate data source versus managed resource definition, but it does not prove that create_before_destroy lifecycle for availability was resolved. Confirm instead: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
C:The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. This might validate explicit depends_on for behavior-only dependencies, but it does not prove that create_before_destroy lifecycle for availability was resolved. Confirm instead: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
Question 85
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: An HCP Terraform organization gives all users organization-wide apply privileges for convenience, despite only a small release team needing production access. The workflow must apply least privilege and preserve workspace isolation. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
- Review organization and workspace team roles, run permissions and audit records for sensitive environments.
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
Explanation
Correct Answer
B:Review organization and workspace team roles, run permissions and audit records for sensitive environments. Workspace team permissions separate collaboration from privileged operations and support auditable Terraform governance. A justified correction is: Grant scoped team access with read or plan permissions as appropriate, reserving apply and administration for authorized groups.
Incorrect Answers
A:Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. This inspects hcp terraform policy enforcement governance rather than the reported hcp terraform team permissions and audit trail issue. The decisive investigation is: Review organization and workspace team roles, run permissions and audit records for sensitive environments.
C:Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope. This inspects hcp workspace variable sets share scoped configuration rather than the reported hcp terraform team permissions and audit trail issue. The decisive investigation is: Review organization and workspace team roles, run permissions and audit records for sensitive environments.
D:Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. This inspects hcp terraform remote execution and state hosting rather than the reported hcp terraform team permissions and audit trail issue. The decisive investigation is: Review organization and workspace team roles, run permissions and audit records for sensitive environments.
Question 86
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module receives instance sizes keyed by environment name, but the configuration tries to read them using a numeric position as if they were a list. The engineer must respect declared resource contracts and data security boundaries. Which Terraform configuration or workflow change most directly corrects the described issue?
- Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
- Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
- Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone.
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
Explanation
Correct Answer
B:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. Terraform collection types have distinct semantics: maps are addressed by keys while lists are ordered index-based sequences. Confirm the cause with: Inspect the variable type constraint and the HCL expression used to access its values. A concrete acceptance test is: The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
Incorrect Answers
A:Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring. This could address resource addressing with repeated instances, but it does not correct the indicated map versus list addressing for environment inputs mechanism. The relevant fix is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
C:Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone. This could address sensitive variable does not erase state secrets, but it does not correct the indicated map versus list addressing for environment inputs mechanism. The relevant fix is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
D:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. This could address object type contract with nested attributes, but it does not correct the indicated map versus list addressing for environment inputs mechanism. The relevant fix is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
Question 87
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new attribute value and overlooks deletion risk. The change must preserve the distinction between previewing and modifying infrastructure. Which Terraform configuration or workflow change most directly corrects the described issue?
- Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
- Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
Explanation
Correct Answer
C:Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying. Provider schemas can require replacement for some attribute changes; plan review exposes this before an apply. Confirm the cause with: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. A concrete acceptance test is: The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
Incorrect Answers
A:Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy. This could address plan versus real infrastructure drift, but it does not correct the indicated plan distinguishes replacement from in-place update mechanism. The relevant fix is: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
B:Run terraform init to install and configure referenced child modules before attempting configuration validation. This could address module installation during initial setup, but it does not correct the indicated plan distinguishes replacement from in-place update mechanism. The relevant fix is: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
D:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This could address terraform destroy is managed-scope deletion, but it does not correct the indicated plan distinguishes replacement from in-place update mechanism. The relevant fix is: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
Question 88
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. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
- Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access.
- Routine Terraform output suppresses the marked secret while protected state access remains restricted.
- The root plan resolves the supported module output without attempting to address private child resource internals.
Explanation
Correct Answer
B:Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access. for_each produces keyed instances whose attributes must be accessed by their instance keys or collected expressions. It tests the correction: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
Incorrect Answers
A:Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions. This might validate object type contract with nested attributes, but it does not prove that collection references for for_each resources was resolved. Confirm instead: Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access.
C:Routine Terraform output suppresses the marked secret while protected state access remains restricted. This might validate sensitive output display behavior, but it does not prove that collection references for for_each resources was resolved. Confirm instead: Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access.
D:The root plan resolves the supported module output without attempting to address private child resource internals. This might validate module output references across composition, but it does not prove that collection references for for_each resources was resolved. Confirm instead: Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access.
Question 89
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A root configuration needs a child module's generated network ID but accesses an internal child resource name directly and fails to resolve it. 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.
- Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
- Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
- Inspect the child module output declarations and the root's module block name and available output values.
- Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
Explanation
Correct Answers
A:Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root. Modules expose values to callers through output declarations, creating an explicit interface between implementation and consumers. Confirm the cause with: Inspect the child module output declarations and the root's module block name and available output values. A concrete acceptance test is: The root plan resolves the supported module output without attempting to address private child resource internals. This forms one element of the required two-step diagnosis and correction.
D:Inspect the child module output declarations and the root's module block name and available output values. Modules expose values to callers through output declarations, creating an explicit interface between implementation and consumers. A justified correction is: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. This relates to object type contract with nested attributes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the child module output declarations and the root's module block name and available output values. Then change: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
C:Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. This relates to variable default versus required input rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the child module output declarations and the root's module block name and available output values. Then change: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
E:Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. This relates to collection references for for_each resources rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the child module output declarations and the root's module block name and available output values. Then change: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
Question 90
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A shared Terraform module accepts CIDR strings and a malformed network input reaches provisioning before anyone notices it violates approved addressing conventions. The engineer must respect declared resource contracts and data security boundaries. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
- Review input and output sensitivity declarations and inspect what the plan or output commands will display.
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
- Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.
Explanation
Correct Answers
A:Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. Custom variable validation enforces module input contracts before incorrect values reach resource creation. A justified correction is: Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input. This forms one element of the required two-step diagnosis and correction.
E:Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input. Custom variable validation enforces module input contracts before incorrect values reach resource creation. Confirm the cause with: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. A concrete acceptance test is: An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Review input and output sensitivity declarations and inspect what the plan or output commands will display. This relates to sensitive output display behavior rather than the matching diagnosis-and-remediation pair required here. Check: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. Then change: Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.
C:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This relates to resource precondition for unsafe configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. Then change: Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.
D:Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. This relates to explicit depends_on for behavior-only dependencies rather than the matching diagnosis-and-remediation pair required here. Check: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. Then change: Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.