HashiCorp Terraform Associate 004 Practice Test 51
Question 500
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. What measurable postchange observation would confirm that the correction worked?
- The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
- Normal plans do not oscillate the delegated tag, while other resource drift remains visible and managed.
- A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
Explanation
Correct Answer
A:The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. depends_on expresses dependencies that cannot be inferred from configuration values, but unnecessary broad dependencies add conservatism. It tests the correction: Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: An….
Incorrect Answers
B:Normal plans do not oscillate the delegated tag, while other resource drift remains visible and managed. This might validate ignore_changes ownership of externally managed tag, but it does not prove that explicit depends_on for behavior-only dependencies was resolved. Confirm instead: 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….
C:A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts. This might validate ephemeral variable for short-lived token in terraform 1.12, but it does not prove that explicit depends_on for behavior-only dependencies was resolved. Confirm instead: The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
D:A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately. This might validate check block observability versus hard failure, but it does not prove that explicit depends_on for behavior-only dependencies was resolved. Confirm instead: The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
Question 501
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A network module is upgraded and renames a child output, but dependent modules still read the old output and planning fails. The team must preserve reproducibility across callers. What measurable postchange observation would confirm that the correction worked?
- Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics.
- The root plan resolves the new module output names with no dangling references or unintended replacements.
- Two clean deployments retrieve the same module code revision and avoid unnoticed drift from default-branch updates.
- All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters.
Explanation
Correct Answer
B:The root plan resolves the new module output names with no dangling references or unintended replacements. Module version changes can alter interfaces; compatibility is assessed across callers, not by module installation success alone. It tests the correction: Update the module version together with dependent output references and validate the full root configuration before applying. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
A:Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics. This might validate registry module source naming contract, but it does not prove that module upgrade plan review with changed outputs was resolved. Confirm instead: The root plan resolves the new module output names with no dangling references or unintended replacements. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
C:Two clean deployments retrieve the same module code revision and avoid unnoticed drift from default-branch updates. This might validate git module ref pin rather than floating main branch, but it does not prove that module upgrade plan review with changed outputs was resolved. Confirm instead: The root plan resolves the new module output names with no dangling references or unintended replacements.
D:All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters. This might validate module blocks reuse standard infrastructure patterns, but it does not prove that module upgrade plan review with changed outputs was resolved. Confirm instead: The root plan resolves the new module output names with no dangling references or unintended replacements.
Question 502
As a second engineer rehearses an infrastructure state migration, 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 operation must not delete or duplicate existing production objects. Select TWO: the decisive first check and the change that directly addresses the problem.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
- 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.
- Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
- Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.
Explanation
Correct Answers
D: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. This forms one element of the required two-step diagnosis and correction.
E:Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Backend configuration can be captured in Terraform working-directory metadata and plan files; secret-bearing arguments require extra care. A justified correction is: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Inspect the backend configuration and state file location on each workstation to identify local state behavior. This relates to local backend path and exposure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Then change: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
B:Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow. This relates to hcp cloud integration versus remote backend rather than the matching diagnosis-and-remediation pair required here. Check: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Then change: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
C: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: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Then change: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
Question 503
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. 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.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
- Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
- Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning.
Explanation
Correct Answer
C:Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID. State stores known provider-returned attributes and supports dependency references; some values remain unknown until apply. Confirm the cause with: Check which resource attributes are computed by the provider and how state records them after successful operations. A concrete acceptance test is: The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A root….
Incorrect Answers
A:Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required. This could address module provider mapping for aliased configurations, but it does not correct the indicated resource attribute outputs supplied by state mechanism. The relevant fix is: Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
B: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 resource attribute outputs supplied by state mechanism. The relevant fix is: Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
D:Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning. This could address state binding between resource address and remote object, but it does not correct the indicated resource attribute outputs supplied by state mechanism. The relevant fix is: 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….
Question 504
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A network module is upgraded and renames a child output, but dependent modules still read the old output and planning fails. The team must preserve reproducibility across callers. Which investigation would most directly establish the reported Terraform failure?
- Identify common resource groups and the controlled parameters that vary by application team.
- Inspect the module source value and the repository layout relative to the directory containing the calling module.
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
- Check the module source address, allowed version range and current module selections from initialization.
Explanation
Correct Answer
C:Compare the upgraded module's documented input/output contract to root references before approving the module version change. Module version changes can alter interfaces; compatibility is assessed across callers, not by module installation success alone. A justified correction is: Update the module version together with dependent output references and validate the full root configuration before applying. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
A:Identify common resource groups and the controlled parameters that vary by application team. This inspects module blocks reuse standard infrastructure patterns rather than the reported module upgrade plan review with changed outputs issue. The decisive investigation is: Compare the upgraded module's documented input/output contract to root references before approving the module version change.
B:Inspect the module source value and the repository layout relative to the directory containing the calling module. This inspects local child module source path resolution rather than the reported module upgrade plan review with changed outputs issue. The decisive investigation is: Compare the upgraded module's documented input/output contract to root references before approving the module version change.
D:Check the module source address, allowed version range and current module selections from initialization. This inspects registry module version pin to avoid breaking releases rather than the reported module upgrade plan review with changed outputs issue. The decisive investigation is: Compare the upgraded module's documented input/output contract to root references before approving the module version change.
Question 505
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A team assumes a default Terraform directory automatically stores state in a centralized shared service, but every engineer sees their own terraform.tfstate file. The operation must not delete or duplicate existing production objects. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
- Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace.
- Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.
Explanation
Correct Answer
B:Inspect the backend configuration and state file location on each workstation to identify local state behavior. The local backend persists state on the executing filesystem; it does not provide shared remote coordination by default. A justified correction is: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A team assumes a….
Incorrect Answers
A:Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. This inspects local workspace state separation rather than the reported local backend path and exposure issue. The decisive investigation is: Inspect the backend configuration and state file location on each workstation to identify local state behavior. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A team assumes a….
C:Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace. This inspects hcp cloud integration versus remote backend rather than the reported local backend path and exposure issue. The decisive investigation is: Inspect the backend configuration and state file location on each workstation to identify local state behavior.
D:Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. This inspects backend credentials kept out of plan artifacts rather than the reported local backend path and exposure issue. The decisive investigation is: Inspect the backend configuration and state file location on each workstation to identify local state behavior.
Question 506
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: An organization wants to block infrastructure plans that violate approved tagging and region controls but relies solely on reviewers noticing violations manually. The workflow must apply least privilege and preserve workspace isolation. What measurable postchange observation would confirm that the correction worked?
- Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes.
- The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
- A shared setting update reaches exactly the approved workspaces while unrelated projects retain independent configuration.
- A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
Explanation
Correct Answer
D:A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals. HCP Terraform policy as code can evaluate planned infrastructure against centralized governance rules before execution. It tests the correction: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: An….
Incorrect Answers
A:Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes. This might validate hcp terraform team permissions and audit trail, but it does not prove that hcp terraform policy enforcement governance was resolved. Confirm instead: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: An….
B:The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot. This might validate terraform cloud block hcp workspace integration, but it does not prove that hcp terraform policy enforcement governance was resolved. Confirm instead: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
C:A shared setting update reaches exactly the approved workspaces while unrelated projects retain independent configuration. This might validate hcp workspace variable sets share scoped configuration, but it does not prove that hcp terraform policy enforcement governance was resolved. Confirm instead: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
Question 507
During a controlled Terraform CLI recovery exercise, the following condition occurs: An organization adopts hundreds of existing resources using ad hoc CLI import commands that are absent from code review and difficult to reproduce. The same infrastructure must remain managed without unintended replacements. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Compare the declared resource address and remote identifier against the selected state snapshot.
- 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.
- Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
Explanation
Correct Answer
D:Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. Configuration-driven import blocks can make existing-resource adoption repeatable and part of a reviewed execution plan. A justified correction is: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
Incorrect Answers
A:Compare the declared resource address and remote identifier against the selected state snapshot. This inspects terraform import binds preexisting remote object rather than the reported import blocks for reproducible adoption workflow issue. The decisive investigation is: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
B: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 import blocks for reproducible adoption workflow issue. The decisive investigation is: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
C:Check the TF_LOG environment variable and filesystem permissions for the requested log path. This inspects tf_log_path requires enabled logging rather than the reported import blocks for reproducible adoption workflow issue. The decisive investigation is: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
Question 508
During a controlled module integration test for a production Terraform stack, the following condition occurs: A configuration manually concatenates a project name and environment label with inconsistent casing, producing nonstandard resource names in repeated deployments. The desired fix must avoid unrelated resource changes. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently.
- Inspect the provider's replacement behavior, uniqueness constraints, and whether old and new instances can coexist.
- Inspect the input values and expressions used to construct resource names and tags.
- Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
Explanation
Correct Answers
A:Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently. Terraform built-in functions transform known input values deterministically before provider APIs receive resource arguments. Confirm the cause with: Inspect the input values and expressions used to construct resource names and tags. A concrete acceptance test is: Identical approved inputs yield consistent resource names and tags without operator-specific manual spelling fixes. This forms one element of the required two-step diagnosis and correction.
C:Inspect the input values and expressions used to construct resource names and tags. Terraform built-in functions transform known input values deterministically before provider APIs receive resource arguments. A justified correction is: Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Inspect the provider's replacement behavior, uniqueness constraints, and whether old and new instances can coexist. This relates to create_before_destroy lifecycle for availability rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the input values and expressions used to construct resource names and tags. Then change: Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently.
D:Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. This relates to conditional expressions for environment configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the input values and expressions used to construct resource names and tags. Then change: Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently.
E:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This relates to resource precondition for unsafe configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the input values and expressions used to construct resource names and tags. Then change: Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently.
Question 509
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: Two contributors produce equivalent Terraform expressions using inconsistent spacing and indentation, causing noisy reviews despite no actual infrastructure differences. The operator must obtain auditable evidence before touching production resources. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Equivalent configuration is presented in consistent canonical formatting while the resource plan remains semantically unchanged.
- The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
- The formatting gate passes without any provider upgrade or unintended managed-resource change.
- A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
Explanation
Correct Answer
A:Equivalent configuration is presented in consistent canonical formatting while the resource plan remains semantically unchanged. terraform fmt standardizes syntax layout; it is not a validation of cloud permissions or a deployment action. It tests the correction: Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes. This matters here because two contributors produce equivalent Terraform expressions using inconsistent spacing and indentation, causing noisy….
Incorrect Answers
B:The apply finishes after explicit approval and writes the updated resource bindings to the configured backend. This might validate apply requires approval unless automated, but it does not prove that terraform fmt normalizes hcl style was resolved. Confirm instead: Equivalent configuration is presented in consistent canonical formatting while the resource plan remains semantically unchanged.
C:The formatting gate passes without any provider upgrade or unintended managed-resource change. This might validate ci terraform fmt check distinguishes style from validity, but it does not prove that terraform fmt normalizes hcl style was resolved. Confirm instead: Equivalent configuration is presented in consistent canonical formatting while the resource plan remains semantically unchanged. This matters here because two contributors produce equivalent Terraform expressions using inconsistent spacing and indentation, causing noisy….
D:A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions. This might validate targeted apply limitations for normal changes, but it does not prove that terraform fmt normalizes hcl style was resolved. Confirm instead: Equivalent configuration is presented in consistent canonical formatting while the resource plan remains semantically unchanged.
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.