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

Question 700

A Terraform rollout has two separate requirements: first, rename a managed resource address without destroying its remote object; second, detach a resource address from state while leaving the remote object intact. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use moved block for refactoring; then use terraform state rm.
  2. First use terraform state rm; then use moved block for refactoring.
  3. First use Drift reconciliation to configuration; then use terraform state rm.
  4. First use moved block for refactoring; then use terraform state mv.
  5. First use terraform state mv; then use Drift reconciliation to configuration.

Explanation

Correct Answer

A:

The first requirement, to rename a managed resource address without destroying its remote object, is handled by moved block for refactoring: A moved block describes an address migration as part of configuration history. The second requirement, to detach a resource address from state while leaving the remote object intact, is handled by terraform state rm: state rm forgets the binding but does not delete the real infrastructure object. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to rename a managed resource address without destroying its remote object and detach a resource address from state while leaving the remote object intact, the first candidate terraform state rm addresses detach a resource address from state while leaving the remote object intact; the second candidate moved block for refactoring addresses rename a managed resource address without destroying its remote object. This mapping fails because the first mechanism primarily supports the task to detach a resource address from state while leaving the remote object intact and the second mechanism primarily supports the task to rename a managed resource address without destroying its remote object; the actual requirements are rename a managed resource address without destroying its remote object first and detach a resource address from state while leaving the remote object intact second.

C:

For the requested tasks to rename a managed resource address without destroying its remote object and detach a resource address from state while leaving the remote object intact, the first candidate Drift reconciliation to configuration addresses restore externally modified resource settings to desired code values; the second candidate terraform state rm addresses detach a resource address from state while leaving the remote object intact. This mapping fails because the first mechanism primarily supports the task to restore externally modified resource settings to desired code values; the actual requirements are rename a managed resource address without destroying its remote object first and detach a resource address from state while leaving the remote object intact second.

D:

For the requested tasks to rename a managed resource address without destroying its remote object and detach a resource address from state while leaving the remote object intact, the first candidate moved block for refactoring addresses rename a managed resource address without destroying its remote object; the second candidate terraform state mv addresses change a resource state address to match a configuration refactor. This mapping fails because the second mechanism primarily supports the task to change a resource state address to match a configuration refactor; the actual requirements are rename a managed resource address without destroying its remote object first and detach a resource address from state while leaving the remote object intact second.

E:

For the requested tasks to rename a managed resource address without destroying its remote object and detach a resource address from state while leaving the remote object intact, the first candidate terraform state mv addresses change a resource state address to match a configuration refactor; the second candidate Drift reconciliation to configuration addresses restore externally modified resource settings to desired code values. 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 restore externally modified resource settings to desired code values; the actual requirements are rename a managed resource address without destroying its remote object first and detach a resource address from state while leaving the remote object intact second.

Question 701

A Terraform rollout has two separate requirements: first, configure cloud and on-premises platforms through a common workflow; second, use a common language without pretending providers expose identical capabilities. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Hybrid infrastructure automation; then use Provider-specific implementation.
  2. First use Vendor portability through modules; then use Provider-specific implementation.
  3. First use Provider-specific implementation; then use Hybrid infrastructure automation.
  4. First use Cross-platform dependency references; then use Vendor portability through modules.
  5. First use Hybrid infrastructure automation; then use Cross-platform dependency references.

Explanation

Correct Answer

A:

The first requirement, to configure cloud and on-premises platforms through a common workflow, is handled by Hybrid infrastructure automation: Terraform can coordinate providers for hosted services and private infrastructure without imposing one cloud API. The second requirement, to use a common language without pretending providers expose identical capabilities, is handled by Provider-specific implementation: HCL and workflow are common while each provider defines its own resource schema and service-specific behavior. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to configure cloud and on-premises platforms through a common workflow and use a common language without pretending providers expose identical capabilities, the first candidate Vendor portability through modules addresses abstract a deployment pattern while keeping provider details explicit; the second candidate Provider-specific implementation addresses use a common language without pretending providers expose identical capabilities. This mapping fails because the first mechanism primarily supports the task to abstract a deployment pattern while keeping provider details explicit; the actual requirements are configure cloud and on-premises platforms through a common workflow first and use a common language without pretending providers expose identical capabilities second.

C:

For the requested tasks to configure cloud and on-premises platforms through a common workflow and use a common language without pretending providers expose identical capabilities, the first candidate Provider-specific implementation addresses use a common language without pretending providers expose identical capabilities; the second candidate Hybrid infrastructure automation addresses configure cloud and on-premises platforms through a common workflow. This mapping fails because the first mechanism primarily supports the task to use a common language without pretending providers expose identical capabilities and the second mechanism primarily supports the task to configure cloud and on-premises platforms through a common workflow; the actual requirements are configure cloud and on-premises platforms through a common workflow first and use a common language without pretending providers expose identical capabilities second.

D:

For the requested tasks to configure cloud and on-premises platforms through a common workflow and use a common language without pretending providers expose identical capabilities, the first candidate Cross-platform dependency references addresses use output from one service to configure another supported service; the second candidate Vendor portability through modules addresses abstract a deployment pattern while keeping provider details explicit. This mapping fails because the first mechanism primarily supports the task to use output from one service to configure another supported service and the second mechanism primarily supports the task to abstract a deployment pattern while keeping provider details explicit; the actual requirements are configure cloud and on-premises platforms through a common workflow first and use a common language without pretending providers expose identical capabilities second.

E:

For the requested tasks to configure cloud and on-premises platforms through a common workflow and use a common language without pretending providers expose identical capabilities, the first candidate Hybrid infrastructure automation addresses configure cloud and on-premises platforms through a common workflow; the second candidate Cross-platform dependency references addresses use output from one service to configure another supported service. This mapping fails because the second mechanism primarily supports the task to use output from one service to configure another supported service; the actual requirements are configure cloud and on-premises platforms through a common workflow first and use a common language without pretending providers expose identical capabilities second.

Question 702

A Terraform rollout has two separate requirements: first, fetch a newly allowed version after editing the module version requirement; second, update a local path module without applying registry release versioning. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Module release compatibility; then use Module versus provider version lock.
  2. First use Local module development lifecycle; then use Module upgrade through init.
  3. First use Module versus provider version lock; then use Local module development lifecycle.
  4. First use Module upgrade through init; then use Local module development lifecycle.
  5. First use Module upgrade through init; then use Module release compatibility.

Explanation

Correct Answer

D:

The first requirement, to fetch a newly allowed version after editing the module version requirement, is handled by Module upgrade through init: Rerunning terraform init downloads compatible module source versions when module requirements change. The second requirement, to update a local path module without applying registry release versioning, is handled by Local module development lifecycle: Local module source code is read from its path and does not use a version argument. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to fetch a newly allowed version after editing the module version requirement and update a local path module without applying registry release versioning, the first candidate Module release compatibility addresses constrain a module to releases with an expected interface; the second candidate Module versus provider version lock addresses track module release selection separately from provider lock file behavior. This mapping fails because the first mechanism primarily supports the task to constrain a module to releases with an expected interface and the second mechanism primarily supports the task to track module release selection separately from provider lock file behavior; the actual requirements are fetch a newly allowed version after editing the module version requirement first and update a local path module without applying registry release versioning second.

B:

For the requested tasks to fetch a newly allowed version after editing the module version requirement and update a local path module without applying registry release versioning, the first candidate Local module development lifecycle addresses update a local path module without applying registry release versioning; the second candidate Module upgrade through init addresses fetch a newly allowed version after editing the module version requirement. This mapping fails because the first mechanism primarily supports the task to update a local path module without applying registry release versioning and the second mechanism primarily supports the task to fetch a newly allowed version after editing the module version requirement; the actual requirements are fetch a newly allowed version after editing the module version requirement first and update a local path module without applying registry release versioning second.

C:

For the requested tasks to fetch a newly allowed version after editing the module version requirement and update a local path module without applying registry release versioning, the first candidate Module versus provider version lock addresses track module release selection separately from provider lock file behavior; the second candidate Local module development lifecycle addresses update a local path module without applying registry release versioning. This mapping fails because the first mechanism primarily supports the task to track module release selection separately from provider lock file behavior; the actual requirements are fetch a newly allowed version after editing the module version requirement first and update a local path module without applying registry release versioning second.

E:

For the requested tasks to fetch a newly allowed version after editing the module version requirement and update a local path module without applying registry release versioning, the first candidate Module upgrade through init addresses fetch a newly allowed version after editing the module version requirement; the second candidate Module release compatibility addresses constrain a module to releases with an expected interface. This mapping fails because the second mechanism primarily supports the task to constrain a module to releases with an expected interface; the actual requirements are fetch a newly allowed version after editing the module version requirement first and update a local path module without applying registry release versioning second.

Question 703

The implementation must both route CLI-driven operations to the intended HCP workspace and initiate workspace operations through familiar Terraform commands. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. HCP Terraform workspace selection
  2. cloud block HCP integration
  3. CLI-driven HCP runs
  4. Local to HCP state migration
  5. Terraform CLI login to HCP

Explanation

Correct Answers

A:

Among the paired tasks to route CLI-driven operations to the intended HCP workspace and initiate workspace operations through familiar Terraform commands, HCP Terraform workspace selection serves the requirement to route CLI-driven operations to the intended HCP workspace: The cloud block workspace settings determine which HCP workspace the configuration uses. The other task must be covered by a separate mechanism.

C:

Among the paired tasks to route CLI-driven operations to the intended HCP workspace and initiate workspace operations through familiar Terraform commands, CLI-driven HCP runs serves the requirement to initiate workspace operations through familiar Terraform commands: HCP Terraform supports CLI-driven workflows connected to remote workspace state and operations. The other task must be covered by a separate mechanism.

Incorrect Answers

B:

The requirements are route CLI-driven operations to the intended HCP workspace and initiate workspace operations through familiar Terraform commands, while cloud block HCP integration supports the different task to associate a Terraform root configuration with an HCP Terraform organization and workspace: A cloud block in terraform settings configures the HCP Terraform integration for that root module. That capability is outside the two selected responsibilities.

D:

The requirements are route CLI-driven operations to the intended HCP workspace and initiate workspace operations through familiar Terraform commands, while Local to HCP state migration supports the different task to move a locally managed state history into an HCP Terraform workspace: Changing state integration and reinitializing can migrate state into HCP Terraform when configured correctly. That capability is outside the two selected responsibilities.

E:

The requirements are route CLI-driven operations to the intended HCP workspace and initiate workspace operations through familiar Terraform commands, while Terraform CLI login to HCP supports the different task to authenticate local Terraform CLI operations against HCP Terraform: terraform login starts an authentication workflow and stores a token for HCP Terraform access. That capability is outside the two selected responsibilities.

Question 704

A Terraform rollout has two separate requirements: first, write Terraform debug logging to a named file; second, focus verbose diagnostics on provider-side activity. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use TRACE diagnostic level; then use Disable debug logging after diagnosis.
  2. First use TF_LOG_PATH environment variable; then use TRACE diagnostic level.
  3. First use TF_LOG_PROVIDER environment variable; then use TF_LOG_PATH environment variable.
  4. First use Disable debug logging after diagnosis; then use TF_LOG_PROVIDER environment variable.
  5. First use TF_LOG_PATH environment variable; then use TF_LOG_PROVIDER environment variable.

Explanation

Correct Answer

E:

The first requirement, to write Terraform debug logging to a named file, is handled by TF_LOG_PATH environment variable: TF_LOG_PATH controls a file destination for Terraform logging when logging is enabled. The second requirement, to focus verbose diagnostics on provider-side activity, is handled by TF_LOG_PROVIDER environment variable: TF_LOG_PROVIDER controls the provider logging level to aid plugin or API troubleshooting. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to write Terraform debug logging to a named file and focus verbose diagnostics on provider-side activity, the first candidate TRACE diagnostic level addresses capture highly detailed events for a stubborn Terraform problem; the second candidate Disable debug logging after diagnosis addresses avoid collecting unnecessary sensitive operational output. This mapping fails because the first mechanism primarily supports the task to capture highly detailed events for a stubborn Terraform problem and the second mechanism primarily supports the task to avoid collecting unnecessary sensitive operational output; the actual requirements are write Terraform debug logging to a named file first and focus verbose diagnostics on provider-side activity second.

B:

For the requested tasks to write Terraform debug logging to a named file and focus verbose diagnostics on provider-side activity, the first candidate TF_LOG_PATH environment variable addresses write Terraform debug logging to a named file; the second candidate TRACE diagnostic level addresses capture highly detailed events for a stubborn Terraform problem. This mapping fails because the second mechanism primarily supports the task to capture highly detailed events for a stubborn Terraform problem; the actual requirements are write Terraform debug logging to a named file first and focus verbose diagnostics on provider-side activity second.

C:

For the requested tasks to write Terraform debug logging to a named file and focus verbose diagnostics on provider-side activity, the first candidate TF_LOG_PROVIDER environment variable addresses focus verbose diagnostics on provider-side activity; the second candidate TF_LOG_PATH environment variable addresses write Terraform debug logging to a named file. This mapping fails because the first mechanism primarily supports the task to focus verbose diagnostics on provider-side activity and the second mechanism primarily supports the task to write Terraform debug logging to a named file; the actual requirements are write Terraform debug logging to a named file first and focus verbose diagnostics on provider-side activity second.

D:

For the requested tasks to write Terraform debug logging to a named file and focus verbose diagnostics on provider-side activity, the first candidate Disable debug logging after diagnosis addresses avoid collecting unnecessary sensitive operational output; the second candidate TF_LOG_PROVIDER environment variable addresses focus verbose diagnostics on provider-side activity. This mapping fails because the first mechanism primarily supports the task to avoid collecting unnecessary sensitive operational output; the actual requirements are write Terraform debug logging to a named file first and focus verbose diagnostics on provider-side activity second.

Question 705

The deployment owner requests a reliable way to calculate collection values without an external provisioner. Which mechanism most directly meets this particular need?

  1. for_each resource replication
  2. for expression list projection
  3. for expression filtering
  4. Dynamic nested block
  5. Template interpolation
  6. Built-in collection function

Explanation

Correct Answer

F:

The task is to calculate collection values without an external provisioner; Built-in collection function directly supports that requirement: Functions such as length, concat, and merge manipulate Terraform values during expression evaluation. Its relevant boundary is: A function call does not fetch remote provider resources unless a data source is used.

Incorrect Answers

A:

for_each resource replication is designed to create one resource instance per unique map or set key, whereas this task is to calculate collection values without an external provisioner: for_each expands a resource into stable keyed instances when its collection is known at planning. Against Built-in collection function, its limitation is: Keys cannot be unknown or derived directly from sensitive values.

B:

for expression list projection is designed to transform a collection into a list of calculated values, whereas this task is to calculate collection values without an external provisioner: A bracketed for expression maps each element to a new value using a declared iterator. Against Built-in collection function, its limitation is: A for expression calculates values but does not itself create resource instances.

C:

for expression filtering is designed to include only elements satisfying an if condition in a derived collection, whereas this task is to calculate collection values without an external provisioner: A for expression's optional if clause filters elements while projecting results. Against Built-in collection function, its limitation is: Filtering a collection is different from lifecycle ignore_changes.

D:

Dynamic nested block is designed to generate repeated nested configuration blocks from a collection, whereas this task is to calculate collection values without an external provisioner: A dynamic block emits nested blocks where the enclosing resource schema permits them. Against Built-in collection function, its limitation is: Dynamic cannot generate resource or provider blocks at the root level.

E:

Template interpolation is designed to embed evaluated expressions in a Terraform string, whereas this task is to calculate collection values without an external provisioner: The ${...} syntax can interpolate an expression into a quoted string or template. Against Built-in collection function, its limitation is: Interpolation is not required when an argument can take a direct expression reference.

Question 706

A reviewer is asked to choose a mechanism to inspect externally changed infrastructure without planning configuration reconciliation. Which mechanism most directly meets this particular need?

  1. Plan without state refresh
  2. Refresh-only planning
  3. Plan saved to file
  4. terraform plan command
  5. Targeted planning

Explanation

Correct Answer

B:

The task is to inspect externally changed infrastructure without planning configuration reconciliation; Refresh-only planning directly supports that requirement: terraform plan -refresh-only proposes updates to state and outputs based on remote observations. Its relevant boundary is: It does not use configuration to correct drift in the remote service.

Incorrect Answers

A:

Plan without state refresh is designed to avoid remote refresh reads when an intentional troubleshooting constraint requires it, whereas this task is to inspect externally changed infrastructure without planning configuration reconciliation: terraform plan -refresh=false uses existing state without refreshing live objects before planning. Against Refresh-only planning, its limitation is: A plan based on stale state can be inaccurate about real infrastructure.

C:

Plan saved to file is designed to capture one execution plan for later approval and application, whereas this task is to inspect externally changed infrastructure without planning configuration reconciliation: terraform plan -out=change.tfplan saves an executable binary plan artifact. Against Refresh-only planning, its limitation is: Saved plans can include sensitive data and should not be committed publicly.

D:

terraform plan command is designed to preview actions required to reach the declared infrastructure state, whereas this task is to inspect externally changed infrastructure without planning configuration reconciliation: terraform plan shows changes Terraform expects, including creates, updates, deletes, and replacements. Against Refresh-only planning, its limitation is: Plan does not persist the proposed changes to remote infrastructure.

E:

Targeted planning is designed to focus on a small subset for exceptional repair or troubleshooting, whereas this task is to inspect externally changed infrastructure without planning configuration reconciliation: terraform plan -target=ADDRESS limits the planner's focus to the selected graph portion. Against Refresh-only planning, its limitation is: Routine targeted planning can overlook intended changes elsewhere.

Question 707

A reviewer is asked to choose a mechanism to declare several provider types in the same root module. Which mechanism most directly meets this particular need?

  1. Resource provider meta-argument
  2. Explicit child module provider mapping
  3. Default provider configuration inheritance
  4. Different provider local names

Explanation

Correct Answer

D:

The task is to declare several provider types in the same root module; Different provider local names directly supports that requirement: The required_providers map can list multiple source addresses with distinct local names. Its relevant boundary is: Resources still use their provider-defined schemas and credentials.

Incorrect Answers

A:

Resource provider meta-argument is designed to direct an individual resource to the intended aliased provider, whereas this task is to declare several provider types in the same root module: The provider meta-argument can select a configured instance such as aws.west for that resource. Against Different provider local names, its limitation is: The alias must be declared and satisfy provider requirements.

B:

Explicit child module provider mapping is designed to pass an aliased provider to resources inside a child module, whereas this task is to declare several provider types in the same root module: The providers map in a module block maps the child's provider name to a parent provider configuration. Against Different provider local names, its limitation is: A child module cannot automatically see every parent alias just because it exists.

C:

Default provider configuration inheritance addresses the different requirement to let a child module use default provider settings from its parent: Child modules commonly inherit default provider configurations from the calling module; this does not by itself satisfy the requested task to declare several provider types in the same root module. For the stated need, Different provider local names is the more direct mechanism.

Question 708

A team is adjusting its declarative infrastructure process to stop tracking an object in state but deliberately leave it deployed. Which mechanism most directly meets this particular need?

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

Explanation

Correct Answer

D:

The task is to stop tracking an object in state but deliberately leave it deployed; removed block with destroy=false directly supports that requirement: A removed block declares that Terraform should forget a resource without deleting it when destroy=false. Its relevant boundary is: Ordinary resource removal from HCL can instead lead to destruction.

Incorrect Answers

A:

Remote drift detection during plan is designed to recognize that a resource was changed outside Terraform, whereas this task is to stop tracking an object in state but deliberately leave it deployed: Normal plan refresh reads can reveal drift between state and the remote object. Against removed block with destroy=false, its limitation is: Configuration reconciliation requires a subsequent reviewed apply.

B:

terraform state rm is designed to detach a resource address from state while leaving the remote object intact, whereas this task is to stop tracking an object in state but deliberately leave it deployed: state rm forgets the binding but does not delete the real infrastructure object. Against removed block with destroy=false, its limitation is: If its configuration remains, a later plan can propose creating another object.

C:

terraform state mv is designed to change a resource state address to match a configuration refactor, whereas this task is to stop tracking an object in state but deliberately leave it deployed: state mv rebinds an existing object under a new compatible address. Against removed block with destroy=false, its limitation is: It does not rename or migrate the remote object through its provider API.

E:

Drift reconciliation to configuration is designed to restore externally modified resource settings to desired code values, whereas this task is to stop tracking an object in state but deliberately leave it deployed: A regular plan and apply can propose changing a drifted object back to configured settings. Against removed block with destroy=false, its limitation is: A refresh-only apply instead accepts observed remote values into state.

Question 709

The deployment owner requests a reliable way to pin a VCS module using its source ref rather than registry version. Which mechanism most directly meets this particular need?

  1. Version of Git module
  2. Module release compatibility
  3. Module versus provider version lock
  4. Local module development lifecycle

Explanation

Correct Answer

A:

The task is to pin a VCS module using its source ref rather than registry version; Version of Git module directly supports that requirement: A ?ref=tag or commit in a Git module source selects the VCS revision to fetch. Its relevant boundary is: The registry module version argument does not apply to generic Git sources.

Incorrect Answers

B:

Module release compatibility is designed to constrain a module to releases with an expected interface, whereas this task is to pin a VCS module using its source ref rather than registry version: A version range helps avoid inadvertently selecting a module revision with breaking input or output changes. Against Version of Git module, its limitation is: Version constraints cannot guarantee every patch release is defect-free.

C:

Module versus provider version lock is designed to track module release selection separately from provider lock file behavior, whereas this task is to pin a VCS module using its source ref rather than registry version: Module versions are selected by module source and version settings, whereas the lock file records providers. Against Version of Git module, its limitation is: Assuming .terraform.lock.hcl freezes registry modules can surprise a new installation.

D:

Local module development lifecycle is designed to update a local path module without applying registry release versioning, whereas this task is to pin a VCS module using its source ref rather than registry version: Local module source code is read from its path and does not use a version argument. Against Version of Git module, its limitation is: A local edit can still change the next plan and should be reviewed.

Question 710

A deployment design calls for a supported way to move a locally managed state history into an HCP Terraform workspace. Which mechanism most directly meets this particular need?

  1. Terraform CLI login to HCP
  2. cloud block HCP integration
  3. CLI-driven HCP runs
  4. Local to HCP state migration

Explanation

Correct Answer

D:

The task is to move a locally managed state history into an HCP Terraform workspace; Local to HCP state migration directly supports that requirement: Changing state integration and reinitializing can migrate state into HCP Terraform when configured correctly. Its relevant boundary is: A migration should be backed up and verified before discarding the local copy.

Incorrect Answers

A:

Terraform CLI login to HCP is designed to authenticate local Terraform CLI operations against HCP Terraform, whereas this task is to move a locally managed state history into an HCP Terraform workspace: terraform login starts an authentication workflow and stores a token for HCP Terraform access. Against Local to HCP state migration, its limitation is: A CLI token is not a cloud provider's deployment credential.

B:

cloud block HCP integration is designed to associate a Terraform root configuration with an HCP Terraform organization and workspace, whereas this task is to move a locally managed state history into an HCP Terraform workspace: A cloud block in terraform settings configures the HCP Terraform integration for that root module. Against Local to HCP state migration, its limitation is: It should not be combined with a separate backend block in the same root configuration.

C:

CLI-driven HCP runs addresses the different requirement to initiate workspace operations through familiar Terraform commands: HCP Terraform supports CLI-driven workflows connected to remote workspace state and operations; this does not by itself satisfy the requested task to move a locally managed state history into an HCP Terraform workspace. For the stated need, Local to HCP state migration is the more direct mechanism.

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