HashiCorp Terraform Associate 004 Practice Test 43
Question 420
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A team wants additional backup retention only in production but duplicates the entire Terraform module for each environment and the copies diverge. The engineer must respect declared resource contracts and data security boundaries. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
- Inspect the shared attributes and whether one expression can derive a value from the environment input.
- Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
- Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Explanation
Correct Answers
B:Inspect the shared attributes and whether one expression can derive a value from the environment input. Terraform expressions can choose values based on explicit conditions without duplicating full resource definitions. A justified correction is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. This forms one element of the required two-step diagnosis and correction.
C:Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. Terraform expressions can choose values based on explicit conditions without duplicating full resource definitions. Confirm the cause with: Inspect the shared attributes and whether one expression can derive a value from the environment input. A concrete acceptance test is: Development and production plan different approved retention settings with otherwise shared definitions and no copied modules. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Remove or update the overriding variable source and make the intended region input explicit for the controlled run. This relates to variable input precedence and configuration injection rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the shared attributes and whether one expression can derive a value from the environment input. Then change: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
D:Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings. This relates to implicit dependency through resource attribute reference rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the shared attributes and whether one expression can derive a value from the environment input. Then change: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
E:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This relates to for_each stable identity instead of count index rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the shared attributes and whether one expression can derive a value from the environment input. Then change: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
Question 421
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual machine they recently created. The operator must obtain auditable evidence before touching production resources. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.
Explanation
Correct Answers
C:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. Terraform destroy targets the managed resources recorded in the selected state, not only the objects recently added by one operator. Confirm the cause with: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. A concrete acceptance test is: Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state. This forms one element of the required two-step diagnosis and correction. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
E:Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. Terraform destroy targets the managed resources recorded in the selected state, not only the objects recently added by one operator. A justified correction is: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This forms one element of the required two-step diagnosis and correction. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
Incorrect Answers
A:Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This relates to selective cleanup without destroying retained object rather than the matching diagnosis-and-remediation pair required here. Check: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. Then change: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
B:Run terraform init to install and configure referenced child modules before attempting configuration validation. This relates to module installation during initial setup rather than the matching diagnosis-and-remediation pair required here. Check: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. Then change: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
D:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. This relates to apply requires approval unless automated rather than the matching diagnosis-and-remediation pair required here. Check: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. Then change: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
Question 422
During an operational review of a Terraform state backend, the following condition occurs: A Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock immediately without checking whether another run is active. The team must preserve managed-object identity and safe collaboration. Which investigation would most directly establish the reported Terraform failure?
- Compare the refreshed real object with its prior state and declared configuration to identify an outside change.
- Compare old and new resource addresses and verify the provider object is the same logical managed resource.
- Inspect active runs and lock metadata to determine whether another legitimate operation owns the state lock.
- Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
Explanation
Correct Answer
D:Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking. Force-unlocking an active run can allow concurrent writers and damage state integrity; lock ownership must be verified. A justified correction is: Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID. This matters here because a Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock….
Incorrect Answers
A:Compare the refreshed real object with its prior state and declared configuration to identify an outside change. This inspects out-of-band drift detection in managed resource rather than the reported force unlock requires stale-lock verification issue. The decisive investigation is: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
B:Compare old and new resource addresses and verify the provider object is the same logical managed resource. This inspects moved block preserves state during address refactor rather than the reported force unlock requires stale-lock verification issue. The decisive investigation is: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking. This matters here because a Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock….
C:Inspect active runs and lock metadata to determine whether another legitimate operation owns the state lock. This inspects state locking prevents concurrent writes rather than the reported force unlock requires stale-lock verification issue. The decisive investigation is: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
Question 423
During a controlled module integration test for a production Terraform stack, the following condition occurs: An application service needs a policy attachment completed before creating a dependent service, but no attribute reference exists to order the two operations. The desired fix must avoid unrelated resource changes. Which Terraform configuration or workflow change most directly corrects the described issue?
- Provide the required region input through the module call or a supported root variable assignment mechanism.
- Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
- Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
- Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
Explanation
Correct Answer
C:Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. depends_on expresses dependencies that cannot be inferred from configuration values, but unnecessary broad dependencies add conservatism. Confirm the cause with: Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. A concrete acceptance test is: The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: An….
Incorrect Answers
A:Provide the required region input through the module call or a supported root variable assignment mechanism. This could address variable default versus required input, but it does not correct the indicated explicit depends_on for behavior-only dependencies mechanism. The relevant fix is: Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
B:Remove or update the overriding variable source and make the intended region input explicit for the controlled run. This could address variable input precedence and configuration injection, but it does not correct the indicated explicit depends_on for behavior-only dependencies mechanism. The relevant fix is: Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
D:Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated. This could address ignore_changes ownership of externally managed tag, but it does not correct the indicated explicit depends_on for behavior-only dependencies mechanism. The relevant fix is: Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
Question 424
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: An operator deletes terraform.tfstate but keeps all resource blocks, and Terraform proposes creating infrastructure already present under existing object identifiers. The configuration should behave consistently without broadening access. Which investigation would most directly establish the reported Terraform failure?
- Separate plugin resolution logs from runtime API authorization errors and inspect the provider's active identity and scoped permissions.
- Compare state resource addresses to actual remote objects and the active backend's selected state snapshot.
- Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present.
- Examine required_providers version constraints and the selected version recorded in the dependency lock file.
Explanation
Correct Answer
B:Compare state resource addresses to actual remote objects and the active backend's selected state snapshot. Terraform state tracks address-to-object identity; configuration alone does not automatically rediscover arbitrary preexisting objects. A justified correction is: Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: An….
Incorrect Answers
A:Separate plugin resolution logs from runtime API authorization errors and inspect the provider's active identity and scoped permissions. This inspects provider authorization versus installation failure rather than the reported state binding between resource address and remote object issue. The decisive investigation is: Compare state resource addresses to actual remote objects and the active backend's selected state snapshot.
C: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 state binding between resource address and remote object issue. The decisive investigation is: Compare state resource addresses to actual remote objects and the active backend's selected state snapshot.
D:Examine required_providers version constraints and the selected version recorded in the dependency lock file. This inspects provider version range semantics rather than the reported state binding between resource address and remote object issue. The decisive investigation is: Compare state resource addresses to actual remote objects and the active backend's selected state snapshot.
Question 425
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A novice team runs terraform apply in a directory containing unreviewed edits and cannot explain the difference between proposed and actual resource changes. The change must preserve the distinction between previewing and modifying infrastructure. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
- Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply.
- Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
- Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource.
Explanation
Correct Answer
C:Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. Terraform's normal lifecycle separates desired-state authoring and plan evaluation from the operation that changes managed infrastructure. A justified correction is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A novice team runs….
Incorrect Answers
A:Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. This inspects terraform fmt normalizes hcl style rather than the reported core write plan apply workflow order issue. The decisive investigation is: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
B:Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply. This inspects terraform validate versus cloud permission testing rather than the reported core write plan apply workflow order issue. The decisive investigation is: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
D:Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource. This inspects workflow repeatability after configuration change rather than the reported core write plan apply workflow order issue. The decisive investigation is: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A novice team runs….
Question 426
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A repository is cloned into a new runner, and terraform plan fails before generating changes because the workspace has not initialized provider plugins or its backend. The change must preserve the distinction between previewing and modifying infrastructure. Select TWO: the decisive first check and the change that directly addresses the problem.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Inspect the .terraform working directory and initialization output for missing backend, module, and provider setup.
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
- Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
Explanation
Correct Answers
A:Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. The init command prepares backend configuration and downloads needed providers/modules; it does not create managed resources by itself. Confirm the cause with: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. A concrete acceptance test is: The runner completes initialization and can calculate a plan using the intended backend and installed dependencies. This forms one element of the required two-step diagnosis and correction.
C:Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. The init command prepares backend configuration and downloads needed providers/modules; it does not create managed resources by itself. A justified correction is: Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This relates to terraform destroy is managed-scope deletion rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. Then change: Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
D:Run terraform init to install and configure referenced child modules before attempting configuration validation. This relates to module installation during initial setup rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. Then change: Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
E:Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. This relates to plan distinguishes replacement from in-place update rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. Then change: Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
Question 427
During a separate-region Terraform rollout in an approved staging account, 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 configuration should behave consistently without broadening access. What measurable postchange observation would confirm that the correction worked?
- Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
- The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates.
- The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
- The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
Explanation
Correct Answer
C:The plan identifies production-account resources under the intended provider configuration while development objects remain separate. A provider alias selects an alternate configured provider instance; resource blocks must reference it to avoid a default-account fallback. It tests the correction: Define explicitly aliased provider configurations and assign the production resource to the intended alias. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A….
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 provider alias for multiple accounts was resolved. Confirm instead: The plan identifies production-account resources under the intended provider configuration while development objects remain separate. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A….
B:The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates. This might validate controlled provider upgrade using init upgrade, but it does not prove that provider alias for multiple accounts was resolved. Confirm instead: The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
D:The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state. This might validate resource attribute outputs supplied by state, but it does not prove that provider alias for multiple accounts was resolved. Confirm instead: The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
Question 428
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual machine they recently created. The operator must obtain auditable evidence before touching production resources. Which investigation would most directly establish the reported Terraform failure?
- Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.
- Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure.
- Inspect whether the approved artifact was produced by terraform plan -out and whether apply consumes exactly that plan artifact.
- Inspect Terraform diagnostic output for undeclared input references and compare declared variable names to expressions.
Explanation
Correct Answer
A:Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. Terraform destroy targets the managed resources recorded in the selected state, not only the objects recently added by one operator. A justified correction is: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
Incorrect Answers
B:Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. This inspects selective cleanup without destroying retained object rather than the reported terraform destroy is managed-scope deletion issue. The decisive investigation is: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
C:Inspect whether the approved artifact was produced by terraform plan -out and whether apply consumes exactly that plan artifact. This inspects saved execution plan for controlled deployment rather than the reported terraform destroy is managed-scope deletion issue. The decisive investigation is: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.
D:Inspect Terraform diagnostic output for undeclared input references and compare declared variable names to expressions. This inspects terraform validate catches undeclared reference rather than the reported terraform destroy is managed-scope deletion issue. The decisive investigation is: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.
Question 429
During a cross-platform infrastructure standardization exercise, the following condition occurs: Developers assume a Terraform virtual machine resource from cloud A can be copied unchanged into cloud B just because the configuration language is the same. The decision must preserve ownership and minimize undocumented changes. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Compare the runbook's procedural steps with a version-controlled declarative inventory of desired resources and their attributes.
- Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
- Inspect provider source requirements, authentication scopes, and whether the on-premises and hosted platforms expose different APIs.
- Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally.
Explanation
Correct Answer
B:Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces. Terraform's common workflow does not make different cloud vendor APIs or resource type attributes interchangeable. A justified correction is: Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
Incorrect Answers
A:Compare the runbook's procedural steps with a version-controlled declarative inventory of desired resources and their attributes. This inspects declarative desired state versus imperative console runbook rather than the reported provider-neutral infrastructure pattern without identical resource types issue. The decisive investigation is: Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
C:Inspect provider source requirements, authentication scopes, and whether the on-premises and hosted platforms expose different APIs. This inspects hybrid cloud workflow with distinct provider credentials rather than the reported provider-neutral infrastructure pattern without identical resource types issue. The decisive investigation is: Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
D:Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally. This inspects reusable environment definitions and reduced configuration drift rather than the reported provider-neutral infrastructure pattern without identical resource types issue. The decisive investigation is: Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
Question 430
When maintaining Terraform modules used by several application teams, the following condition occurs: A child Terraform module refers directly to var.environment declared only in its parent, causing a missing-variable diagnostic. The module interface must remain stable and reviewable. What measurable postchange observation would confirm that the correction worked?
- The child module files are located consistently by local and CI runs without copying the same definitions into the root.
- The child module receives the intended environment value without accessing variables declared only in its caller.
- Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it.
- The caller can reference the exact authorized network ID without using private child implementation resource addresses.
Explanation
Correct Answer
B:The child module receives the intended environment value without accessing variables declared only in its caller. Input variables are scoped to their modules and must cross a module boundary through an explicit interface. It tests the correction: Declare an input variable in the child module and pass the parent's value explicitly as a module argument. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A child….
Incorrect Answers
A:The child module files are located consistently by local and CI runs without copying the same definitions into the root. This might validate local child module source path resolution, but it does not prove that root and child variable scope isolation was resolved. Confirm instead: The child module receives the intended environment value without accessing variables declared only in its caller.
C:Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it. This might validate module outputs coordinate dependencies instead of duplicate data, but it does not prove that root and child variable scope isolation was resolved. Confirm instead: The child module receives the intended environment value without accessing variables declared only in its caller.
D:The caller can reference the exact authorized network ID without using private child implementation resource addresses. This might validate child output exposure to calling module, but it does not prove that root and child variable scope isolation was resolved. Confirm instead: The child module receives the intended environment value without accessing variables declared only in its caller. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A child….