100% Latest & Updated HashiCorp Terraform Associate 004 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 10
A Terraform platform team is coordinating 3 independent decisions. Workstream A: Two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules. and Workstream B: A module uses a provider data source to find the newest image and a resource block to launch a VM from its returned identifier. and Workstream C: A child module must receive two non-default provider aliases for cross-region VPN creation. Select exactly 3 actions, one addressing each distinct workstream.
- Declare aliases in the child required_providers and explicitly pass both in the parent module.providers mapping.
- Create an appropriately scoped HCP Terraform variable set applied to those project workspaces.
- Interpret the refreshed plan as detected drift and decide whether to restore declared tags or intentionally update configuration.
- Confirm there is no current state writer, then use force-unlock only for the team's own stale lock ID.
- Reference the selected data source attribute in the managed resource's image argument.
- Reuse one reviewed Terraform module with explicit environment inputs instead of independently editing each deployment.
Explanation
Correct Answers
A:For the workstream in which a child module must receive two non-default provider aliases for cross-region VPN creation, use this action: Declare aliases in the child required_providers and explicitly pass both in the parent module.providers mapping. Cross-region reusable modules should receive provider configurations from the caller. Verify: The child's plan uses the two exact provider instances rather than silently defaulting to one region. Limitation: An alias without a corresponding provider mapping is not inherited automatically.
E:For the workstream in which a module uses a provider data source to find the newest image and a resource block to launch a VM from its returned identifier, use this action: Reference the selected data source attribute in the managed resource's image argument. Data sources provide read-only values that can feed managed resource configuration. Verify: The plan resolves the image lookup and uses its ID in the VM resource configuration. Limitation: An automatically changing latest-image lookup may propose later VM replacements depending on resource schema.
F:For the workstream in which two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules, use this action: Reuse one reviewed Terraform module with explicit environment inputs instead of independently editing each deployment. Reusable reviewed IaC reduces manual divergence while retaining deliberate differences through inputs. Verify: Review version-control diffs and compare planned firewall changes for both environments. Limitation: Shared code needs safe parameterization and review, or the same erroneous rule can propagate everywhere.
Incorrect Answers
B:This action is appropriate instead for a different, unlisted requirement: A platform administrator must reuse one nonsecret provider configuration variable across multiple workspaces in the same HCP project. It would be checked by: New and existing workspaces in the project receive the intended shared variable. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
C:This action is appropriate instead for a different, unlisted requirement: An operations team edits cloud VM tags manually, and normal Terraform plan shows an unexpected change even though HCL has not changed. It would be checked by: The reviewed plan explains which observed remote attributes differ from desired HCL. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
D:This action is appropriate instead for a different, unlisted requirement: A Terraform job crashed and left a stale lock, but the team has not verified whether any other run is active. It would be checked by: State operations resume without releasing a lock held by an active independent job. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
Question 11
An infrastructure team faces this specific situation: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. Which Terraform action most directly satisfies the requirement?
- Select suitable Azure and monitoring providers and declare both systems through one Terraform root module.
- Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies.
- Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state.
- Reuse one reviewed Terraform module with explicit environment inputs instead of independently editing each deployment.
Explanation
Correct Answer
B:Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. Terraform's provider model unifies the workflow while delegating API interactions to platform-specific plugins. Verify: A single plan lists the intended private and public resource actions under their respective providers. Limitation: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions.
Incorrect Answers
A:This is linked to a different situation: A company uses Azure for application workloads and a SaaS provider for monitoring, and wants to avoid managing two separate IaC languages. There the relevant decision is: Select suitable Azure and monitoring providers and declare both systems through one Terraform root module. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant decision is: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. There the relevant decision is: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant decision is: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: Two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules. There the relevant decision is: Reuse one reviewed Terraform module with explicit environment inputs instead of independently editing each deployment. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant decision is: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. It would therefore not resolve or assess the case as stated.
Question 12
A reviewer is confirming a change for the following use case: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. The implementation follows this approach: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. Which observation or acceptance test most directly verifies the intended result?
- The plan and state distinguish managed resource instances from unmanaged manual purchases.
- A single plan lists the intended private and public resource actions under their respective providers.
- Review version-control diffs and compare planned firewall changes for both environments.
- A pull request includes configuration differences and a plan describing expected resource mutations.
Explanation
Correct Answer
B:Acceptance evidence: A single plan lists the intended private and public resource actions under their respective providers. It validates the proposed action, declare resources through separate compatible providers in one Terraform configuration, with references for dependencies, because terraform's provider model unifies the workflow while delegating API interactions to platform-specific plugins. Remaining limitation: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions.
Incorrect Answers
A:This is linked to a different situation: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. There the relevant acceptance is: The plan and state distinguish managed resource instances from unmanaged manual purchases. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant acceptance is: A single plan lists the intended private and public resource actions under their respective providers. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: Two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules. There the relevant acceptance is: Review version-control diffs and compare planned firewall changes for both environments. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant acceptance is: A single plan lists the intended private and public resource actions under their respective providers. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant acceptance is: A pull request includes configuration differences and a plan describing expected resource mutations. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant acceptance is: A single plan lists the intended private and public resource actions under their respective providers. It would therefore not resolve or assess the case as stated.
Question 13
Consider a proposed solution for this requirement: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. The team plans to do the following: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. Which limitation or operational caveat must remain in the review?
- Shared code needs safe parameterization and review, or the same erroneous rule can propagate everywhere.
- A plan is a snapshot of observed state and can become stale before apply.
- Each endpoint still needs its own supported provider, authentication, connectivity, and permissions.
- Provider APIs and credentials are still required; merely storing HCL does not make the environment provision itself.
Explanation
Correct Answer
C:The limitation is each endpoint still needs its own supported provider, authentication, connectivity, and permissions. The proposed change is declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. Validate it by checking a single plan lists the intended private and public resource actions under their respective providers. Terraform's provider model unifies the workflow while delegating API interactions to platform-specific plugins.
Incorrect Answers
A:This is linked to a different situation: Two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules. There the relevant limitation is: Shared code needs safe parameterization and review, or the same erroneous rule can propagate everywhere. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant limitation is: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant limitation is: A plan is a snapshot of observed state and can become stale before apply. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant limitation is: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: A university repeats a six-network, three-environment build by copying screenshots of console clicks, and auditors cannot reconstruct which settings produced the last deployment. There the relevant limitation is: Provider APIs and credentials are still required; merely storing HCL does not make the environment provision itself. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant limitation is: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions. It would therefore not resolve or assess the case as stated.
Question 14
The team is reviewing a Terraform implementation for this case: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. Which tempting assumption would be specifically incorrect for this proposed implementation?
- Assume copying a completed infrastructure console screenshot eliminates environment drift.
- Assume one generic Terraform API can manage every remote platform without provider plugins.
- Treat an undocumented click sequence as a reproducible declarative infrastructure definition.
- Equate a clean git diff with proof that no remote resource changes will be planned.
Explanation
Correct Answer
B:Reject the assumption: Assume one generic Terraform API can manage every remote platform without provider plugins. Instead, declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. Terraform's provider model unifies the workflow while delegating API interactions to platform-specific plugins. Acceptance evidence: A single plan lists the intended private and public resource actions under their respective providers.
Incorrect Answers
A:This is linked to a different situation: Two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules. There the relevant misconception is: Assume copying a completed infrastructure console screenshot eliminates environment drift. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant misconception is: Assume one generic Terraform API can manage every remote platform without provider plugins. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: A university repeats a six-network, three-environment build by copying screenshots of console clicks, and auditors cannot reconstruct which settings produced the last deployment. There the relevant misconception is: Treat an undocumented click sequence as a reproducible declarative infrastructure definition. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant misconception is: Assume one generic Terraform API can manage every remote platform without provider plugins. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant misconception is: Equate a clean git diff with proof that no remote resource changes will be planned. For the question's actual requirement — A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. — the specifically relevant misconception is: Assume one generic Terraform API can manage every remote platform without provider plugins. It would therefore not resolve or assess the case as stated.
Question 15
A Terraform platform team is coordinating 2 independent decisions. Workstream A: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. and Workstream B: A database security group must be passed into a managed database resource without copying IDs into hardcoded variables. Select exactly 2 actions, one addressing each distinct workstream.
- Declare one backend block inside terraform and reinitialize the working directory.
- Use terraform validate against initialized providers to catch unsupported or missing arguments.
- Use the cloud integration block for workspace mapping and authenticate with terraform login securely.
- Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies.
- Reference the security group resource attribute directly from the database argument.
Explanation
Correct Answers
D:For the workstream in which a logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release, use this action: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. Terraform's provider model unifies the workflow while delegating API interactions to platform-specific plugins. Verify: A single plan lists the intended private and public resource actions under their respective providers. Limitation: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions.
E:For the workstream in which a database security group must be passed into a managed database resource without copying IDs into hardcoded variables, use this action: Reference the security group resource attribute directly from the database argument. Cross-resource references connect outputs to inputs and usually create implicit dependencies. Verify: Terraform's graph records the dependency and plans the database with the correct group identifier. Limitation: An attribute may be unknown until apply, but Terraform can still preserve the dependency graph.
Incorrect Answers
A:This option addresses a separate requirement: A new environment needs to save state in a specific shared backend, and the team attempts to write backend settings under a resource block. Evidence for that other requirement would be terraform init reports the selected backend and plan reads the correct shared state; neither listed workstream asks for it.
B:This option addresses a separate requirement: A commit is syntactically valid HCL but includes a resource argument not supported by the installed provider schema. Evidence for that other requirement would be validation reports schema errors without making changes to remote infrastructure; neither listed workstream asks for it.
C:This option addresses a separate requirement: A local Terraform root must be connected to a specific HCP Terraform workspace without storing an API token in version control. Evidence for that other requirement would be cLI commands authenticate to the correct HCP organization/workspace and work with managed remote state; neither listed workstream asks for it.
Question 16
An infrastructure team faces this specific situation: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. Which Terraform action most directly satisfies the requirement?
- Describe the desired networks and dependencies in versioned Terraform configuration and review plans before applying.
- Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies.
- Review the HCL change through version control and inspect a Terraform execution plan before authorized apply.
- Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state.
Explanation
Correct Answer
D:Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. Declarative configuration describes desired objects; state connects configuration addresses to real infrastructure instances. Verify: The plan and state distinguish managed resource instances from unmanaged manual purchases. Limitation: An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow.
Incorrect Answers
A:This is linked to a different situation: A university repeats a six-network, three-environment build by copying screenshots of console clicks, and auditors cannot reconstruct which settings produced the last deployment. There the relevant decision is: Describe the desired networks and dependencies in versioned Terraform configuration and review plans before applying. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant decision is: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. There the relevant decision is: Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant decision is: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant decision is: Review the HCL change through version control and inspect a Terraform execution plan before authorized apply. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant decision is: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. It would therefore not resolve or assess the case as stated.
Question 17
A reviewer is confirming a change for the following use case: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. The implementation follows this approach: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. Which observation or acceptance test most directly verifies the intended result?
- A single plan lists the intended private and public resource actions under their respective providers.
- A pull request includes configuration differences and a plan describing expected resource mutations.
- The plan and state distinguish managed resource instances from unmanaged manual purchases.
- Plan output contains the cloud deployment and monitoring integrations with clear provider ownership.
Explanation
Correct Answer
C:Acceptance evidence: The plan and state distinguish managed resource instances from unmanaged manual purchases. It validates the proposed action, use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state, because declarative configuration describes desired objects; state connects configuration addresses to real infrastructure instances. Remaining limitation: An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow.
Incorrect Answers
A:This is linked to a different situation: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. There the relevant acceptance is: A single plan lists the intended private and public resource actions under their respective providers. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant acceptance is: The plan and state distinguish managed resource instances from unmanaged manual purchases. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant acceptance is: A pull request includes configuration differences and a plan describing expected resource mutations. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant acceptance is: The plan and state distinguish managed resource instances from unmanaged manual purchases. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: A company uses Azure for application workloads and a SaaS provider for monitoring, and wants to avoid managing two separate IaC languages. There the relevant acceptance is: Plan output contains the cloud deployment and monitoring integrations with clear provider ownership. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant acceptance is: The plan and state distinguish managed resource instances from unmanaged manual purchases. It would therefore not resolve or assess the case as stated.
Question 18
Consider a proposed solution for this requirement: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. The team plans to do the following: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. Which limitation or operational caveat must remain in the review?
- An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow.
- Each endpoint still needs its own supported provider, authentication, connectivity, and permissions.
- A plan is a snapshot of observed state and can become stale before apply.
- Shared code needs safe parameterization and review, or the same erroneous rule can propagate everywhere.
Explanation
Correct Answer
A:The limitation is an IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow. The proposed change is use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. Validate it by checking the plan and state distinguish managed resource instances from unmanaged manual purchases. Declarative configuration describes desired objects; state connects configuration addresses to real infrastructure instances.
Incorrect Answers
B:This is linked to a different situation: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. There the relevant limitation is: Each endpoint still needs its own supported provider, authentication, connectivity, and permissions. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant limitation is: An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant limitation is: A plan is a snapshot of observed state and can become stale before apply. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant limitation is: An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: Two branches of a retailer deploy similar staging clusters, but each hand-built cluster gradually acquires different firewall rules. There the relevant limitation is: Shared code needs safe parameterization and review, or the same erroneous rule can propagate everywhere. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant limitation is: An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow. It would therefore not resolve or assess the case as stated.
Question 19
The team is reviewing a Terraform implementation for this case: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. Which tempting assumption would be specifically incorrect for this proposed implementation?
- Assume one generic Terraform API can manage every remote platform without provider plugins.
- Expect an Azure resource block to manage an unrelated SaaS API without that service's provider.
- Assume naming a server in a text file automatically imports that already-existing server into state.
- Equate a clean git diff with proof that no remote resource changes will be planned.
Explanation
Correct Answer
C:Reject the assumption: Assume naming a server in a text file automatically imports that already-existing server into state. Instead, use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. Declarative configuration describes desired objects; state connects configuration addresses to real infrastructure instances. Acceptance evidence: The plan and state distinguish managed resource instances from unmanaged manual purchases.
Incorrect Answers
A:This is linked to a different situation: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. There the relevant misconception is: Assume one generic Terraform API can manage every remote platform without provider plugins. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant misconception is: Assume naming a server in a text file automatically imports that already-existing server into state. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A company uses Azure for application workloads and a SaaS provider for monitoring, and wants to avoid managing two separate IaC languages. There the relevant misconception is: Expect an Azure resource block to manage an unrelated SaaS API without that service's provider. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant misconception is: Assume naming a server in a text file automatically imports that already-existing server into state. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: An operations group wants four engineers to propose a subnet change without all four immediately modifying production. There the relevant misconception is: Equate a clean git diff with proof that no remote resource changes will be planned. For the question's actual requirement — An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. — the specifically relevant misconception is: Assume naming a server in a text file automatically imports that already-existing server into state. It would therefore not resolve or assess the case as stated.
Question 20
A Terraform platform team is coordinating 3 independent decisions. Workstream A: An audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure. and Workstream B: A module uses for_each on a map of regions and must output one subnet ID for the us-east-1 instance. and Workstream C: A registry module release contains an urgent fix and the team's installed module is still the previous compatible release. Select exactly 3 actions, one addressing each distinct workstream.
- Index the resource collection by its actual for_each key rather than assuming numeric list positions.
- Back up state, configure HCP cloud integration, and follow the prompted state migration during initialization.
- Run a refresh-only plan, review its state changes, and apply refresh-only if the update is appropriate.
- Distinguish provider-version lock metadata from terraform.tfstate and protect the actual state through suitable backend controls.
- Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state.
- Review the intended registry release and run terraform init -upgrade after updating constraints as needed.
Explanation
Correct Answers
A:For the workstream in which a module uses for_each on a map of regions and must output one subnet ID for the us-east-1 instance, use this action: Index the resource collection by its actual for_each key rather than assuming numeric list positions. for_each resources are addressed using keys, whereas count resources use numeric indices. Verify: The evaluated expression points to the correct keyed instance address in the plan. Limitation: Keys must exist and be stable; renaming a key may change addresses and induce replacement.
E:For the workstream in which an audit team asks whether applying a YAML-looking file automatically turns ad hoc server purchases into managed infrastructure, use this action: Use a Terraform root module that explicitly declares tracked resources and reconcile it through Terraform state. Declarative configuration describes desired objects; state connects configuration addresses to real infrastructure instances. Verify: The plan and state distinguish managed resource instances from unmanaged manual purchases. Limitation: An IaC repository alone cannot retroactively adopt existing objects without an import or equivalent workflow.
F:For the workstream in which a registry module release contains an urgent fix and the team's installed module is still the previous compatible release, use this action: Review the intended registry release and run terraform init -upgrade after updating constraints as needed. Module upgrade changes downloaded code, not state ownership by itself. Verify: The initialized module source matches the new permitted version and the resulting plan is reviewed. Limitation: An upgrade may change resources and output interfaces; it needs an impact review before apply.
Incorrect Answers
B:This action is appropriate instead for a different, unlisted requirement: A team is migrating existing local state into HCP Terraform and wants to avoid accidental duplicate resource creation. It would be checked by: The HCP workspace contains the existing managed addresses after migration and normal plan does not re-create all resources. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
C:This action is appropriate instead for a different, unlisted requirement: A company intentionally altered remote settings and wants Terraform state to reflect the real objects without proposing configuration-driven remediation yet. It would be checked by: State and root outputs synchronize with observed remote data without changing the cloud object itself. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
D:This action is appropriate instead for a different, unlisted requirement: A team considers keeping .terraform.lock.hcl in a secrets vault because it thinks the file is the primary infrastructure state store. It would be checked by: Inspection shows the lock file describes plugin versions while state records resource attributes and bindings. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests