HashiCorp Terraform Associate (HashiCorp Certified: Terraform Associate) Practice Test 4

Question 30

A Terraform change proposal names “A state import workflow” to associate existing infrastructure with a newly declared Terraform resource address. Which outcome can reviewers attribute to that particular mechanism?

  1. Configuration still describes the preferred value, so normal planning can propose undoing an out-of-band modification unless ignored.
  2. Refresh-only apply can update the recorded state to match observed remote attributes without modifying cloud resources.
  3. The lifecycle ignore_changes rule suppresses post-creation update plans for selected attributes while leaving other attributes managed.
  4. The state pull command retrieves state from the configured backend and prints a snapshot that may contain secrets.
  5. Importing attaches the remote object's identity to state; compatible configuration is still needed to avoid unwanted changes afterward.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to associate existing infrastructure with a newly declared Terraform resource address, so it produces the behavior described. In contrast, terraform apply -refresh-only serves a different goal: accept current remote readings into Terraform's state through an apply operation, not associate existing infrastructure with a newly declared Terraform resource address.

Incorrect Answers

A:

The description applies to a refreshed changed resource when an engineer needs to understand why Terraform tries to reset a manually edited resource attribute; the named a state import workflow instead handles the requirement to associate existing infrastructure with a newly declared Terraform resource address, so this behavior does not describe A state import workflow in the situation named.

B:

The description applies to terraform apply -refresh-only when an engineer needs to accept current remote readings into Terraform's state through an apply operation; the named a state import workflow instead handles the requirement to associate existing infrastructure with a newly declared Terraform resource address, so this behavior does not describe A state import workflow in the situation named.

C:

The description applies to ignore_changes for shared ownership when an engineer needs to stop Terraform from overwriting a field delegated to an external controller; the named a state import workflow instead handles the requirement to associate existing infrastructure with a newly declared Terraform resource address, so this behavior does not describe A state import workflow in the situation named.

D:

The description applies to terraform state pull when an engineer needs to obtain the current state snapshot for inspection or controlled backup; the named a state import workflow instead handles the requirement to associate existing infrastructure with a newly declared Terraform resource address, so this behavior does not describe A state import workflow in the situation named.

Question 31

An engineer preparing an infrastructure rollout requires a way to suppress Terraform's normal approval prompt in a controlled pipeline. Which Terraform approach most directly fulfills that request?

  1. Apply a saved plan
  2. terraform apply -parallelism
  3. Parallel graph execution
  4. terraform apply -auto-approve
  5. Refresh during apply planning

Explanation

Correct Answer

D:

The auto-approve option allows the automatically created plan to proceed without interactive confirmation, so pipeline safeguards matter; this directly meets the requirement to suppress Terraform's normal approval prompt in a controlled pipeline. By comparison, apply a saved plan is intended to execute exactly the plan artifact that was reviewed, which is a different task from suppress Terraform's normal approval prompt in a controlled pipeline.

Incorrect Answers

A:

Passing the saved plan file to terraform apply uses its recorded choices; applying a plan file does not start a new interactive replanning step; this mechanism is useful when the job is to execute exactly the plan artifact that was reviewed, whereas the current scenario requires the engineer to suppress Terraform's normal approval prompt in a controlled pipeline. These operations have different effects in the stated Terraform workflow.

B:

The parallelism setting controls Terraform's concurrent resource operation count, which can mitigate API throttling; this mechanism is useful when the job is to limit how many graph operations execute concurrently, whereas the current scenario requires the engineer to suppress Terraform's normal approval prompt in a controlled pipeline. These operations have different effects in the stated Terraform workflow.

C:

Terraform executes actions in graph order and can operate on independent nodes in parallel subject to provider and CLI limits; this mechanism is useful when the job is to allow independent resources to be applied concurrently, whereas the current scenario requires the engineer to suppress Terraform's normal approval prompt in a controlled pipeline. These operations have different effects in the stated Terraform workflow.

E:

For a normal fresh apply, Terraform plans with current provider observations unless refresh is explicitly disabled; saved plan behavior differs; this mechanism is useful when the job is to avoid applying from stale remembered attributes after remote drift, whereas the current scenario requires the engineer to suppress Terraform's normal approval prompt in a controlled pipeline. These operations have different effects in the stated Terraform workflow.

Question 32

A Terraform deployment has independent requirements: (1) list the names of keys defined in a map; (2) replace one managed resource when another managed resource's attribute changes. Which TWO mechanisms directly address these needs? Choose TWO.

  1. replace_triggered_by
  2. The keys function
  3. The cidrhost function
  4. Dependency cycle resolution
  5. The dynamic block

Explanation

Correct Answers

A:

This lifecycle rule uses planned resource actions as triggers for replacement and is not a general-purpose dependency selector; this meets the requirement to replace one managed resource when another managed resource's attribute changes, while the other selected techniques address list the names of keys defined in a map, which require their own distinct Terraform mechanisms.

B:

keys returns a lexicographically sorted list of map keys, useful for deterministic iteration; this meets the requirement to list the names of keys defined in a map, while the other selected techniques address replace one managed resource when another managed resource's attribute changes, which require their own distinct Terraform mechanisms.

Incorrect Answers

C:

cidrhost computes a host address inside the given prefix from a numeric host index; it addresses calculate an IP address at an offset within a CIDR range, but this delivery instead requires list the names of keys defined in a map and replace one managed resource when another managed resource's attribute changes. The required combination involves The keys function and replace_triggered_by, not the behavior of The cidrhost function.

D:

Dependency cycles cannot be topologically ordered and require restructuring the relationships or splitting responsibilities; it addresses correct a pair of modules that each require the other's output to initialize, but this delivery instead requires list the names of keys defined in a map and replace one managed resource when another managed resource's attribute changes. The required combination involves The keys function and replace_triggered_by, not the behavior of Dependency cycle resolution.

E:

dynamic constructs blocks required by resource schemas; it does not create standalone Terraform resource declarations; it addresses generate repeated nested blocks from a collection, but this delivery instead requires list the names of keys defined in a map and replace one managed resource when another managed resource's attribute changes. The required combination involves The keys function and replace_triggered_by, not the behavior of The dynamic block.

Question 33

A configuration review for an application stack has a concrete implementation goal: coerce a suitable collection into a list for ordered operations. What is the most appropriate Terraform mechanism?

  1. A tuple type
  2. tolist conversion
  3. The null value
  4. The any type constraint
  5. for_each with a map

Explanation

Correct Answer

B:

tolist converts compatible values to a list, but a source set's original order is not inherently meaningful; this directly meets the requirement to coerce a suitable collection into a list for ordered operations. By comparison, for_each with a map is intended to create instances using stable logical keys rather than shifting numeric indexes, which is a different task from coerce a suitable collection into a list for ordered operations.

Incorrect Answers

A:

tuple([string, number]) enforces a position-specific sequence with different type constraints; this mechanism is useful when the job is to require a fixed sequence of potentially different element types, whereas the current scenario requires the engineer to coerce a suitable collection into a list for ordered operations. These operations have different effects in the stated Terraform workflow.

C:

In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset; this mechanism is useful when the job is to represent the absence of an optional argument value, whereas the current scenario requires the engineer to coerce a suitable collection into a list for ordered operations. These operations have different effects in the stated Terraform workflow.

D:

The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts; this mechanism is useful when the job is to accept values without imposing a specific static input shape, whereas the current scenario requires the engineer to coerce a suitable collection into a list for ordered operations. These operations have different effects in the stated Terraform workflow.

E:

A resource's for_each meta-argument accepts maps or sets of strings; map keys appear in resource addresses; this mechanism is useful when the job is to create instances using stable logical keys rather than shifting numeric indexes, whereas the current scenario requires the engineer to coerce a suitable collection into a list for ordered operations. These operations have different effects in the stated Terraform workflow.

Question 34

A team compares Terraform mechanisms for the goal to limit the lifetime and scope of identities used by infrastructure automation. Which stated consequence belongs specifically to “Vault short-lived credentials”?

  1. Ephemeral outputs are permitted on child modules, allowing a value to travel through an allowed ephemeral context without entering state.
  2. Provider-defined write-only arguments introduced in Terraform 1.11 are available only when the resource schema supports them.
  3. Terraform 1.10+ ephemeral variables can flow only into allowed ephemeral contexts and are omitted from persisted artifacts.
  4. Terraform does not permit ephemeral = true on root-module output blocks, because their ordinary purpose is persistent presentation.
  5. Provider-supported ephemeral resources exist only during an operation and can feed appropriate ephemeral consumers.
  6. Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys.

Explanation

Correct Answer

F:

The named mechanism is used when the objective is to limit the lifetime and scope of identities used by infrastructure automation, so it produces the behavior described. In contrast, no ephemeral root output serves a different goal: reject a design that tries to publish a runtime-only value through the root output table, not limit the lifetime and scope of identities used by infrastructure automation.

Incorrect Answers

A:

The description applies to an ephemeral child module output when an engineer needs to pass a temporary sensitive value from a child module to its parent; the named vault short-lived credentials instead handles the requirement to limit the lifetime and scope of identities used by infrastructure automation, so this behavior does not describe Vault short-lived credentials in the situation named.

B:

The description applies to a write-only resource argument when an engineer needs to pass a secret to a resource without persisting that argument's value; the named vault short-lived credentials instead handles the requirement to limit the lifetime and scope of identities used by infrastructure automation, so this behavior does not describe Vault short-lived credentials in the situation named.

C:

The description applies to ephemeral = true on a variable when an engineer needs to use a short-lived runtime secret without saving its value in plan or state; the named vault short-lived credentials instead handles the requirement to limit the lifetime and scope of identities used by infrastructure automation, so this behavior does not describe Vault short-lived credentials in the situation named.

D:

The description applies to no ephemeral root output when an engineer needs to reject a design that tries to publish a runtime-only value through the root output table; the named vault short-lived credentials instead handles the requirement to limit the lifetime and scope of identities used by infrastructure automation, so this behavior does not describe Vault short-lived credentials in the situation named.

E:

The description applies to an ephemeral resource block when an engineer needs to retrieve or generate temporary data that should not be persisted in Terraform state; the named vault short-lived credentials instead handles the requirement to limit the lifetime and scope of identities used by infrastructure automation, so this behavior does not describe Vault short-lived credentials in the situation named.

Question 35

A build job for a Terraform configuration has a concrete implementation goal: prepare a folder containing fresh .tf configuration files. What is the most appropriate Terraform mechanism?

  1. terraform init -migrate-state
  2. Repeatable initialization
  3. terraform init for a new directory
  4. Provider source change reinitialization

Explanation

Correct Answer

C:

Initialization installs required providers and modules and establishes the working directory's backend configuration; this directly meets the requirement to prepare a folder containing fresh .tf configuration files. By comparison, terraform init -migrate-state is intended to move existing state to a newly configured backend, which is a different task from prepare a folder containing fresh .tf configuration files.

Incorrect Answers

A:

The migrate-state flag attempts to copy prior state into the new backend and can prompt for migration confirmation; this mechanism is useful when the job is to move existing state to a newly configured backend, whereas the current scenario requires the engineer to prepare a folder containing fresh .tf configuration files. These operations have different effects in the stated Terraform workflow.

B:

terraform init is designed to be safely rerun; when requirements are unchanged, it generally keeps existing setup; this mechanism is useful when the job is to run initialization again in an already prepared directory without unnecessary changes, whereas the current scenario requires the engineer to prepare a folder containing fresh .tf configuration files. These operations have different effects in the stated Terraform workflow.

D:

A modified provider requirement can trigger a need to rerun init to resolve the newly declared plugin dependency; this mechanism is useful when the job is to respond after changing the source address of a required provider, whereas the current scenario requires the engineer to prepare a folder containing fresh .tf configuration files. These operations have different effects in the stated Terraform workflow.

Question 36

A Terraform deployment has independent requirements: (1) link an output from one service to a dependent resource on another service; (2) describe the desired infrastructure state instead of scripting every API step. Which TWO mechanisms directly address these needs? Choose TWO.

  1. Provider authentication per service
  2. Declarative resource configuration
  3. Repeatable environment definition
  4. Cross-provider references
  5. A resource graph

Explanation

Correct Answers

B:

Terraform interprets resource declarations, constructs a dependency graph, and asks providers to reconcile real objects with that desired state; this meets the requirement to describe the desired infrastructure state instead of scripting every API step, while the other selected techniques address link an output from one service to a dependent resource on another service, which require their own distinct Terraform mechanisms.

D:

An attribute reference between resource instances can create a dependency across provider boundaries; this meets the requirement to link an output from one service to a dependent resource on another service, while the other selected techniques address describe the desired infrastructure state instead of scripting every API step, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

Each provider configuration supplies or discovers credentials appropriate to the API it calls, rather than sharing a universal Terraform credential; it addresses authorize Terraform separately for two different infrastructure APIs, but this delivery instead requires link an output from one service to a dependent resource on another service and describe the desired infrastructure state instead of scripting every API step. The required combination involves Declarative resource configuration and Cross-provider references, not the behavior of Provider authentication per service.

C:

IaC configuration provides repeatable definitions; variables and isolated state allow environments to differ without independently hand-building each object; it addresses recreate the same logical infrastructure design across test and production, but this delivery instead requires link an output from one service to a dependent resource on another service and describe the desired infrastructure state instead of scripting every API step. The required combination involves Declarative resource configuration and Cross-provider references, not the behavior of Repeatable environment definition.

E:

Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations; it addresses determine a safe sequence for creating objects with references between them, but this delivery instead requires link an output from one service to a dependent resource on another service and describe the desired infrastructure state instead of scripting every API step. The required combination involves Declarative resource configuration and Cross-provider references, not the behavior of A resource graph.

Question 37

A Terraform reviewer encounters “A data source that depends on a resource” while assessing how to delay a lookup until a prerequisite object is available. Which statement correctly describes its actual behavior?

  1. A removed block with destroy = false can express a configuration-driven removal from state while leaving the infrastructure object intact.
  2. A resource block has a type and a local label; together they form its address within the module.
  3. Data source reads can be deferred during planning when their inputs depend on values not known until apply.
  4. The built-in terraform_data resource can represent input changes and trigger replacement behavior without managing a cloud API resource.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to delay a lookup until a prerequisite object is available, so it produces the behavior described. In contrast, resource local names serves a different goal: distinguish two managed instances of the same provider-defined resource type, not delay a lookup until a prerequisite object is available.

Incorrect Answers

A:

The description applies to resource removal without deletion when an engineer needs to retain a remote object but stop Terraform from managing it; the named a data source that depends on a resource instead handles the requirement to delay a lookup until a prerequisite object is available, so this behavior does not describe A data source that depends on a resource in the situation named.

B:

The description applies to resource local names when an engineer needs to distinguish two managed instances of the same provider-defined resource type; the named a data source that depends on a resource instead handles the requirement to delay a lookup until a prerequisite object is available, so this behavior does not describe A data source that depends on a resource in the situation named.

D:

The description applies to the terraform_data resource when an engineer needs to model a Terraform-managed lifecycle value without requiring an external service object; the named a data source that depends on a resource instead handles the requirement to delay a lookup until a prerequisite object is available, so this behavior does not describe A data source that depends on a resource in the situation named.

Question 38

During an infrastructure design review about how to install all referenced remote child modules before planning, a maintainer asks what “terraform init for modules” does. Which description is accurate?

  1. Module source syntax places //subdir after the package address to select the intended directory within the downloaded package.
  2. Keeping reusable child modules separately versioned allows independent adoption and maintenance by different Terraform root modules.
  3. HCP Terraform's private registry can distribute approved modules with access control and supported version metadata.
  4. Published module documentation and metadata describe the module interface and help consumers understand required arguments.
  5. Initialization retrieves module sources and populates .terraform/modules while preparing other required dependencies.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to install all referenced remote child modules before planning, so it produces the behavior described. In contrast, a separate module repository serves a different goal: share reusable Terraform configuration with multiple root projects, not install all referenced remote child modules before planning.

Incorrect Answers

A:

The description applies to the double-slash source subdirectory when an engineer needs to use a nested module stored below a repository's root directory; the named terraform init for modules instead handles the requirement to install all referenced remote child modules before planning, so this behavior does not describe terraform init for modules in the situation named.

B:

The description applies to a separate module repository when an engineer needs to share reusable Terraform configuration with multiple root projects; the named terraform init for modules instead handles the requirement to install all referenced remote child modules before planning, so this behavior does not describe terraform init for modules in the situation named.

C:

The description applies to a private registry module source when an engineer needs to reuse an internally published module available to authorized organization members; the named terraform init for modules instead handles the requirement to install all referenced remote child modules before planning, so this behavior does not describe terraform init for modules in the situation named.

D:

The description applies to registry module documentation when an engineer needs to determine a module's declared inputs, outputs, providers and usage examples; the named terraform init for modules instead handles the requirement to install all referenced remote child modules before planning, so this behavior does not describe terraform init for modules in the situation named.

Question 39

A runbook lists “The provider registry namespace” for the task to identify the publisher when providers share a type name. Which technical effect should its description include?

  1. Terraform Core handles language evaluation, planning and state orchestration while provider plugins execute service-specific operations.
  2. A provider block can configure an endpoint, region or authentication parameters but should not carry the provider's version constraint.
  3. Providers implement resource and data-source schemas plus read, create, update and delete operations for their services.
  4. The namespace portion of a source address separates provider publishers in the registry.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to identify the publisher when providers share a type name, so it produces the behavior described. In contrast, Terraform Core serves a different goal: evaluate HCL expressions and calculate a resource dependency graph, not identify the publisher when providers share a type name.

Incorrect Answers

A:

The description applies to Terraform Core when an engineer needs to evaluate HCL expressions and calculate a resource dependency graph; the named the provider registry namespace instead handles the requirement to identify the publisher when providers share a type name, so this behavior does not describe The provider registry namespace in the situation named.

B:

The description applies to the provider block when an engineer needs to configure API connection settings for an already required provider; the named the provider registry namespace instead handles the requirement to identify the publisher when providers share a type name, so this behavior does not describe The provider registry namespace in the situation named.

C:

The description applies to a provider plugin when an engineer needs to translate Terraform resource operations into calls to the relevant remote API; the named the provider registry namespace instead handles the requirement to identify the publisher when providers share a type name, so this behavior does not describe The provider registry namespace in the situation named.

Question 40

A Terraform reviewer encounters “Version-controlled infrastructure definition” while assessing how to review a proposed infrastructure change before team members deploy it. Which statement correctly describes its actual behavior?

  1. Infrastructure configuration can be committed and reviewed in version control so the intended change is traceable before a Terraform run.
  2. Terraform Core evaluates configuration while provider plugins implement the provider-specific API operations.
  3. Terraform state records mappings and attributes needed to compare future plans without rediscovering every object's identity from scratch.
  4. Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations.
  5. IaC configuration provides repeatable definitions; variables and isolated state allow environments to differ without independently hand-building each object.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to review a proposed infrastructure change before team members deploy it, so it produces the behavior described. In contrast, a resource graph serves a different goal: determine a safe sequence for creating objects with references between them, not review a proposed infrastructure change before team members deploy it.

Incorrect Answers

B:

The description applies to provider-mediated API operations when an engineer needs to manage infrastructure services through a shared declarative workflow; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

C:

The description applies to state-backed object tracking when an engineer needs to retain the association between a configuration address and its actual managed object; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

D:

The description applies to a resource graph when an engineer needs to determine a safe sequence for creating objects with references between them; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

E:

The description applies to repeatable environment definition when an engineer needs to recreate the same logical infrastructure design across test and production; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests