HashiCorp Terraform Associate 004 Practice Test 66
Question 650
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A Terraform directory configures two accounts of the same platform but the provider blocks share a broad credential so the blast radius is unclear. The engineers must keep provider choices and identities reproducible. Which outcome most directly validates the intended fix?
- Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently.
- The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates.
- The child module's resources are planned under the intended alternate region rather than silently using the default provider.
- Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
Explanation
Correct Answer
D:Read and write operations in one account do not gain unnecessary authorization to unrelated account resources. Multiple provider configurations can share a plugin while representing distinct authenticated API clients. It tests the correction: Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
Incorrect Answers
A:Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently. This might validate dependency lock file reproducible selection, but it does not prove that multiple provider instances requiring separate authentication was resolved. Confirm instead: Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
B:The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates. This might validate controlled provider upgrade using init upgrade, but it does not prove that multiple provider instances requiring separate authentication was resolved. Confirm instead: Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
C:The child module's resources are planned under the intended alternate region rather than silently using the default provider. This might validate module provider mapping for aliased configurations, but it does not prove that multiple provider instances requiring separate authentication was resolved. Confirm instead: Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
Question 651
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics.
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. This matters here because a CI job rejects valid HCL files because their alignment differs from canonical formatting, while engineers….
E: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. This matters here because a CI job rejects valid HCL files because their alignment differs from canonical formatting, while engineers….
Incorrect Answers
B:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. This relates to apply requires approval unless automated rather than the matching diagnosis-and-remediation pair required here. Check: Inspect 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.
C: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. This matters here because a CI job rejects valid HCL files because their alignment differs from canonical formatting, while engineers….
D:Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources. 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 652
While diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: An engineer wants to know which indexed resources are managed before a refactor but greps the Terraform source and misses instances tracked in the active state. The investigator must avoid unreviewed state writes. Which proposed remediation solves this failure without masking its cause?
- Use terraform state show on the selected address to review tracked attributes without changing resources.
- Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan.
- Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
- Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
Explanation
Correct Answer
C:Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. terraform state list inspects state bindings, which can differ from textual declarations after drift or refactoring. Confirm the cause with: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. A concrete acceptance test is: The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract. This matters here because while diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: An….
Incorrect Answers
A:Use terraform state show on the selected address to review tracked attributes without changing resources. This could address state show inspects one stored resource instance, but it does not correct the indicated state list for tracking managed addresses mechanism. The relevant fix is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. This matters here because while diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: An….
B:Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan. This could address terraform import binds preexisting remote object, but it does not correct the indicated state list for tracking managed addresses mechanism. The relevant fix is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
D:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. This could address tf_log for troubleshooting provider and cli diagnostics, but it does not correct the indicated state list for tracking managed addresses mechanism. The relevant fix is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. This matters here because while diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: An….
Question 653
While diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: A debugging session needs the stored attributes of module.network.resource_name for one key, but the engineer runs terraform output and finds no corresponding root output. The investigator must avoid unreviewed state writes. Which Terraform configuration or workflow change most directly corrects the described issue?
- Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
- Use terraform state show on the selected address to review tracked attributes without changing resources.
- Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
- Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Explanation
Correct Answer
B:Use terraform state show on the selected address to review tracked attributes without changing resources. State inspection commands read tracked resource details; root outputs expose only values explicitly declared for outputs. Confirm the cause with: Identify the exact resource instance address from terraform state list and inspect it with terraform state show. A concrete acceptance test is: The reviewer sees the requested resource's stored values while no import, state edit or remote mutation is performed. This matters here because while diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: A….
Incorrect Answers
A:Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state. This could address import blocks for reproducible adoption workflow, but it does not correct the indicated state show inspects one stored resource instance mechanism. The relevant fix is: Use terraform state show on the selected address to review tracked attributes without changing resources. This matters here because while diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: A….
C:Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. This could address state list for tracking managed addresses, but it does not correct the indicated state show inspects one stored resource instance mechanism. The relevant fix is: Use terraform state show on the selected address to review tracked attributes without changing resources. This matters here because while diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: A….
D:Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. This could address tf_log_path requires enabled logging, but it does not correct the indicated state show inspects one stored resource instance mechanism. The relevant fix is: Use terraform state show on the selected address to review tracked attributes without changing resources.
Question 654
When maintaining Terraform modules used by several application teams, the following condition occurs: A web module hardcodes the subnet ID produced by a separate network module and fails when an environment provisions a different subnet. The module interface must remain stable and reviewable. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the module source value and the repository layout relative to the directory containing the calling module.
- Inspect the child module's variable declarations and the arguments passed by its calling module block.
- Inspect which module arguments vary and whether stable application keys can drive repeated module instances.
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
Explanation
Correct Answer
D:Inspect the parent composition and whether the network child provides an output representing the created subnet. Composed modules communicate through explicit outputs and inputs, permitting dependency-aware infrastructure assembly. A justified correction is: Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A web module….
Incorrect Answers
A: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 outputs coordinate dependencies instead of duplicate data issue. The decisive investigation is: Inspect the parent composition and whether the network child provides an output representing the created subnet. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A web module….
B:Inspect the child module's variable declarations and the arguments passed by its calling module block. This inspects root and child variable scope isolation rather than the reported module outputs coordinate dependencies instead of duplicate data issue. The decisive investigation is: Inspect the parent composition and whether the network child provides an output representing the created subnet.
C:Inspect which module arguments vary and whether stable application keys can drive repeated module instances. This inspects for_each at module call for multiple environments rather than the reported module outputs coordinate dependencies instead of duplicate data issue. The decisive investigation is: Inspect the parent composition and whether the network child provides an output representing the created subnet.
Question 655
During a controlled module integration test for a production Terraform stack, the following condition occurs: A name-sensitive network endpoint needs replacement, but Terraform plans to remove the old endpoint first and an application would become unavailable. The desired fix must avoid unrelated resource changes. Which outcome most directly validates the intended fix?
- The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
- Removing one application plans its own deletion without shifting unrelated resource instances to new indexes.
- The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
Explanation
Correct Answer
C:The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit. create_before_destroy changes replacement ordering but cannot override remote API uniqueness rules or capacity limits. It tests the correction: Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
Incorrect Answers
A:The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. This might validate explicit depends_on for behavior-only dependencies, but it does not prove that create_before_destroy lifecycle for availability was resolved. Confirm instead: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
B:Removing one application plans its own deletion without shifting unrelated resource instances to new indexes. This might validate for_each stable identity instead of count index, but it does not prove that create_before_destroy lifecycle for availability was resolved. Confirm instead: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
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 create_before_destroy lifecycle for availability was resolved. Confirm instead: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
Question 656
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A novice team runs terraform apply in a directory containing unreviewed edits and cannot explain the difference between proposed and actual resource changes. The operator must obtain auditable evidence before touching production resources. Which Terraform configuration or workflow change most directly corrects the described issue?
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
- Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
- Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
Explanation
Correct Answer
B:Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. Terraform's normal lifecycle separates desired-state authoring and plan evaluation from the operation that changes managed infrastructure. Confirm the cause with: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. A concrete acceptance test is: A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported. This matters here because a novice team runs terraform apply in a directory containing unreviewed edits and cannot explain the difference….
Incorrect Answers
A:Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources. This could address workflow repeatability after configuration change, but it does not correct the indicated core write plan apply workflow order mechanism. The relevant fix is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. This matters here because a novice team runs terraform apply in a directory containing unreviewed edits and cannot explain the difference….
C:Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This could address apply requires approval unless automated, but it does not correct the indicated core write plan apply workflow order mechanism. The relevant fix is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
D:Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying. This could address plan distinguishes replacement from in-place update, but it does not correct the indicated core write plan apply workflow order mechanism. The relevant fix is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
Question 657
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 Terraform configuration or workflow change most directly corrects the described issue?
- Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
- Use the managed subnet resource's appropriate output attribute directly in the server configuration.
- Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Explanation
Correct Answer
C:Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. Terraform expressions can choose values based on explicit conditions without duplicating full resource definitions. Confirm the cause with: Inspect the shared attributes and whether one expression can derive a value from the environment input. A concrete acceptance test is: Development and production plan different approved retention settings with otherwise shared definitions and no copied modules. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A team….
Incorrect Answers
A:Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. This could address explicit depends_on for behavior-only dependencies, but it does not correct the indicated conditional expressions for environment configuration mechanism. The relevant fix is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
B:Use the managed subnet resource's appropriate output attribute directly in the server configuration. This could address implicit dependency through resource attribute reference, but it does not correct the indicated conditional expressions for environment configuration mechanism. The relevant fix is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
D:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This could address for_each stable identity instead of count index, but it does not correct the indicated conditional expressions for environment configuration mechanism. The relevant fix is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
Question 658
When reviewing a reusable Terraform HCL configuration before deployment, 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 engineer must respect declared resource contracts and data security boundaries. Select TWO: the decisive first check and the change that directly addresses the problem.
- Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently.
- Inspect the input values and expressions used to construct resource names and tags.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
- Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
- Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema.
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. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A….
B: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. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A….
Incorrect Answers
C:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This relates to for_each stable identity instead of count index rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the 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 a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports. This relates to check block observability versus hard failure 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:Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema. This relates to data source versus managed resource definition 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 659
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A root module adds a new remote child module source, but terraform validate reports it cannot find the child module in the local working directory. The operator must obtain auditable evidence before touching production resources. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the module source declaration and initialization logs for the missing module download.
- Inspect the .terraform working directory and initialization output for missing backend, module, and provider setup.
- Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
- Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply.
Explanation
Correct Answer
A:Inspect the module source declaration and initialization logs for the missing module download. Terraform initialization installs external module dependencies while validation assumes required module code is locally available. A justified correction is: Run terraform init to install and configure referenced child modules before attempting configuration validation.
Incorrect Answers
B:Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. This inspects terraform init backend and provider preparation rather than the reported module installation during initial setup issue. The decisive investigation is: Inspect the module source declaration and initialization logs for the missing module download.
C:Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. This inspects terraform fmt normalizes hcl style rather than the reported module installation during initial setup issue. The decisive investigation is: Inspect the module source declaration and initialization logs for the missing module download.
D:Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply. This inspects terraform validate versus cloud permission testing rather than the reported module installation during initial setup issue. The decisive investigation is: Inspect the module source declaration and initialization logs for the missing module download.
Question 660
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 Terraform configuration or workflow change most directly corrects the described issue?
- Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values.
- Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.
- Update the module version together with dependent output references and validate the full root configuration before applying.
- Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
Explanation
Correct Answer
C:Update the module version together with dependent output references and validate the full root configuration before applying. Module version changes can alter interfaces; compatibility is assessed across callers, not by module installation success alone. Confirm the cause with: Compare the upgraded module's documented input/output contract to root references before approving the module version change. A concrete acceptance test is: 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….
Incorrect Answers
A:Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values. This could address module outputs coordinate dependencies instead of duplicate data, but it does not correct the indicated module upgrade plan review with changed outputs mechanism. The relevant fix is: Update the module version together with dependent output references and validate the full root configuration before applying.
B:Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This could address git module source with explicit subdirectory, but it does not correct the indicated module upgrade plan review with changed outputs mechanism. The relevant fix is: Update the module version together with dependent output references and validate the full root configuration before applying.
D:Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. This could address git module ref pin rather than floating main branch, but it does not correct the indicated module upgrade plan review with changed outputs mechanism. The relevant fix is: Update the module version together with dependent output references and validate the full root configuration before applying.