HashiCorp Terraform Associate 004 Practice Test 56
Question 550
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A compliance controller adds a standard cost tag after provisioning and each Terraform plan tries to revert the independently managed tag. The engineer must respect declared resource contracts and data security boundaries. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the shared attributes and whether one expression can derive a value from the environment input.
- Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
- Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
- Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
Explanation
Correct Answer
C:Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift. ignore_changes omits configured attribute differences from update decisions and should not be a blanket excuse to hide drift. A justified correction is: Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A….
Incorrect Answers
A:Inspect the shared attributes and whether one expression can derive a value from the environment input. This inspects conditional expressions for environment configuration rather than the reported ignore_changes ownership of externally managed tag issue. The decisive investigation is: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
B:Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. This inspects explicit depends_on for behavior-only dependencies rather than the reported ignore_changes ownership of externally managed tag issue. The decisive investigation is: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
D:Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. This inspects input variable custom validation rule rather than the reported ignore_changes ownership of externally managed tag issue. The decisive investigation is: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
Question 551
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. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
- Add a moved block mapping the old address to the new address before running a reviewed plan.
- Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow.
- Select the intended workspace before planning and check the corresponding workspace-specific state directory.
Explanation
Correct Answer
A:Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. Backend configuration can be captured in Terraform working-directory metadata and plan files; secret-bearing arguments require extra care. Confirm the cause with: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. A concrete acceptance test is: Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
Incorrect Answers
B:Add a moved block mapping the old address to the new address before running a reviewed plan. This could address moved block preserves state during address refactor, but it does not correct the indicated backend credentials kept out of plan artifacts mechanism. The relevant fix is: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
C:Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow. This could address hcp cloud integration versus remote backend, but it does not correct the indicated backend credentials kept out of plan artifacts mechanism. The relevant fix is: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
D:Select the intended workspace before planning and check the corresponding workspace-specific state directory. This could address local workspace state separation, but it does not correct the indicated backend credentials kept out of plan artifacts mechanism. The relevant fix is: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
Question 552
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer creates three storage resources using for_each but later reads a bare resource attribute as though the declaration has a single instance. The engineer must respect declared resource contracts and data security boundaries. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Inspect the input values and expressions used to construct resource names and tags.
- Check the for_each keys and the collection shape of the declared resource instances.
- Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
- Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
- Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
Explanation
Correct Answers
B:Check the for_each keys and the collection shape of the declared resource instances. for_each produces keyed instances whose attributes must be accessed by their instance keys or collected expressions. A justified correction is: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer….
C:Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. for_each produces keyed instances whose attributes must be accessed by their instance keys or collected expressions. Confirm the cause with: Check the for_each keys and the collection shape of the declared resource instances. A concrete acceptance test is: Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer….
Incorrect Answers
A:Inspect the input values and expressions used to construct resource names and tags. This relates to built-in functions for deterministic naming rather than the matching diagnosis-and-remediation pair required here. Check: Check the for_each keys and the collection shape of the declared resource instances. Then change: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
D:Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root. This relates to module output references across composition rather than the matching diagnosis-and-remediation pair required here. Check: Check the for_each keys and the collection shape of the declared resource instances. Then change: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An engineer….
E:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This relates to map versus list addressing for environment inputs rather than the matching diagnosis-and-remediation pair required here. Check: Check the for_each keys and the collection shape of the declared resource instances. Then change: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
Question 553
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module receives instance sizes keyed by environment name, but the configuration tries to read them using a numeric position as if they were a list. The engineer must respect declared resource contracts and data security boundaries. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Inspect the variable type constraint and the HCL expression used to access its values.
- Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.
- Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
- Inspect the shared attributes and whether one expression can derive a value from the environment input.
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
Explanation
Correct Answers
A:Inspect the variable type constraint and the HCL expression used to access its values. Terraform collection types have distinct semantics: maps are addressed by keys while lists are ordered index-based sequences. A justified correction is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module….
C:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. Terraform collection types have distinct semantics: maps are addressed by keys while lists are ordered index-based sequences. Confirm the cause with: Inspect the variable type constraint and the HCL expression used to access its values. A concrete acceptance test is: The plan selects the correct per-environment instance size without relying on arbitrary key ordering. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module….
Incorrect Answers
B:Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration. This relates to ephemeral variable for short-lived token in terraform 1.12 rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the variable type constraint and the HCL expression used to access its values. Then change: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module….
D:Inspect the shared attributes and whether one expression can derive a value from the environment input. This relates to conditional expressions for environment configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the variable type constraint and the HCL expression used to access its values. Then change: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
E:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. This relates to object type contract with nested attributes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the variable type constraint and the HCL expression used to access its values. Then change: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module….
Question 554
While migrating a manually maintained development environment into reviewed Terraform configuration, the following condition occurs: A deployment ticket says to create a network and firewall by hand, leaving no reliable code change for peers to inspect before access is opened. The team must establish a reproducible and auditable infrastructure change. Which diagnostic check provides the strongest evidence for the underlying problem?
- Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations.
- Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications.
- Inspect provider source requirements, authentication scopes, and whether the on-premises and hosted platforms expose different APIs.
- Compare the runbook's procedural steps with a version-controlled declarative inventory of desired resources and their attributes.
Explanation
Correct Answer
B:Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications. Terraform configurations are executable specifications that enable peer review, not screenshots of already completed manual changes. A justified correction is: Encode the network and firewall resources in version-controlled Terraform and require a reviewed plan in the change process.
Incorrect Answers
A:Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. This inspects multi-cloud providers under one terraform workflow rather than the reported terraform configuration as reviewable infrastructure specification issue. The decisive investigation is: Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications.
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 terraform configuration as reviewable infrastructure specification issue. The decisive investigation is: Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications.
D: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 terraform configuration as reviewable infrastructure specification issue. The decisive investigation is: Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications.
Question 555
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A CI job rejects valid HCL files because their alignment differs from canonical formatting, while engineers mistakenly change provider versions to fix it. The change must preserve the distinction between previewing and modifying infrastructure. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content.
- Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics.
- Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
- Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource.
Explanation
Correct Answers
A:Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently. A formatting check tests canonical HCL presentation, whereas provider version resolution and configuration validity are separate concerns. Confirm the cause with: Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. A concrete acceptance test is: The formatting gate passes without any provider upgrade or unintended managed-resource change. This forms one element of the required two-step diagnosis and correction.
C:Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. A formatting check tests canonical HCL presentation, whereas provider version resolution and configuration validity are separate concerns. A justified correction is: Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content. This relates to saved execution plan for controlled deployment rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. Then change: Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently.
D:Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes. This relates to terraform fmt normalizes hcl style rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. Then change: Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently.
E:Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource. This relates to workflow repeatability after configuration change rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. Then change: Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently.
Question 556
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A root configuration defines an alias for a secondary region, but its child module provisions resources in the primary region because the provider mapping is omitted. The configuration should behave consistently without broadening access. What targeted engineering response should the team implement?
- Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
- Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
- Install and configure the appropriate provider through terraform init so Terraform can use its resource and data source implementations.
Explanation
Correct Answer
A:Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required. Provider configurations are supplied by module callers; module source files do not automatically inherit arbitrary aliases by matching their names. Confirm the cause with: Review the child module provider requirements and root module providers mapping for the child call. A concrete acceptance test is: The child module's resources are planned under the intended alternate region rather than silently using the default provider. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A root….
Incorrect Answers
B:Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin. This could address provider authorization versus installation failure, but it does not correct the indicated module provider mapping for aliased configurations mechanism. The relevant fix is: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
C:Define explicitly aliased provider configurations and assign the production resource to the intended alias. This could address provider alias for multiple accounts, but it does not correct the indicated module provider mapping for aliased configurations mechanism. The relevant fix is: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
D:Install and configure the appropriate provider through terraform init so Terraform can use its resource and data source implementations. This could address provider plugin manages api resources and data reads, but it does not correct the indicated module provider mapping for aliased configurations mechanism. The relevant fix is: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
Question 557
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A root configuration defines an alias for a secondary region, but its child module provisions resources in the primary region because the provider mapping is omitted. The engineers must keep provider choices and identities reproducible. What measurable postchange observation would confirm that the correction worked?
- The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
- The child module's resources are planned under the intended alternate region rather than silently using the default provider.
- The same initialized provider can read the required resource metadata using an approved identity and the access-denied error disappears.
- The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
Explanation
Correct Answer
B:The child module's resources are planned under the intended alternate region rather than silently using the default provider. Provider configurations are supplied by module callers; module source files do not automatically inherit arbitrary aliases by matching their names. It tests the correction: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
Incorrect Answers
A:The plan identifies production-account resources under the intended provider configuration while development objects remain separate. This might validate provider alias for multiple accounts, but it does not prove that module provider mapping for aliased configurations was resolved. Confirm instead: The child module's resources are planned under the intended alternate region rather than silently using the default provider.
C:The same initialized provider can read the required resource metadata using an approved identity and the access-denied error disappears. This might validate provider authorization versus installation failure, but it does not prove that module provider mapping for aliased configurations was resolved. Confirm instead: The child module's resources are planned under the intended alternate region rather than silently using the default provider.
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 module provider mapping for aliased configurations was resolved. Confirm instead: The child module's resources are planned under the intended alternate region rather than silently using the default provider.
Question 558
During a controlled Terraform CLI recovery exercise, the following condition occurs: An operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was never enabled. The same infrastructure must remain managed without unintended replacements. Which investigation would most directly establish the reported Terraform failure?
- Inspect the resource's provider selection, active credentials and which account owns the remote object.
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
- Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
- Check the TF_LOG environment variable and filesystem permissions for the requested log path.
Explanation
Correct Answer
D:Check the TF_LOG environment variable and filesystem permissions for the requested log path. TF_LOG_PATH selects a log destination but must be paired with an enabled TF_LOG level to produce verbose logs. A justified correction is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. This matters here because an operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was….
Incorrect Answers
A:Inspect the resource's provider selection, active credentials and which account owns the remote object. This inspects import source account and provider selection rather than the reported tf_log_path requires enabled logging issue. The decisive investigation is: Check the TF_LOG environment variable and filesystem permissions for the requested log path.
B:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. This inspects tf_log for troubleshooting provider and cli diagnostics rather than the reported tf_log_path requires enabled logging issue. The decisive investigation is: Check the TF_LOG environment variable and filesystem permissions for the requested log path. This matters here because an operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was….
C:Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. This inspects state list for tracking managed addresses rather than the reported tf_log_path requires enabled logging issue. The decisive investigation is: Check the TF_LOG environment variable and filesystem permissions for the requested log path. This matters here because an operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was….
Question 559
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A project stores a state file in a developer's home directory even though multiple engineers need consistent shared planning and state history. The operation must not delete or duplicate existing production objects. What measurable postchange observation would confirm that the correction worked?
- Team plans use the same access-controlled state backend after migration without duplicating existing managed objects.
- Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files.
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
- Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot.
Explanation
Correct Answer
A:Team plans use the same access-controlled state backend after migration without duplicating existing managed objects. Terraform backend configuration selects where state snapshots are stored; migrating them requires careful initialization and authorization. It tests the correction: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A project stores a….
Incorrect Answers
B:Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. This might validate local backend path and exposure, but it does not prove that remote backend block configuration was resolved. Confirm instead: Team plans use the same access-controlled state backend after migration without duplicating existing managed objects.
C:Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs. This might validate backend credentials kept out of plan artifacts, but it does not prove that remote backend block configuration was resolved. Confirm instead: Team plans use the same access-controlled state backend after migration without duplicating existing managed objects.
D: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 remote backend block configuration was resolved. Confirm instead: Team plans use the same access-controlled state backend after migration without duplicating existing managed objects.
Question 560
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform engineer wants to reference an existing DNS zone owned by another team but declares a new resource block and unintentionally plans to create a second zone. The engineer must respect declared resource contracts and data security boundaries. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.
- Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
- Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
- Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
Explanation
Correct Answer
D:Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage. A data block queries information from remote systems while a resource block declares an object Terraform manages across its lifecycle. Confirm the cause with: Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema. A concrete acceptance test is: Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform….
Incorrect Answers
A:Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required. This could address create_before_destroy lifecycle for availability, but it does not correct the indicated data source versus managed resource definition mechanism. The relevant fix is: Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform….
B:Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists. This could address data source read ordering versus creation, but it does not correct the indicated data source versus managed resource definition mechanism. The relevant fix is: Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
C: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 data source versus managed resource definition mechanism. The relevant fix is: Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.