HashiCorp Terraform Associate 004 Practice Test 53
Question 520
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended to stay on a provider's version 5 releases but a broad >= 5.0 constraint unexpectedly selected a breaking 6.x release. The engineers must keep provider choices and identities reproducible. Select TWO: the decisive first check and the change that directly addresses the problem.
- Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
- Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
- Examine required_providers version constraints and the selected version recorded in the dependency lock file.
- Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
- Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again.
Explanation
Correct Answers
C:Examine required_providers version constraints and the selected version recorded in the dependency lock file. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. A justified correction is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. This forms one element of the required two-step diagnosis and correction. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended….
D:Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. Confirm the cause with: Examine required_providers version constraints and the selected version recorded in the dependency lock file. A concrete acceptance test is: Routine initialization stays within the intended major version while explicit change review governs the next major update. This forms one element of the required two-step diagnosis and correction. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended….
Incorrect Answers
A:Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. This relates to provider block credentials versus required_providers rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
B:Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID. This relates to resource attribute outputs supplied by state rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
E:Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again. This relates to provider source requirement declaration rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
Question 521
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A maintenance engineer changes a provider constraint but an existing workspace continues using an older locked plugin even though a newer permitted version is needed. The engineers must keep provider choices and identities reproducible. Which Terraform configuration or workflow change most directly corrects the described issue?
- Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
- Install and configure the appropriate provider through terraform init so Terraform can use its resource and data source implementations.
- Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
- Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
Explanation
Correct Answer
D:Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. Terraform init normally honors locked versions; -upgrade allows choosing newer compatible selections under the declared constraints. Confirm the cause with: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. A concrete acceptance test is: The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A maintenance….
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 controlled provider upgrade using init upgrade mechanism. The relevant fix is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
B: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 controlled provider upgrade using init upgrade mechanism. The relevant fix is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
C:Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. This could address dependency lock file reproducible selection, but it does not correct the indicated controlled provider upgrade using init upgrade mechanism. The relevant fix is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
Question 522
During a controlled module integration test for a production Terraform stack, the following condition occurs: A database connection output includes a password but the author marks only the input variable as sensitive and expects every derived output to be safely hidden in command output. The desired fix must avoid unrelated resource changes. Which proposed remediation solves this failure without masking its cause?
- Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.
- Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
- Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
- Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow.
Explanation
Correct Answer
B:Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. Sensitivity metadata affects presentation, not a guarantee that secret bytes have been removed from state or all other surfaces. Confirm the cause with: Review input and output sensitivity declarations and inspect what the plan or output commands will display. A concrete acceptance test is: Routine Terraform output suppresses the marked secret while protected state access remains restricted.
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 sensitive output display behavior mechanism. The relevant fix is: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
C: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 sensitive output display behavior mechanism. The relevant fix is: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
D:Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow. This could address vault credential lookup without hardcoding secret values, but it does not correct the indicated sensitive output display behavior mechanism. The relevant fix is: Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
Question 523
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 investigation would most directly establish the reported Terraform failure?
- 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.
- Inspect state instance addresses and compare count positions against stable business keys.
- Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version.
Explanation
Correct Answer
A: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.
Incorrect Answers
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 conditional expressions for environment configuration issue. The decisive investigation is: Inspect the shared attributes and whether one expression can derive a value from the environment input.
C:Inspect state instance addresses and compare count positions against stable business keys. This inspects for_each stable identity instead of count index rather than the reported conditional expressions for environment configuration issue. The decisive investigation is: Inspect the shared attributes and whether one expression can derive a value from the environment input.
D:Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. This inspects check block observability versus hard failure rather than the reported conditional expressions for environment configuration issue. The decisive investigation is: Inspect the shared attributes and whether one expression can derive a value from the environment input.
Question 524
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A reusable subnet module expects each entry to contain a CIDR and an enable flag, but callers submit unstructured strings and fail validation. The engineer must respect declared resource contracts and data security boundaries. What targeted engineering response should the team implement?
- 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.
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
- 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 Answer
C:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. Structured object types validate named attribute contracts; a plain string cannot substitute for an object with multiple typed fields. Confirm the cause with: Inspect the module's input type constraint and the shape of the supplied nested values. A concrete acceptance test is: Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
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 object type contract with nested attributes mechanism. The relevant fix is: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
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 object type contract with nested attributes mechanism. The relevant fix is: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
D:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This could address map versus list addressing for environment inputs, but it does not correct the indicated object type contract with nested attributes mechanism. The relevant fix is: Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
Question 525
During a controlled module integration test for a production Terraform stack, 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 desired fix must avoid unrelated resource changes. Which outcome most directly validates the intended fix?
- Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access.
- Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
- Identical approved inputs yield consistent resource names and tags without operator-specific manual spelling fixes.
- The root plan resolves the supported module output without attempting to address private child resource internals.
Explanation
Correct Answer
B:Development and production plan different approved retention settings with otherwise shared definitions and no copied modules. Terraform expressions can choose values based on explicit conditions without duplicating full resource definitions. It tests the correction: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
Incorrect Answers
A:Each application environment receives the correct key-specific resource ID without ambiguous or invalid collection access. This might validate collection references for for_each resources, but it does not prove that conditional expressions for environment configuration was resolved. Confirm instead: Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
C:Identical approved inputs yield consistent resource names and tags without operator-specific manual spelling fixes. This might validate built-in functions for deterministic naming, but it does not prove that conditional expressions for environment configuration was resolved. Confirm instead: Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
D:The root plan resolves the supported module output without attempting to address private child resource internals. This might validate module output references across composition, but it does not prove that conditional expressions for environment configuration was resolved. Confirm instead: Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
Question 526
While diagnosing a Terraform state or import issue in a staging workspace, 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 investigator must avoid unreviewed state writes. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
- 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.
- Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
- Use terraform state show on the selected address to review tracked attributes without changing resources.
Explanation
Correct Answers
A:Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. TF_LOG_PATH selects a log destination but must be paired with an enabled TF_LOG level to produce verbose logs. Confirm the cause with: Check the TF_LOG environment variable and filesystem permissions for the requested log path. A concrete acceptance test is: The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. This forms one element of the required two-step diagnosis and correction.
C: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 forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. This relates to state list for tracking managed addresses rather than the matching diagnosis-and-remediation pair required here. Check: Check the TF_LOG environment variable and filesystem permissions for the requested log path. Then change: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
D:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. This relates to tf_log for troubleshooting provider and cli diagnostics rather than the matching diagnosis-and-remediation pair required here. Check: Check the TF_LOG environment variable and filesystem permissions for the requested log path. Then change: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
E:Use terraform state show on the selected address to review tracked attributes without changing resources. This relates to state show inspects one stored resource instance rather than the matching diagnosis-and-remediation pair required here. Check: Check the TF_LOG environment variable and filesystem permissions for the requested log path. Then change: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Question 527
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants Terraform to stop managing a legacy storage bucket but must retain the real bucket and its contents for a migration. The change must preserve the distinction between previewing and modifying infrastructure. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Use terraform validate to identify the invalid reference, correct the spelling, and rerun validation before planning.
- Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure.
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
Explanation
Correct Answers
B:Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. A justified correction is: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This forms one element of the required two-step diagnosis and correction. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants….
C:Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. Confirm the cause with: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. A concrete acceptance test is: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist. This forms one element of the required two-step diagnosis and correction. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants….
Incorrect Answers
A:Use terraform validate to identify the invalid reference, correct the spelling, and rerun validation before planning. This relates to terraform validate catches undeclared reference rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Then change: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
D: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 bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Then change: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants….
E:Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. This relates to terraform fmt normalizes hcl style rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Then change: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
Question 528
During an operational review of a Terraform state backend, the following condition occurs: A root Terraform configuration configures both cloud integration and a separate backend block, leading to a configuration error or ambiguous remote operation target. The team must preserve managed-object identity and safe collaboration. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
- Inspect active runs and lock metadata to determine whether another legitimate operation owns the state lock.
- 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
C:Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace. HCP Terraform's cloud integration and a separate backend declaration are alternative root state configuration modes. A justified correction is: Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow. This matters here because a root Terraform configuration configures both cloud integration and a separate backend block, leading to a….
Incorrect Answers
A:Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking. This inspects force unlock requires stale-lock verification rather than the reported hcp cloud integration versus remote backend issue. The decisive investigation is: Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace.
B: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 hcp cloud integration versus remote backend issue. The decisive investigation is: Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace.
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 hcp cloud integration versus remote backend issue. The decisive investigation is: Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace.
Question 529
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: An engineer references a public registry module using a Git URL but also supplies a registry version argument and expects Terraform to resolve it as a registry source. The team must preserve reproducibility across callers. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract.
- Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
- Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
- Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.
- Identify common resource groups and the controlled parameters that vary by application team.
Explanation
Correct Answers
B:Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. Registry sources support the version argument; a Git source generally selects its revision through its source query ref. A justified correction is: Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL. This forms one element of the required two-step diagnosis and correction.
C:Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL. Registry sources support the version argument; a Git source generally selects its revision through its source query ref. Confirm the cause with: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. A concrete acceptance test is: Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract. This relates to for_each at module call for multiple environments rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. Then change: Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
D:Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This relates to git module source with explicit subdirectory rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. Then change: Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
E:Identify common resource groups and the controlled parameters that vary by application team. This relates to module blocks reuse standard infrastructure patterns rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. Then change: Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
Question 530
When maintaining Terraform modules used by several application teams, the following condition occurs: A root Terraform configuration calls a child module with a relative source path that points to a nonexistent sibling directory on the CI runner. The module interface must remain stable and reviewable. Which investigation would most directly establish the reported Terraform failure?
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
- Inspect the module source value and the repository layout relative to the directory containing the calling module.
- Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
- Check the module source address, allowed version range and current module selections from initialization.
Explanation
Correct Answer
B:Inspect the module source value and the repository layout relative to the directory containing the calling module. Local module sources are paths resolved relative to the calling module; incorrect layout cannot be repaired by provider credentials. A justified correction is: Set the source to an accurate local relative module path and initialize or validate from the correct root directory. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A root….
Incorrect Answers
A:Compare the upgraded module's documented input/output contract to root references before approving the module version change. This inspects module upgrade plan review with changed outputs rather than the reported local child module source path resolution issue. The decisive investigation is: Inspect the module source value and the repository layout relative to the directory containing the calling module.
C:Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. This inspects git module source with explicit subdirectory rather than the reported local child module source path resolution issue. The decisive investigation is: Inspect the module source value and the repository layout relative to the directory containing the calling module.
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 local child module source path resolution issue. The decisive investigation is: Inspect the module source value and the repository layout relative to the directory containing the calling module. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A root….