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

Question 650

Before adopting for expression filtering to include only elements satisfying an if condition in a derived collection, which statement sets an accurate boundary?

  1. The two branches need compatible types for Terraform to reconcile the result.
  2. Interpolation is not required when an argument can take a direct expression reference.
  3. Filtering a collection is different from lifecycle ignore_changes.
  4. A function call does not fetch remote provider resources unless a data source is used.
  5. A for expression calculates values but does not itself create resource instances.

Explanation

Correct Answer

C:

For for expression filtering in the task to include only elements satisfying an if condition in a derived collection, the important caution is: Filtering a collection is different from lifecycle ignore_changes. The reason this matters is its actual behavior: A for expression's optional if clause filters elements while projecting results.

Incorrect Answers

A:

The proposed warning belongs to Conditional expression, which serves the different goal to choose between two values based on a boolean condition, rather than to for expression filtering: Terraform's condition ? true_value : false_value expression selects a value based on a predicate. The question concerns for expression filtering acting to include only elements satisfying an if condition in a derived collection, not a limit of Conditional expression.

B:

The proposed warning belongs to Template interpolation, which serves the different goal to embed evaluated expressions in a Terraform string, rather than to for expression filtering: The ${...} syntax can interpolate an expression into a quoted string or template. The question concerns for expression filtering acting to include only elements satisfying an if condition in a derived collection, not a limit of Template interpolation.

D:

The proposed warning belongs to Built-in collection function, which serves the different goal to calculate collection values without an external provisioner, rather than to for expression filtering: Functions such as length, concat, and merge manipulate Terraform values during expression evaluation. The question concerns for expression filtering acting to include only elements satisfying an if condition in a derived collection, not a limit of Built-in collection function.

E:

The proposed warning belongs to for expression list projection, which serves the different goal to transform a collection into a list of calculated values, rather than to for expression filtering: A bracketed for expression maps each element to a new value using a declared iterator. The question concerns for expression filtering acting to include only elements satisfying an if condition in a derived collection, not a limit of for expression list projection.

Question 651

In a reusable deployment, the primary objective is to make a published module dependency deterministic across clean installs. Which mechanism most directly meets this particular need?

  1. Local module development lifecycle
  2. Module release compatibility
  3. Exact registry module version
  4. Module versus provider version lock

Explanation

Correct Answer

C:

The task is to make a published module dependency deterministic across clean installs; Exact registry module version directly supports that requirement: An exact version requirement identifies one registry module release. Its relevant boundary is: Pinning a module does not pin its provider dependencies unless constrained separately.

Incorrect Answers

A:

Local module development lifecycle is designed to update a local path module without applying registry release versioning, whereas this task is to make a published module dependency deterministic across clean installs: Local module source code is read from its path and does not use a version argument. Against Exact registry module version, its limitation is: A local edit can still change the next plan and should be reviewed.

B:

Module release compatibility is designed to constrain a module to releases with an expected interface, whereas this task is to make a published module dependency deterministic across clean installs: A version range helps avoid inadvertently selecting a module revision with breaking input or output changes. Against Exact registry module version, its limitation is: Version constraints cannot guarantee every patch release is defect-free.

D:

Module versus provider version lock is designed to track module release selection separately from provider lock file behavior, whereas this task is to make a published module dependency deterministic across clean installs: Module versions are selected by module source and version settings, whereas the lock file records providers. Against Exact registry module version, its limitation is: Assuming .terraform.lock.hcl freezes registry modules can surprise a new installation.

Question 652

A reviewer is asked to choose a mechanism to associate a Terraform root configuration with an HCP Terraform organization and workspace. Which mechanism most directly meets this particular need?

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

Explanation

Correct Answer

D:

The task is to associate a Terraform root configuration with an HCP Terraform organization and workspace; cloud block HCP integration directly supports that requirement: A cloud block in terraform settings configures the HCP Terraform integration for that root module. Its relevant boundary is: It should not be combined with a separate backend block in the same root configuration.

Incorrect Answers

A:

Local to HCP state migration is designed to move a locally managed state history into an HCP Terraform workspace, whereas this task is to associate a Terraform root configuration with an HCP Terraform organization and workspace: Changing state integration and reinitializing can migrate state into HCP Terraform when configured correctly. Against cloud block HCP integration, its limitation is: A migration should be backed up and verified before discarding the local copy.

B:

Terraform CLI login to HCP is designed to authenticate local Terraform CLI operations against HCP Terraform, whereas this task is to associate a Terraform root configuration with an HCP Terraform organization and workspace: terraform login starts an authentication workflow and stores a token for HCP Terraform access. Against cloud block HCP integration, its limitation is: A CLI token is not a cloud provider's deployment credential.

C:

HCP Terraform workspace selection is designed to route CLI-driven operations to the intended HCP workspace, whereas this task is to associate a Terraform root configuration with an HCP Terraform organization and workspace: The cloud block workspace settings determine which HCP workspace the configuration uses. Against cloud block HCP integration, its limitation is: Selecting the wrong workspace can target a different infrastructure state.

Question 653

A Terraform rollout has two separate requirements: first, configure a second instance of the same provider for another account or region; second, declare several provider types in the same root module. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Aliased provider instance; then use Different provider local names.
  2. First use Explicit child module provider mapping; then use Default provider configuration inheritance.
  3. First use Default provider configuration inheritance; then use Different provider local names.
  4. First use Different provider local names; then use Aliased provider instance.
  5. First use Aliased provider instance; then use Explicit child module provider mapping.

Explanation

Correct Answer

A:

The first requirement, to configure a second instance of the same provider for another account or region, is handled by Aliased provider instance: The alias argument gives a provider configuration an additional address that resources can select. The second requirement, to declare several provider types in the same root module, is handled by Different provider local names: The required_providers map can list multiple source addresses with distinct local names. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to configure a second instance of the same provider for another account or region and declare several provider types in the same root module, the first candidate Explicit child module provider mapping addresses pass an aliased provider to resources inside a child module; the second candidate Default provider configuration inheritance addresses let a child module use default provider settings from its parent. This mapping fails because the first mechanism primarily supports the task to pass an aliased provider to resources inside a child module and the second mechanism primarily supports the task to let a child module use default provider settings from its parent; the actual requirements are configure a second instance of the same provider for another account or region first and declare several provider types in the same root module second.

C:

For the requested tasks to configure a second instance of the same provider for another account or region and declare several provider types in the same root module, the first candidate Default provider configuration inheritance addresses let a child module use default provider settings from its parent; the second candidate Different provider local names addresses declare several provider types in the same root module. This mapping fails because the first mechanism primarily supports the task to let a child module use default provider settings from its parent; the actual requirements are configure a second instance of the same provider for another account or region first and declare several provider types in the same root module second.

D:

For the requested tasks to configure a second instance of the same provider for another account or region and declare several provider types in the same root module, the first candidate Different provider local names addresses declare several provider types in the same root module; the second candidate Aliased provider instance addresses configure a second instance of the same provider for another account or region. This mapping fails because the first mechanism primarily supports the task to declare several provider types in the same root module and the second mechanism primarily supports the task to configure a second instance of the same provider for another account or region; the actual requirements are configure a second instance of the same provider for another account or region first and declare several provider types in the same root module second.

E:

For the requested tasks to configure a second instance of the same provider for another account or region and declare several provider types in the same root module, the first candidate Aliased provider instance addresses configure a second instance of the same provider for another account or region; the second candidate Explicit child module provider mapping addresses pass an aliased provider to resources inside a child module. This mapping fails because the second mechanism primarily supports the task to pass an aliased provider to resources inside a child module; the actual requirements are configure a second instance of the same provider for another account or region first and declare several provider types in the same root module second.

Question 654

A Terraform rollout has two separate requirements: first, include only elements satisfying an if condition in a derived collection; second, embed evaluated expressions in a Terraform string. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Dynamic nested block; then use Template interpolation.
  2. First use Built-in collection function; then use Dynamic nested block.
  3. First use Template interpolation; then use for expression filtering.
  4. First use for expression filtering; then use Built-in collection function.
  5. First use for expression filtering; then use Template interpolation.

Explanation

Correct Answer

E:

The first requirement, to include only elements satisfying an if condition in a derived collection, is handled by for expression filtering: A for expression's optional if clause filters elements while projecting results. The second requirement, to embed evaluated expressions in a Terraform string, is handled by Template interpolation: The ${...} syntax can interpolate an expression into a quoted string or template. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to include only elements satisfying an if condition in a derived collection and embed evaluated expressions in a Terraform string, the first candidate Dynamic nested block addresses generate repeated nested configuration blocks from a collection; the second candidate Template interpolation addresses embed evaluated expressions in a Terraform string. This mapping fails because the first mechanism primarily supports the task to generate repeated nested configuration blocks from a collection; the actual requirements are include only elements satisfying an if condition in a derived collection first and embed evaluated expressions in a Terraform string second.

B:

For the requested tasks to include only elements satisfying an if condition in a derived collection and embed evaluated expressions in a Terraform string, the first candidate Built-in collection function addresses calculate collection values without an external provisioner; the second candidate Dynamic nested block addresses generate repeated nested configuration blocks from a collection. This mapping fails because the first mechanism primarily supports the task to calculate collection values without an external provisioner and the second mechanism primarily supports the task to generate repeated nested configuration blocks from a collection; the actual requirements are include only elements satisfying an if condition in a derived collection first and embed evaluated expressions in a Terraform string second.

C:

For the requested tasks to include only elements satisfying an if condition in a derived collection and embed evaluated expressions in a Terraform string, the first candidate Template interpolation addresses embed evaluated expressions in a Terraform string; 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 embed evaluated expressions in a Terraform string and the second mechanism primarily supports the task to include only elements satisfying an if condition in a derived collection; the actual requirements are include only elements satisfying an if condition in a derived collection first and embed evaluated expressions in a Terraform string second.

D:

For the requested tasks to include only elements satisfying an if condition in a derived collection and embed evaluated expressions in a Terraform string, the first candidate for expression filtering addresses include only elements satisfying an if condition in a derived collection; the second candidate Built-in collection function addresses calculate collection values without an external provisioner. This mapping fails because the second mechanism primarily supports the task to calculate collection values without an external provisioner; the actual requirements are include only elements satisfying an if condition in a derived collection first and embed evaluated expressions in a Terraform string second.

Question 655

An operator chooses the mechanism "Plan saved to file" for a Terraform project. Which outcome should this choice support?

  1. capture one execution plan for later approval and application
  2. focus on a small subset for exceptional repair or troubleshooting
  3. inspect externally changed infrastructure without planning configuration reconciliation
  4. preview actions required to reach the declared infrastructure state

Explanation

Correct Answer

A:

The practical result of Plan saved to file, used to capture one execution plan for later approval and application, is: terraform plan -out=change.tfplan saves an executable binary plan artifact. A qualification for this effect is: Saved plans can include sensitive data and should not be committed publicly.

Incorrect Answers

B:

That outcome applies to Targeted planning, intended to focus on a small subset for exceptional repair or troubleshooting, rather than the question's feature Plan saved to file: terraform plan -target=ADDRESS limits the planner's focus to the selected graph portion. Unlike Targeted planning, Plan saved to file is intended to capture one execution plan for later approval and application, not to focus on a small subset for exceptional repair or troubleshooting.

C:

That outcome applies to Refresh-only planning, intended to inspect externally changed infrastructure without planning configuration reconciliation, rather than the question's feature Plan saved to file: terraform plan -refresh-only proposes updates to state and outputs based on remote observations. Unlike Refresh-only planning, Plan saved to file is intended to capture one execution plan for later approval and application, not to inspect externally changed infrastructure without planning configuration reconciliation.

D:

That outcome applies to terraform plan command, intended to preview actions required to reach the declared infrastructure state, rather than the question's feature Plan saved to file: terraform plan shows changes Terraform expects, including creates, updates, deletes, and replacements. Unlike terraform plan command, Plan saved to file is intended to capture one execution plan for later approval and application, not to preview actions required to reach the declared infrastructure state.

Question 656

A team reviews the use of Refresh-only reconciliation in Terraform 1.12. Which purpose matches its actual behavior?

  1. restore externally modified resource settings to desired code values
  2. change a resource state address to match a configuration refactor
  3. detach a resource address from state while leaving the remote object intact
  4. accept an external change into Terraform state without modifying remote infrastructure

Explanation

Correct Answer

D:

The practical result of Refresh-only reconciliation, used to accept an external change into Terraform state without modifying remote infrastructure, is: A refresh-only plan or apply updates state and outputs to observed values. A qualification for this effect is: It does not make the live object conform to an old configuration value.

Incorrect Answers

A:

That outcome applies to Drift reconciliation to configuration, intended to restore externally modified resource settings to desired code values, rather than the question's feature Refresh-only reconciliation: A regular plan and apply can propose changing a drifted object back to configured settings. Unlike Drift reconciliation to configuration, Refresh-only reconciliation is intended to accept an external change into Terraform state without modifying remote infrastructure, not to restore externally modified resource settings to desired code values.

B:

That outcome applies to terraform state mv, intended to change a resource state address to match a configuration refactor, rather than the question's feature Refresh-only reconciliation: state mv rebinds an existing object under a new compatible address. Unlike terraform state mv, Refresh-only reconciliation is intended to accept an external change into Terraform state without modifying remote infrastructure, not to change a resource state address to match a configuration refactor.

C:

That outcome applies to terraform state rm, intended to detach a resource address from state while leaving the remote object intact, rather than the question's feature Refresh-only reconciliation: state rm forgets the binding but does not delete the real infrastructure object. Unlike terraform state rm, Refresh-only reconciliation is intended to accept an external change into Terraform state without modifying remote infrastructure, not to detach a resource address from state while leaving the remote object intact.

Question 657

The implementation must both manage different clouds from one Terraform root module and control DNS, SaaS, and cloud resources through a common configuration tool. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. Provider-specific implementation
  2. Cross-platform dependency references
  3. Hybrid infrastructure automation
  4. Service-agnostic orchestration
  5. Multi-cloud provider configuration

Explanation

Correct Answers

D:

Among the paired tasks to manage different clouds from one Terraform root module and control DNS, SaaS, and cloud resources through a common configuration tool, Service-agnostic orchestration serves the requirement to control DNS, SaaS, and cloud resources through a common configuration tool: Terraform providers expose resource and data types beyond infrastructure hosted by a cloud vendor. The other task must be covered by a separate mechanism.

E:

Among the paired tasks to manage different clouds from one Terraform root module and control DNS, SaaS, and cloud resources through a common configuration tool, Multi-cloud provider configuration serves the requirement to manage different clouds from one Terraform root module: Separate provider plugins can reconcile resources on multiple platforms within the same configuration. The other task must be covered by a separate mechanism.

Incorrect Answers

A:

The requirements are manage different clouds from one Terraform root module and control DNS, SaaS, and cloud resources through a common configuration tool, while Provider-specific implementation supports the different task to use a common language without pretending providers expose identical capabilities: HCL and workflow are common while each provider defines its own resource schema and service-specific behavior. That capability is outside the two selected responsibilities.

B:

The requirements are manage different clouds from one Terraform root module and control DNS, SaaS, and cloud resources through a common configuration tool, while Cross-platform dependency references supports the different task to use output from one service to configure another supported service: References can establish ordering when a resource on one platform consumes attributes from another resource. That capability is outside the two selected responsibilities.

C:

The requirements are manage different clouds from one Terraform root module and control DNS, SaaS, and cloud resources through a common configuration tool, while Hybrid infrastructure automation supports the different task to configure cloud and on-premises platforms through a common workflow: Terraform can coordinate providers for hosted services and private infrastructure without imposing one cloud API. That capability is outside the two selected responsibilities.

Question 658

A Terraform runbook describes the mechanism "Exact registry module version". Which responsibility should a reviewer associate with it?

  1. constrain a module to releases with an expected interface
  2. update a local path module without applying registry release versioning
  3. track module release selection separately from provider lock file behavior
  4. make a published module dependency deterministic across clean installs

Explanation

Correct Answer

D:

The practical result of Exact registry module version, used to make a published module dependency deterministic across clean installs, is: An exact version requirement identifies one registry module release. A qualification for this effect is: Pinning a module does not pin its provider dependencies unless constrained separately.

Incorrect Answers

A:

That outcome applies to Module release compatibility, intended to constrain a module to releases with an expected interface, rather than the question's feature Exact registry module version: A version range helps avoid inadvertently selecting a module revision with breaking input or output changes. Unlike Module release compatibility, Exact registry module version is intended to make a published module dependency deterministic across clean installs, not to constrain a module to releases with an expected interface.

B:

That outcome applies to Local module development lifecycle, intended to update a local path module without applying registry release versioning, rather than the question's feature Exact registry module version: Local module source code is read from its path and does not use a version argument. Unlike Local module development lifecycle, Exact registry module version is intended to make a published module dependency deterministic across clean installs, not to update a local path module without applying registry release versioning.

C:

That outcome applies to Module versus provider version lock, intended to track module release selection separately from provider lock file behavior, rather than the question's feature Exact registry module version: Module versions are selected by module source and version settings, whereas the lock file records providers. Unlike Module versus provider version lock, Exact registry module version is intended to make a published module dependency deterministic across clean installs, not to track module release selection separately from provider lock file behavior.

Question 659

A configuration walkthrough identifies "cloud block HCP integration". Which task is it principally intended to support?

  1. associate a Terraform root configuration with an HCP Terraform organization and workspace
  2. move a locally managed state history into an HCP Terraform workspace
  3. authenticate local Terraform CLI operations against HCP Terraform
  4. route CLI-driven operations to the intended HCP workspace

Explanation

Correct Answer

A:

The practical result of cloud block HCP integration, used to associate a Terraform root configuration with an HCP Terraform organization and workspace, is: A cloud block in terraform settings configures the HCP Terraform integration for that root module. A qualification for this effect is: It should not be combined with a separate backend block in the same root configuration.

Incorrect Answers

B:

That outcome applies to Local to HCP state migration, intended to move a locally managed state history into an HCP Terraform workspace, rather than the question's feature cloud block HCP integration: Changing state integration and reinitializing can migrate state into HCP Terraform when configured correctly. Unlike Local to HCP state migration, cloud block HCP integration is intended to associate a Terraform root configuration with an HCP Terraform organization and workspace, not to move a locally managed state history into an HCP Terraform workspace.

C:

That outcome applies to Terraform CLI login to HCP, intended to authenticate local Terraform CLI operations against HCP Terraform, rather than the question's feature cloud block HCP integration: terraform login starts an authentication workflow and stores a token for HCP Terraform access. Unlike Terraform CLI login to HCP, cloud block HCP integration is intended to associate a Terraform root configuration with an HCP Terraform organization and workspace, not to authenticate local Terraform CLI operations against HCP Terraform.

D:

That outcome applies to HCP Terraform workspace selection, intended to route CLI-driven operations to the intended HCP workspace, rather than the question's feature cloud block HCP integration: The cloud block workspace settings determine which HCP workspace the configuration uses. Unlike HCP Terraform workspace selection, cloud block HCP integration is intended to associate a Terraform root configuration with an HCP Terraform organization and workspace, not to route CLI-driven operations to the intended HCP workspace.

Question 660

The implementation must both enable Terraform debugging output while investigating a CLI failure and focus debugging on Terraform Core behavior rather than provider messages. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. TF_LOG_PATH environment variable
  2. TF_LOG_CORE environment variable
  3. TRACE diagnostic level
  4. TF_LOG environment variable
  5. TF_LOG_PROVIDER environment variable

Explanation

Correct Answers

B:

Among the paired tasks to enable Terraform debugging output while investigating a CLI failure and focus debugging on Terraform Core behavior rather than provider messages, TF_LOG_CORE environment variable serves the requirement to focus debugging on Terraform Core behavior rather than provider messages: TF_LOG_CORE can set logging for Terraform Core separately from provider plugin output. The other task must be covered by a separate mechanism.

D:

Among the paired tasks to enable Terraform debugging output while investigating a CLI failure and focus debugging on Terraform Core behavior rather than provider messages, TF_LOG environment variable serves the requirement to enable Terraform debugging output while investigating a CLI failure: TF_LOG sets a supported logging level such as DEBUG or TRACE for a Terraform process. The other task must be covered by a separate mechanism.

Incorrect Answers

A:

The requirements are enable Terraform debugging output while investigating a CLI failure and focus debugging on Terraform Core behavior rather than provider messages, while TF_LOG_PATH environment variable supports the different task to write Terraform debug logging to a named file: TF_LOG_PATH controls a file destination for Terraform logging when logging is enabled. That capability is outside the two selected responsibilities.

C:

The requirements are enable Terraform debugging output while investigating a CLI failure and focus debugging on Terraform Core behavior rather than provider messages, while TRACE diagnostic level supports the different task to capture highly detailed events for a stubborn Terraform problem: TRACE is a very verbose Terraform logging level useful for deep troubleshooting. That capability is outside the two selected responsibilities.

E:

The requirements are enable Terraform debugging output while investigating a CLI failure and focus debugging on Terraform Core behavior rather than provider messages, while TF_LOG_PROVIDER environment variable supports the different task to focus verbose diagnostics on provider-side activity: TF_LOG_PROVIDER controls the provider logging level to aid plugin or API troubleshooting. That capability is outside the two selected responsibilities.

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