HashiCorp Terraform Associate 004 Practice Test 52
Question 510
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 diagnostic check provides the strongest evidence for the underlying problem?
- Check the selected backend's documentation for locking support and the actual concurrent-apply behavior.
- Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
- Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
Explanation
Correct Answer
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.
Incorrect Answers
A:Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. This inspects backend-specific state locking support rather than the reported local workspace state separation issue. The decisive investigation is: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
C:Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications. This inspects refresh-only state update without infrastructure mutation rather than the reported local workspace state separation issue. The decisive investigation is: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
D:Inspect the backend configuration and state file location on each workstation to identify local state behavior. This inspects local backend path and exposure rather than the reported local workspace state separation issue. The decisive investigation is: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
Question 511
During an operational review of a Terraform state backend, the following condition occurs: An engineer passes a remote state storage key through plaintext -backend-config arguments in a shared build log and assumes Terraform will never retain that key. The team must preserve managed-object identity and safe collaboration. What measurable postchange observation would confirm that the correction worked?
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
- Initialization connects to the intended workspace without conflicting backend configurations or unintended state copies.
- Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot.
- Concurrent runs against the same state are serialized according to the backend's supported locking contract.
Explanation
Correct Answer
A:Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs. Backend configuration can be captured in Terraform working-directory metadata and plan files; secret-bearing arguments require extra care. It tests the correction: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
Incorrect Answers
B:Initialization connects to the intended workspace without conflicting backend configurations or unintended state copies. This might validate hcp cloud integration versus remote backend, but it does not prove that backend credentials kept out of plan artifacts was resolved. Confirm instead: Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
C:Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot. This might validate state locking prevents concurrent writes, but it does not prove that backend credentials kept out of plan artifacts was resolved. Confirm instead: Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
D:Concurrent runs against the same state are serialized according to the backend's supported locking contract. This might validate backend-specific state locking support, but it does not prove that backend credentials kept out of plan artifacts was resolved. Confirm instead: Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
Question 512
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: An engineer embeds cloud credentials inside required_providers and expects Terraform to authenticate because the source and version were specified there. The configuration should behave consistently without broadening access. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
- Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
- Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin.
- Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present.
- Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials.
Explanation
Correct Answers
B:Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. Plugin installation requirements and runtime provider configuration are different parts of Terraform's execution model. A justified correction is: Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials. This forms one element of the required two-step diagnosis and correction.
E:Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials. Plugin installation requirements and runtime provider configuration are different parts of Terraform's execution model. Confirm the cause with: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. A concrete acceptance test is: Initialization installs the intended plugin and authenticated operations use the proper provider configuration without credentials in version declarations. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A: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: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. Then change: Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials.
C:Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin. This relates to provider authorization versus installation failure rather than the matching diagnosis-and-remediation pair required here. Check: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. Then change: Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials.
D:Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present. This relates to state as sensitive operational metadata rather than the matching diagnosis-and-remediation pair required here. Check: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. Then change: Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials.
Question 513
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive terraform apply prompts for confirmation, but an engineer assumes it is a failed deployment because no resources changed immediately. The change must preserve the distinction between previewing and modifying infrastructure. Which Terraform configuration or workflow change most directly corrects the described issue?
- Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content.
- Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
- Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility.
- Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
Explanation
Correct Answer
D:Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. A normal interactive Terraform apply requires an approval decision; automating approval changes governance, not Terraform's reconciliation rules. Confirm the cause with: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. A concrete acceptance test is: The apply finishes after explicit approval and writes the updated resource bindings to the configured backend. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive….
Incorrect Answers
A:Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content. This could address saved execution plan for controlled deployment, but it does not correct the indicated apply requires approval unless automated mechanism. The relevant fix is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
B:Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment. This could address targeted apply limitations for normal changes, but it does not correct the indicated apply requires approval unless automated mechanism. The relevant fix is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive….
C:Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility. This could address terraform validate versus cloud permission testing, but it does not correct the indicated apply requires approval unless automated mechanism. The relevant fix is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
Question 514
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A root output refers to the ID of a resource just created, yet another workflow assumes the string is known before the apply finishes. The configuration should behave consistently without broadening access. Which outcome most directly validates the intended fix?
- Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
- The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
- Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.
- Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses.
Explanation
Correct Answer
B:The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state. State stores known provider-returned attributes and supports dependency references; some values remain unknown until apply. It tests the correction: Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A root….
Incorrect Answers
A:Read and write operations in one account do not gain unnecessary authorization to unrelated account resources. This might validate multiple provider instances requiring separate authentication, but it does not prove that resource attribute outputs supplied by state was resolved. Confirm instead: The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
C:Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure. This might validate state as sensitive operational metadata, but it does not prove that resource attribute outputs supplied by state was resolved. Confirm instead: The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
D:Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses. This might validate provider source requirement declaration, but it does not prove that resource attribute outputs supplied by state was resolved. Confirm instead: The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
Question 515
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A Terraform directory configures two accounts of the same platform but the provider blocks share a broad credential so the blast radius is unclear. The engineers must keep provider choices and identities reproducible. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect provider alias identities, authentication scopes, and which modules or resources select each instance.
- Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present.
- Inspect the resource type prefixes and required_providers source mappings before running terraform init.
- Review the child module provider requirements and root module providers mapping for the child call.
Explanation
Correct Answer
A:Inspect provider alias identities, authentication scopes, and which modules or resources select each instance. Multiple provider configurations can share a plugin while representing distinct authenticated API clients. A justified correction is: Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
Incorrect Answers
B:Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present. This inspects state as sensitive operational metadata rather than the reported multiple provider instances requiring separate authentication issue. The decisive investigation is: Inspect provider alias identities, authentication scopes, and which modules or resources select each instance.
C:Inspect the resource type prefixes and required_providers source mappings before running terraform init. This inspects provider plugin manages api resources and data reads rather than the reported multiple provider instances requiring separate authentication issue. The decisive investigation is: Inspect provider alias identities, authentication scopes, and which modules or resources select each instance.
D: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 multiple provider instances requiring separate authentication issue. The decisive investigation is: Inspect provider alias identities, authentication scopes, and which modules or resources select each instance.
Question 516
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An organization switches from local state to a remote backend, but its existing Terraform work directory still points to the former backend settings. The change must preserve the distinction between previewing and modifying infrastructure. Which proposed remediation solves this failure without masking its cause?
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
- Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
- Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content.
Explanation
Correct Answer
B:Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups. Changing backend configuration requires a deliberate reinitialization decision; a text edit alone does not migrate state safely. Confirm the cause with: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. A concrete acceptance test is: The working directory uses the approved remote backend and the existing managed resource bindings remain available without duplicate provisioning. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An organization….
Incorrect Answers
A:Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This could address selective cleanup without destroying retained object, but it does not correct the indicated reinitializing after backend configuration change mechanism. The relevant fix is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
C:Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. This could address terraform init backend and provider preparation, but it does not correct the indicated reinitializing after backend configuration change mechanism. The relevant fix is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An organization….
D:Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content. This could address saved execution plan for controlled deployment, but it does not correct the indicated reinitializing after backend configuration change mechanism. The relevant fix is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
Question 517
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A team wants Terraform to stop managing a legacy storage bucket but must retain the real bucket and its contents for a migration. The operator must obtain auditable evidence before touching production resources. Which outcome most directly validates the intended fix?
- Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified.
- A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action.
- Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state.
- The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
Explanation
Correct Answer
D:The state no longer tracks the bucket and verification confirms the remote bucket and data still exist. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. It tests the correction: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
Incorrect Answers
A:Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified. This might validate terraform validate versus cloud permission testing, but it does not prove that selective cleanup without destroying retained object was resolved. Confirm instead: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
B:A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action. This might validate workflow repeatability after configuration change, but it does not prove that selective cleanup without destroying retained object was resolved. Confirm instead: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
C:Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state. This might validate terraform destroy is managed-scope deletion, but it does not prove that selective cleanup without destroying retained object was resolved. Confirm instead: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
Question 518
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform engineer moves a resource from root to a child module and the next plan offers to destroy the old address and create the same remote object at a new address. The operation must not delete or duplicate existing production objects. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Add a moved block mapping the old address to the new address before running a reviewed plan.
- Inspect the current terraform backend declaration and permissions for the selected shared backend service.
- Compare old and new resource addresses and verify the provider object is the same logical managed resource.
- Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
- Select the intended workspace before planning and check the corresponding workspace-specific state directory.
Explanation
Correct Answers
A:Add a moved block mapping the old address to the new address before running a reviewed plan. Configuration address refactoring requires a state mapping; moved blocks declare that logical migration without recreating infrastructure. Confirm the cause with: Compare old and new resource addresses and verify the provider object is the same logical managed resource. A concrete acceptance test is: The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement. This forms one element of the required two-step diagnosis and correction. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform….
C:Compare old and new resource addresses and verify the provider object is the same logical managed resource. Configuration address refactoring requires a state mapping; moved blocks declare that logical migration without recreating infrastructure. A justified correction is: Add a moved block mapping the old address to the new address before running a reviewed plan. This forms one element of the required two-step diagnosis and correction. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform….
Incorrect Answers
B:Inspect the current terraform backend declaration and permissions for the selected shared backend service. This relates to remote backend block configuration rather than the matching diagnosis-and-remediation pair required here. Check: Compare old and new resource addresses and verify the provider object is the same logical managed resource. Then change: Add a moved block mapping the old address to the new address before running a reviewed plan. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform….
D:Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change. This relates to out-of-band drift detection in managed resource rather than the matching diagnosis-and-remediation pair required here. Check: Compare old and new resource addresses and verify the provider object is the same logical managed resource. Then change: Add a moved block mapping the old address to the new address before running a reviewed plan. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform….
E:Select the intended workspace before planning and check the corresponding workspace-specific state directory. This relates to local workspace state separation rather than the matching diagnosis-and-remediation pair required here. Check: Compare old and new resource addresses and verify the provider object is the same logical managed resource. Then change: Add a moved block mapping the old address to the new address before running a reviewed plan.
Question 519
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A team configures remote object storage for state and assumes every backend automatically provides the same distributed locking guarantees. The operation must not delete or duplicate existing production objects. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Select a backend with supported state-locking capabilities and configure its required access controls appropriately.
- Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- Check the selected backend's documentation for locking support and the actual concurrent-apply behavior.
- Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
Explanation
Correct Answers
A:Select a backend with supported state-locking capabilities and configure its required access controls appropriately. Remote storage and robust state locking are related but distinct backend capabilities; locking depends on backend implementation. Confirm the cause with: Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. A concrete acceptance test is: Concurrent runs against the same state are serialized according to the backend's supported locking contract. This forms one element of the required two-step diagnosis and correction. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A team configures….
D:Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. Remote storage and robust state locking are related but distinct backend capabilities; locking depends on backend implementation. A justified correction is: Select a backend with supported state-locking capabilities and configure its required access controls appropriately. This forms one element of the required two-step diagnosis and correction. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A team configures….
Incorrect Answers
B:Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications. This relates to refresh-only state update without infrastructure mutation rather than the matching diagnosis-and-remediation pair required here. Check: Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. Then change: Select a backend with supported state-locking capabilities and configure its required access controls appropriately.
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: Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. Then change: Select a backend with supported state-locking capabilities and configure its required access controls appropriately.
E:Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. This relates to remote backend block configuration rather than the matching diagnosis-and-remediation pair required here. Check: Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. Then change: Select a backend with supported state-locking capabilities and configure its required access controls appropriately.
Question 520
In a clean CI runner initializing a Terraform root configuration, 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 engineers must keep provider choices and identities reproducible. Select TWO: the decisive first check and the change that directly addresses the problem.
- Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
- Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
- Examine required_providers version constraints and the selected version recorded in the dependency lock file.
- Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
- Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again.
Explanation
Correct Answers
C:Examine required_providers version constraints and the selected version recorded in the dependency lock file. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. A justified correction is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. 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 project intended….
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 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 project intended….
Incorrect Answers
A:Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. This relates to provider block credentials versus required_providers rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
B:Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID. This relates to resource attribute outputs supplied by state rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
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: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.