HashiCorp Terraform Associate 004 (HashiCorp Certified: Terraform Associate (004)) Practice Test 73

Question 720

A Terraform rollout has two separate requirements: first, calculate collection values without an external provisioner; second, create one resource instance per unique map or set key. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Built-in collection function; then use for expression list projection.
  2. First use for expression list projection; then use for expression filtering.
  3. First use for_each resource replication; then use Built-in collection function.
  4. First use for expression filtering; then use for_each resource replication.
  5. First use Built-in collection function; then use for_each resource replication.

Explanation

Correct Answer

E:

The first requirement, to calculate collection values without an external provisioner, is handled by Built-in collection function: Functions such as length, concat, and merge manipulate Terraform values during expression evaluation. The second requirement, to create one resource instance per unique map or set key, is handled by for_each resource replication: for_each expands a resource into stable keyed instances when its collection is known at planning. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to calculate collection values without an external provisioner and create one resource instance per unique map or set key, the first candidate Built-in collection function addresses calculate collection values without an external provisioner; the second candidate for expression list projection addresses transform a collection into a list of calculated values. This mapping fails because the second mechanism primarily supports the task to transform a collection into a list of calculated values; the actual requirements are calculate collection values without an external provisioner first and create one resource instance per unique map or set key second.

B:

For the requested tasks to calculate collection values without an external provisioner and create one resource instance per unique map or set key, the first candidate for expression list projection addresses transform a collection into a list of calculated values; the second candidate for expression filtering addresses include only elements satisfying an if condition in a derived collection. This mapping fails because the first mechanism primarily supports the task to transform a collection into a list of calculated values and the second mechanism primarily supports the task to include only elements satisfying an if condition in a derived collection; the actual requirements are calculate collection values without an external provisioner first and create one resource instance per unique map or set key second.

C:

For the requested tasks to calculate collection values without an external provisioner and create one resource instance per unique map or set key, the first candidate for_each resource replication addresses create one resource instance per unique map or set key; the second candidate Built-in collection function addresses calculate collection values without an external provisioner. This mapping fails because the first mechanism primarily supports the task to create one resource instance per unique map or set key and the second mechanism primarily supports the task to calculate collection values without an external provisioner; the actual requirements are calculate collection values without an external provisioner first and create one resource instance per unique map or set key second.

D:

For the requested tasks to calculate collection values without an external provisioner and create one resource instance per unique map or set key, the first candidate for expression filtering addresses include only elements satisfying an if condition in a derived collection; the second candidate for_each resource replication addresses create one resource instance per unique map or set key. This mapping fails because the first mechanism primarily supports the task to include only elements satisfying an if condition in a derived collection; the actual requirements are calculate collection values without an external provisioner first and create one resource instance per unique map or set key second.

Question 721

The rollout owner asks whether Refresh-only planning is sufficient to inspect externally changed infrastructure without planning configuration reconciliation. Which limitation specifically concerns that mechanism?

  1. Plan does not persist the proposed changes to remote infrastructure.
  2. It does not use configuration to correct drift in the remote service.
  3. Saved plans can include sensitive data and should not be committed publicly.
  4. A plan based on stale state can be inaccurate about real infrastructure.

Explanation

Correct Answer

B:

For Refresh-only planning in the task to inspect externally changed infrastructure without planning configuration reconciliation, the important caution is: It does not use configuration to correct drift in the remote service. The reason this matters is its actual behavior: terraform plan -refresh-only proposes updates to state and outputs based on remote observations.

Incorrect Answers

A:

The proposed warning belongs to terraform plan command, which serves the different goal to preview actions required to reach the declared infrastructure state, rather than to Refresh-only planning: terraform plan shows changes Terraform expects, including creates, updates, deletes, and replacements. The question concerns Refresh-only planning acting to inspect externally changed infrastructure without planning configuration reconciliation, not a limit of terraform plan command.

C:

The proposed warning belongs to Plan saved to file, which serves the different goal to capture one execution plan for later approval and application, rather than to Refresh-only planning: terraform plan -out=change.tfplan saves an executable binary plan artifact. The question concerns Refresh-only planning acting to inspect externally changed infrastructure without planning configuration reconciliation, not a limit of Plan saved to file.

D:

The listed caution belongs specifically to Plan without state refresh, used to avoid remote refresh reads when an intentional troubleshooting constraint requires it: terraform plan -refresh=false uses existing state without refreshing live objects before planning; the feature under review is instead Refresh-only planning, so this answer attaches another feature's qualification to the wrong mechanism.

Question 722

The team is documenting risks of removed block with destroy=false while planning to stop tracking an object in state but deliberately leave it deployed. Which caveat specifically applies to that mechanism?

  1. A refresh-only apply instead accepts observed remote values into state.
  2. If its configuration remains, a later plan can propose creating another object.
  3. Configuration reconciliation requires a subsequent reviewed apply.
  4. Ordinary resource removal from HCL can instead lead to destruction.
  5. It does not rename or migrate the remote object through its provider API.

Explanation

Correct Answer

D:

For removed block with destroy=false in the task to stop tracking an object in state but deliberately leave it deployed, the important caution is: Ordinary resource removal from HCL can instead lead to destruction. The reason this matters is its actual behavior: A removed block declares that Terraform should forget a resource without deleting it when destroy=false.

Incorrect Answers

A:

The proposed warning belongs to Drift reconciliation to configuration, which serves the different goal to restore externally modified resource settings to desired code values, rather than to removed block with destroy=false: A regular plan and apply can propose changing a drifted object back to configured settings. The question concerns removed block with destroy=false acting to stop tracking an object in state but deliberately leave it deployed, not a limit of Drift reconciliation to configuration.

B:

The proposed warning belongs to terraform state rm, which serves the different goal to detach a resource address from state while leaving the remote object intact, rather than to removed block with destroy=false: state rm forgets the binding but does not delete the real infrastructure object. The question concerns removed block with destroy=false acting to stop tracking an object in state but deliberately leave it deployed, not a limit of terraform state rm.

C:

The proposed warning belongs to Remote drift detection during plan, which serves the different goal to recognize that a resource was changed outside Terraform, rather than to removed block with destroy=false: Normal plan refresh reads can reveal drift between state and the remote object. The question concerns removed block with destroy=false acting to stop tracking an object in state but deliberately leave it deployed, not a limit of Remote drift detection during plan.

E:

The proposed warning belongs to terraform state mv, which serves the different goal to change a resource state address to match a configuration refactor, rather than to removed block with destroy=false: state mv rebinds an existing object under a new compatible address. The question concerns removed block with destroy=false acting to stop tracking an object in state but deliberately leave it deployed, not a limit of terraform state mv.

Question 723

A colleague recommends the Terraform concept "Service-agnostic orchestration". Which use case best matches it?

  1. abstract a deployment pattern while keeping provider details explicit
  2. control DNS, SaaS, and cloud resources through a common configuration tool
  3. plan and apply resources from several providers in one run
  4. use output from one service to configure another supported service

Explanation

Correct Answer

B:

The practical result of Service-agnostic orchestration, used to control DNS, SaaS, and cloud resources through a common configuration tool, is: Terraform providers expose resource and data types beyond infrastructure hosted by a cloud vendor. A qualification for this effect is: Service-agnostic does not mean resource schemas are interchangeable.

Incorrect Answers

A:

That outcome applies to Vendor portability through modules, intended to abstract a deployment pattern while keeping provider details explicit, rather than the question's feature Service-agnostic orchestration: A module can offer common input and output conventions even if its implementation uses provider-specific resources. Unlike Vendor portability through modules, Service-agnostic orchestration is intended to control DNS, SaaS, and cloud resources through a common configuration tool, not to abstract a deployment pattern while keeping provider details explicit.

C:

That outcome applies to Common Terraform lifecycle across providers, intended to plan and apply resources from several providers in one run, rather than the question's feature Service-agnostic orchestration: Terraform Core constructs a dependency graph and asks installed providers to implement their own actions. Unlike Common Terraform lifecycle across providers, Service-agnostic orchestration is intended to control DNS, SaaS, and cloud resources through a common configuration tool, not to plan and apply resources from several providers in one run.

D:

That outcome applies to Cross-platform dependency references, intended to use output from one service to configure another supported service, rather than the question's feature Service-agnostic orchestration: References can establish ordering when a resource on one platform consumes attributes from another resource. Unlike Cross-platform dependency references, Service-agnostic orchestration is intended to control DNS, SaaS, and cloud resources through a common configuration tool, not to use output from one service to configure another supported service.

Question 724

The rollout owner asks whether Version of Git module is sufficient to pin a VCS module using its source ref rather than registry version. Which limitation specifically concerns that mechanism?

  1. The registry module version argument does not apply to generic Git sources.
  2. A local edit can still change the next plan and should be reviewed.
  3. Assuming .terraform.lock.hcl freezes registry modules can surprise a new installation.
  4. An unpinned module version may drift as newer releases appear.
  5. Version constraints cannot guarantee every patch release is defect-free.

Explanation

Correct Answer

A:

For Version of Git module in the task to pin a VCS module using its source ref rather than registry version, the important caution is: The registry module version argument does not apply to generic Git sources. The reason this matters is its actual behavior: A ?ref=tag or commit in a Git module source selects the VCS revision to fetch.

Incorrect Answers

B:

The proposed warning belongs to Local module development lifecycle, which serves the different goal to update a local path module without applying registry release versioning, rather than to Version of Git module: Local module source code is read from its path and does not use a version argument. The question concerns Version of Git module acting to pin a VCS module using its source ref rather than registry version, not a limit of Local module development lifecycle.

C:

The proposed warning belongs to Module versus provider version lock, which serves the different goal to track module release selection separately from provider lock file behavior, rather than to Version of Git module: Module versions are selected by module source and version settings, whereas the lock file records providers. The question concerns Version of Git module acting to pin a VCS module using its source ref rather than registry version, not a limit of Module versus provider version lock.

D:

The proposed warning belongs to Registry module version constraint, which serves the different goal to select module releases meeting a declared compatibility range, rather than to Version of Git module: A registry module call accepts a version argument that chooses supported release versions. The question concerns Version of Git module acting to pin a VCS module using its source ref rather than registry version, not a limit of Registry module version constraint.

E:

The proposed warning belongs to Module release compatibility, which serves the different goal to constrain a module to releases with an expected interface, rather than to Version of Git module: A version range helps avoid inadvertently selecting a module revision with breaking input or output changes. The question concerns Version of Git module acting to pin a VCS module using its source ref rather than registry version, not a limit of Module release compatibility.

Question 725

A change proposal relies on Local to HCP state migration for the task to move a locally managed state history into an HCP Terraform workspace. Which limitation specifically applies to it?

  1. Selecting the wrong workspace can target a different infrastructure state.
  2. A CLI token is not a cloud provider's deployment credential.
  3. Actual execution behavior depends on the workspace and integration settings.
  4. A migration should be backed up and verified before discarding the local copy.

Explanation

Correct Answer

D:

For Local to HCP state migration in the task to move a locally managed state history into an HCP Terraform workspace, the important caution is: A migration should be backed up and verified before discarding the local copy. The reason this matters is its actual behavior: Changing state integration and reinitializing can migrate state into HCP Terraform when configured correctly.

Incorrect Answers

A:

The proposed warning belongs to HCP Terraform workspace selection, which serves the different goal to route CLI-driven operations to the intended HCP workspace, rather than to Local to HCP state migration: The cloud block workspace settings determine which HCP workspace the configuration uses. The question concerns Local to HCP state migration acting to move a locally managed state history into an HCP Terraform workspace, not a limit of HCP Terraform workspace selection.

B:

The proposed warning belongs to Terraform CLI login to HCP, which serves the different goal to authenticate local Terraform CLI operations against HCP Terraform, rather than to Local to HCP state migration: terraform login starts an authentication workflow and stores a token for HCP Terraform access. The question concerns Local to HCP state migration acting to move a locally managed state history into an HCP Terraform workspace, not a limit of Terraform CLI login to HCP.

C:

The listed caution belongs specifically to CLI-driven HCP runs, used to initiate workspace operations through familiar Terraform commands: HCP Terraform supports CLI-driven workflows connected to remote workspace state and operations; the feature under review is instead Local to HCP state migration, so this answer attaches another feature's qualification to the wrong mechanism.

Question 726

A colleague recommends the Terraform concept "TF_LOG_CORE environment variable". Which use case best matches it?

  1. review debugging evidence without publishing API secrets
  2. capture highly detailed events for a stubborn Terraform problem
  3. focus debugging on Terraform Core behavior rather than provider messages
  4. avoid collecting unnecessary sensitive operational output

Explanation

Correct Answer

C:

The practical result of TF_LOG_CORE environment variable, used to focus debugging on Terraform Core behavior rather than provider messages, is: TF_LOG_CORE can set logging for Terraform Core separately from provider plugin output. A qualification for this effect is: Core logging does not substitute for investigating remote API authorization errors.

Incorrect Answers

A:

That outcome applies to Log analysis and source protection, intended to review debugging evidence without publishing API secrets, rather than the question's feature TF_LOG_CORE environment variable: Diagnostic logs should be stored and shared according to secret-handling policy. Unlike Log analysis and source protection, TF_LOG_CORE environment variable is intended to focus debugging on Terraform Core behavior rather than provider messages, not to review debugging evidence without publishing API secrets.

B:

That outcome applies to TRACE diagnostic level, intended to capture highly detailed events for a stubborn Terraform problem, rather than the question's feature TF_LOG_CORE environment variable: TRACE is a very verbose Terraform logging level useful for deep troubleshooting. Unlike TRACE diagnostic level, TF_LOG_CORE environment variable is intended to focus debugging on Terraform Core behavior rather than provider messages, not to capture highly detailed events for a stubborn Terraform problem.

D:

That outcome applies to Disable debug logging after diagnosis, intended to avoid collecting unnecessary sensitive operational output, rather than the question's feature TF_LOG_CORE environment variable: Unset debug environment variables or restore normal log settings when the investigation ends. Unlike Disable debug logging after diagnosis, TF_LOG_CORE environment variable is intended to focus debugging on Terraform Core behavior rather than provider messages, not to avoid collecting unnecessary sensitive operational output.

Question 727

A platform engineering group needs to generate repeated nested configuration blocks from a collection. Which mechanism most directly meets this particular need?

  1. for expression list projection
  2. for expression filtering
  3. Dynamic nested block
  4. Conditional expression

Explanation

Correct Answer

C:

The task is to generate repeated nested configuration blocks from a collection; Dynamic nested block directly supports that requirement: A dynamic block emits nested blocks where the enclosing resource schema permits them. Its relevant boundary is: Dynamic cannot generate resource or provider blocks at the root level.

Incorrect Answers

A:

for expression list projection is designed to transform a collection into a list of calculated values, whereas this task is to generate repeated nested configuration blocks from a collection: A bracketed for expression maps each element to a new value using a declared iterator. Against Dynamic nested block, its limitation is: A for expression calculates values but does not itself create resource instances.

B:

for expression filtering is designed to include only elements satisfying an if condition in a derived collection, whereas this task is to generate repeated nested configuration blocks from a collection: A for expression's optional if clause filters elements while projecting results. Against Dynamic nested block, its limitation is: Filtering a collection is different from lifecycle ignore_changes.

D:

Conditional expression is designed to choose between two values based on a boolean condition, whereas this task is to generate repeated nested configuration blocks from a collection: Terraform's condition ? true_value : false_value expression selects a value based on a predicate. Against Dynamic nested block, its limitation is: The two branches need compatible types for Terraform to reconcile the result.

Question 728

A Terraform rollout has two separate requirements: first, inspect externally changed infrastructure without planning configuration reconciliation; second, convert a saved plan into JSON for automated analysis. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Replacement plan indicator; then use terraform plan command.
  2. First use Refresh-only planning; then use Machine-readable plan inspection.
  3. First use terraform plan command; then use Machine-readable plan inspection.
  4. First use Refresh-only planning; then use Replacement plan indicator.
  5. First use Machine-readable plan inspection; then use Refresh-only planning.

Explanation

Correct Answer

B:

The first requirement, to inspect externally changed infrastructure without planning configuration reconciliation, is handled by Refresh-only planning: terraform plan -refresh-only proposes updates to state and outputs based on remote observations. The second requirement, to convert a saved plan into JSON for automated analysis, is handled by Machine-readable plan inspection: terraform show -json change.tfplan exposes plan details for tooling. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to inspect externally changed infrastructure without planning configuration reconciliation and convert a saved plan into JSON for automated analysis, the first candidate Replacement plan indicator addresses recognize that a proposed change will replace an existing resource; the second candidate terraform plan command addresses preview actions required to reach the declared infrastructure state. This mapping fails because the first mechanism primarily supports the task to recognize that a proposed change will replace an existing resource and the second mechanism primarily supports the task to preview actions required to reach the declared infrastructure state; the actual requirements are inspect externally changed infrastructure without planning configuration reconciliation first and convert a saved plan into JSON for automated analysis second.

C:

For the requested tasks to inspect externally changed infrastructure without planning configuration reconciliation and convert a saved plan into JSON for automated analysis, the first candidate terraform plan command addresses preview actions required to reach the declared infrastructure state; the second candidate Machine-readable plan inspection addresses convert a saved plan into JSON for automated analysis. This mapping fails because the first mechanism primarily supports the task to preview actions required to reach the declared infrastructure state; the actual requirements are inspect externally changed infrastructure without planning configuration reconciliation first and convert a saved plan into JSON for automated analysis second.

D:

For the requested tasks to inspect externally changed infrastructure without planning configuration reconciliation and convert a saved plan into JSON for automated analysis, the first candidate Refresh-only planning addresses inspect externally changed infrastructure without planning configuration reconciliation; the second candidate Replacement plan indicator addresses recognize that a proposed change will replace an existing resource. This mapping fails because the second mechanism primarily supports the task to recognize that a proposed change will replace an existing resource; the actual requirements are inspect externally changed infrastructure without planning configuration reconciliation first and convert a saved plan into JSON for automated analysis second.

E:

For the requested tasks to inspect externally changed infrastructure without planning configuration reconciliation and convert a saved plan into JSON for automated analysis, the first candidate Machine-readable plan inspection addresses convert a saved plan into JSON for automated analysis; the second candidate Refresh-only planning addresses inspect externally changed infrastructure without planning configuration reconciliation. This mapping fails because the first mechanism primarily supports the task to convert a saved plan into JSON for automated analysis and the second mechanism primarily supports the task to inspect externally changed infrastructure without planning configuration reconciliation; the actual requirements are inspect externally changed infrastructure without planning configuration reconciliation first and convert a saved plan into JSON for automated analysis second.

Question 729

Before adopting Different provider local names to declare several provider types in the same root module, which statement sets an accurate boundary?

  1. Aliases and complex configurations often require explicit mapping.
  2. Resources still use their provider-defined schemas and credentials.
  3. The existence of an alias does not move existing resources to that configuration automatically.
  4. The alias must be declared and satisfy provider requirements.
  5. A provider alias is not a separate package with its own source address.

Explanation

Correct Answer

B:

For Different provider local names in the task to declare several provider types in the same root module, the important caution is: Resources still use their provider-defined schemas and credentials. The reason this matters is its actual behavior: The required_providers map can list multiple source addresses with distinct local names.

Incorrect Answers

A:

The proposed warning belongs to Default provider configuration inheritance, which serves the different goal to let a child module use default provider settings from its parent, rather than to Different provider local names: Child modules commonly inherit default provider configurations from the calling module. The question concerns Different provider local names acting to declare several provider types in the same root module, not a limit of Default provider configuration inheritance.

C:

The proposed warning belongs to Aliased provider instance, which serves the different goal to configure a second instance of the same provider for another account or region, rather than to Different provider local names: The alias argument gives a provider configuration an additional address that resources can select. The question concerns Different provider local names acting to declare several provider types in the same root module, not a limit of Aliased provider instance.

D:

The proposed warning belongs to Resource provider meta-argument, which serves the different goal to direct an individual resource to the intended aliased provider, rather than to Different provider local names: The provider meta-argument can select a configured instance such as aws.west for that resource. The question concerns Different provider local names acting to declare several provider types in the same root module, not a limit of Resource provider meta-argument.

E:

The listed caution belongs specifically to Provider alias reference address, used to refer to a provider configuration by its local name and alias: An address such as aws.audit identifies a specific configured instance of the aws provider; the feature under review is instead Different provider local names, so this answer attaches another feature's qualification to the wrong mechanism.

Question 730

A Terraform rollout has two separate requirements: first, stop tracking an object in state but deliberately leave it deployed; second, change a resource state address to match a configuration refactor. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use removed block with destroy=false; then use Drift reconciliation to configuration.
  2. First use removed block with destroy=false; then use terraform state mv.
  3. First use Drift reconciliation to configuration; then use Remote drift detection during plan.
  4. First use Remote drift detection during plan; then use terraform state mv.
  5. First use terraform state mv; then use removed block with destroy=false.

Explanation

Correct Answer

B:

The first requirement, to stop tracking an object in state but deliberately leave it deployed, is handled by removed block with destroy=false: A removed block declares that Terraform should forget a resource without deleting it when destroy=false. The second requirement, to change a resource state address to match a configuration refactor, is handled by terraform state mv: state mv rebinds an existing object under a new compatible address. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to stop tracking an object in state but deliberately leave it deployed and change a resource state address to match a configuration refactor, the first candidate removed block with destroy=false addresses stop tracking an object in state but deliberately leave it deployed; the second candidate Drift reconciliation to configuration addresses restore externally modified resource settings to desired code values. This mapping fails because the second mechanism primarily supports the task to restore externally modified resource settings to desired code values; the actual requirements are stop tracking an object in state but deliberately leave it deployed first and change a resource state address to match a configuration refactor second.

C:

For the requested tasks to stop tracking an object in state but deliberately leave it deployed and change a resource state address to match a configuration refactor, the first candidate Drift reconciliation to configuration addresses restore externally modified resource settings to desired code values; the second candidate Remote drift detection during plan addresses recognize that a resource was changed outside Terraform. This mapping fails because the first mechanism primarily supports the task to restore externally modified resource settings to desired code values and the second mechanism primarily supports the task to recognize that a resource was changed outside Terraform; the actual requirements are stop tracking an object in state but deliberately leave it deployed first and change a resource state address to match a configuration refactor second.

D:

For the requested tasks to stop tracking an object in state but deliberately leave it deployed and change a resource state address to match a configuration refactor, the first candidate Remote drift detection during plan addresses recognize that a resource was changed outside Terraform; the second candidate terraform state mv addresses change a resource state address to match a configuration refactor. This mapping fails because the first mechanism primarily supports the task to recognize that a resource was changed outside Terraform; the actual requirements are stop tracking an object in state but deliberately leave it deployed first and change a resource state address to match a configuration refactor second.

E:

For the requested tasks to stop tracking an object in state but deliberately leave it deployed and change a resource state address to match a configuration refactor, the first candidate terraform state mv addresses change a resource state address to match a configuration refactor; the second candidate removed block with destroy=false addresses stop tracking an object in state but deliberately leave it deployed. This mapping fails because the first mechanism primarily supports the task to change a resource state address to match a configuration refactor and the second mechanism primarily supports the task to stop tracking an object in state but deliberately leave it deployed; the actual requirements are stop tracking an object in state but deliberately leave it deployed first and change a resource state address to match a configuration refactor second.

HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests