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

Question 20

Reviewers reject “State locking” as a way to detect actual resource attributes rather than relying only on historical saved values. Which actual behavior explains why the proposal is unsuitable?

  1. A normal plan attempts to refresh state from providers before comparing objects to the current configuration.
  2. A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes.
  3. State can retain dependency information needed to correctly destroy objects no longer declared in configuration.
  4. State maps Terraform instance addresses to remote object identifiers and remembered attributes for subsequent comparisons.

Explanation

Correct Answer

B:

State locking is used when an operator needs to prevent concurrent state writers from overwriting each other's updates. Consequently, this choice cannot meet the separate requirement to detect actual resource attributes rather than relying only on historical saved values. The intended action would instead require Terraform refresh during planning.

Incorrect Answers

A:

That outcome belongs to Terraform refresh during planning, the mechanism that can detect actual resource attributes rather than relying only on historical saved values. The question concerns the engineer’s actual proposal, State locking; it is directed at prevent concurrent state writers from overwriting each other's updates, not that result.

C:

This behavior belongs to State-backed dependency links, which helps engineers maintain dependencies for resources that have been removed from configuration rather than satisfying the separate requirement to detect actual resource attributes rather than relying only on historical saved values. The attempted technique was State locking; it would instead be used to prevent concurrent state writers from overwriting each other's updates, not to produce the effect associated with State-backed dependency links.

D:

This behavior belongs to State resource addresses, which helps engineers identify which remote object corresponds to a particular configuration resource rather than satisfying the separate requirement to detect actual resource attributes rather than relying only on historical saved values. The attempted technique was State locking; it would instead be used to prevent concurrent state writers from overwriting each other's updates, not to produce the effect associated with State resource addresses.

Question 21

A Terraform reviewer encounters “Import IDs defined by providers” while assessing how to map an existing object's correct remote identifier to a Terraform address. Which statement correctly describes its actual behavior?

  1. Providers refresh remote resource attributes, and planning can propose updates to bring changed objects back to declared configuration.
  2. Import commands require the provider-defined identity format, not an arbitrary local Terraform block label.
  3. Configuration still describes the preferred value, so normal planning can propose undoing an out-of-band modification unless ignored.
  4. State metadata such as lineage and serial helps protect against incompatible or stale state updates.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to map an existing object's correct remote identifier to a Terraform address, so it produces the behavior described. In contrast, a normal plan with drift serves a different goal: detect and propose correction for changes made outside Terraform, not map an existing object's correct remote identifier to a Terraform address.

Incorrect Answers

A:

The description applies to a normal plan with drift when an engineer needs to detect and propose correction for changes made outside Terraform; the named import IDs defined by providers instead handles the requirement to map an existing object's correct remote identifier to a Terraform address, so this behavior does not describe Import IDs defined by providers in the situation named.

C:

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 import IDs defined by providers instead handles the requirement to map an existing object's correct remote identifier to a Terraform address, so this behavior does not describe Import IDs defined by providers in the situation named.

D:

The description applies to serial and lineage checks when an engineer needs to detect that a state snapshot belongs to a different history or older generation; the named import IDs defined by providers instead handles the requirement to map an existing object's correct remote identifier to a Terraform address, so this behavior does not describe Import IDs defined by providers in the situation named.

Question 22

An engineer troubleshooting a .tf configuration needs to present a meaningful explanation when a custom condition evaluates false. Which feature or operation is the most direct match?

  1. Custom conditions with unknown values
  2. The error_message field
  3. The check block
  4. Data source postcondition

Explanation

Correct Answer

B:

Validation, precondition and postcondition definitions use error_message to tell the operator why a rule failed; this directly meets the requirement to present a meaningful explanation when a custom condition evaluates false. By comparison, custom conditions with unknown values is intended to understand when a validation cannot yet be decided at planning time, which is a different task from present a meaningful explanation when a custom condition evaluates false.

Incorrect Answers

A:

Terraform may defer condition evaluation to apply when required expression values are unknown during planning; this mechanism is useful when the job is to understand when a validation cannot yet be decided at planning time, whereas the current scenario requires the engineer to present a meaningful explanation when a custom condition evaluates false. These operations have different effects in the stated Terraform workflow.

C:

Check assertions evaluate health expectations and normally report warning diagnostics rather than blocking deployment on a false condition; this mechanism is useful when the job is to report a failed ongoing infrastructure assertion without ordinarily blocking the apply, whereas the current scenario requires the engineer to present a meaningful explanation when a custom condition evaluates false. These operations have different effects in the stated Terraform workflow.

D:

A postcondition on a data block can validate attributes returned from a provider before downstream resources rely on them; this mechanism is useful when the job is to reject use of queried data when it violates a required invariant, whereas the current scenario requires the engineer to present a meaningful explanation when a custom condition evaluates false. These operations have different effects in the stated Terraform workflow.

Question 23

A Terraform change proposal names “A lower-bound provider constraint” to allow provider releases no older than a tested minimum. Which outcome can reviewers attribute to that particular mechanism?

  1. A version requirement such as >= 5.0.0 allows matching later versions but does not cap major-version upgrades.
  2. A required_providers entry maps a local provider name to its source address and version constraint; it does not configure API credentials.
  3. Terraform uses provider source metadata and its configured installation methods to find and install the appropriate plugin binary.
  4. Initialization resolves provider requirements, installs plugins, and prepares modules and backend settings in the working directory.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to allow provider releases no older than a tested minimum, so it produces the behavior described. In contrast, terraform init serves a different goal: download missing required provider plugins before planning, not allow provider releases no older than a tested minimum.

Incorrect Answers

B:

The description applies to the required_providers block when an engineer needs to declare where a provider plugin comes from and which versions are acceptable; the named a lower-bound provider constraint instead handles the requirement to allow provider releases no older than a tested minimum, so this behavior does not describe A lower-bound provider constraint in the situation named.

C:

The description applies to provider registry installation when an engineer needs to retrieve a published plugin from its declared registry source; the named a lower-bound provider constraint instead handles the requirement to allow provider releases no older than a tested minimum, so this behavior does not describe A lower-bound provider constraint in the situation named.

D:

The description applies to terraform init when an engineer needs to download missing required provider plugins before planning; the named a lower-bound provider constraint instead handles the requirement to allow provider releases no older than a tested minimum, so this behavior does not describe A lower-bound provider constraint in the situation named.

Question 24

A Terraform reviewer encounters “An object type” while assessing how to require a named structure with typed attributes. Which statement correctly describes its actual behavior?

  1. object({ name = string, size = number }) specifies per-attribute types for a structured input.
  2. Keyed for_each instances use stable identifiers, whereas count indexes can shift when list elements are deleted.
  3. toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved.
  4. An unknown value represents future information and can propagate through expressions until a provider supplies the result.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to require a named structure with typed attributes, so it produces the behavior described. In contrast, an unknown plan-time value serves a different goal: identify a computed attribute that Terraform cannot determine until apply, not require a named structure with typed attributes.

Incorrect Answers

B:

The description applies to avoiding index churn with for_each when an engineer needs to preserve instance identity when a middle collection item is removed; the named an object type instead handles the requirement to require a named structure with typed attributes, so this behavior does not describe An object type in the situation named.

C:

The description applies to toset conversion when an engineer needs to deduplicate a collection of string identifiers for keyed iteration; the named an object type instead handles the requirement to require a named structure with typed attributes, so this behavior does not describe An object type in the situation named.

D:

The description applies to an unknown plan-time value when an engineer needs to identify a computed attribute that Terraform cannot determine until apply; the named an object type instead handles the requirement to require a named structure with typed attributes, so this behavior does not describe An object type in the situation named.

Question 25

A change request asks an engineer to group related workspaces under one organizational and permissions boundary. Which choice best implements the requested behavior?

  1. A tagged cloud workspaces block
  2. Variable sets scoped to workspaces
  3. A workspace's VCS repository settings
  4. An HCP Terraform project

Explanation

Correct Answer

D:

Projects organize workspaces by application, team or environment, simplifying scope and access administration; this directly meets the requirement to group related workspaces under one organizational and permissions boundary. By comparison, variable sets scoped to workspaces is intended to share credentials only with selected approved infrastructure scopes, which is a different task from group related workspaces under one organizational and permissions boundary.

Incorrect Answers

A:

The cloud block can select a workspace set by supported tags, which differs from specifying one workspace name; this mechanism is useful when the job is to select workspaces using Terraform cloud configuration rather than a single explicit name, whereas the current scenario requires the engineer to group related workspaces under one organizational and permissions boundary. These operations have different effects in the stated Terraform workflow.

B:

A variable set may apply to selected workspaces instead of every workspace in an organization; this mechanism is useful when the job is to share credentials only with selected approved infrastructure scopes, whereas the current scenario requires the engineer to group related workspaces under one organizational and permissions boundary. These operations have different effects in the stated Terraform workflow.

C:

VCS connection details identify the source code changes that should trigger a workspace's Terraform run; this mechanism is useful when the job is to define which configuration branch or directory produces automatic runs, whereas the current scenario requires the engineer to group related workspaces under one organizational and permissions boundary. These operations have different effects in the stated Terraform workflow.

Question 26

A change request asks an engineer to track resources in distinct providers together within the chosen state scope. Which choice best implements the requested behavior?

  1. Consistent automation pipeline
  2. Isolating deployment boundaries
  3. Multi-cloud state visibility
  4. Service-agnostic resource modeling

Explanation

Correct Answer

C:

One Terraform state can map managed resources from multiple providers, although separate configurations may improve blast-radius isolation; this directly meets the requirement to track resources in distinct providers together within the chosen state scope. By comparison, isolating deployment boundaries is intended to limit the impact of changes to one environment or platform, which is a different task from track resources in distinct providers together within the chosen state scope.

Incorrect Answers

A:

Terraform's core workflow works across providers even though their individual resources and authentication methods differ; this mechanism is useful when the job is to apply the same validate-plan-apply lifecycle to more than one cloud, whereas the current scenario requires the engineer to track resources in distinct providers together within the chosen state scope. These operations have different effects in the stated Terraform workflow.

B:

Separate root modules and state files reduce shared-plan scope when different teams or lifecycles require isolation; this mechanism is useful when the job is to limit the impact of changes to one environment or platform, whereas the current scenario requires the engineer to track resources in distinct providers together within the chosen state scope. These operations have different effects in the stated Terraform workflow.

D:

Terraform Core offers common configuration and state mechanisms while provider schemas capture each platform's API differences; this mechanism is useful when the job is to use a common configuration workflow across distinct vendors, whereas the current scenario requires the engineer to track resources in distinct providers together within the chosen state scope. These operations have different effects in the stated Terraform workflow.

Question 27

The team evaluates “An implicit attribute dependency” for a requirement to ensure a dependent resource waits for the object whose ID it needs. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. The syntax local.NAME accesses a locally defined expression evaluated in the current module.
  2. Referencing another managed resource's attribute creates an implicit dependency in Terraform's graph.
  3. Resources using count can refer to the current instance number through count.index, a zero-based integer.
  4. A resource address inside a module ordinarily uses TYPE.NAME, with optional instance indexing when count or for_each is used.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to ensure a dependent resource waits for the object whose ID it needs, so it produces the behavior described. In contrast, the resource address format serves a different goal: identify a resource instance by its type and local name, not ensure a dependent resource waits for the object whose ID it needs.

Incorrect Answers

A:

The description applies to a local value reference when an engineer needs to share one calculated expression among multiple resources in a module; the named an implicit attribute dependency instead handles the requirement to ensure a dependent resource waits for the object whose ID it needs, so this behavior does not describe An implicit attribute dependency in the situation named.

C:

The description applies to count.index when an engineer needs to build a numbered name for each instance created using count; the named an implicit attribute dependency instead handles the requirement to ensure a dependent resource waits for the object whose ID it needs, so this behavior does not describe An implicit attribute dependency in the situation named.

D:

The description applies to the resource address format when an engineer needs to identify a resource instance by its type and local name; the named an implicit attribute dependency instead handles the requirement to ensure a dependent resource waits for the object whose ID it needs, so this behavior does not describe An implicit attribute dependency in the situation named.

Question 28

A runbook lists “A provider plugin” for the task to translate Terraform resource operations into calls to the relevant remote API. Which technical effect should its description include?

  1. A provider configuration with alias defines a named alternate that resources or modules can explicitly select.
  2. Terraform Core handles language evaluation, planning and state orchestration while provider plugins execute service-specific operations.
  3. Providers implement resource and data-source schemas plus read, create, update and delete operations for their services.
  4. The provider declares accepted resource arguments and computed attributes; Terraform validates configuration against that schema.
  5. A provider block can configure an endpoint, region or authentication parameters but should not carry the provider's version constraint.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to translate Terraform resource operations into calls to the relevant remote API, so it produces the behavior described. In contrast, provider-defined resource schemas serves a different goal: determine which arguments a resource type accepts, not translate Terraform resource operations into calls to the relevant remote API.

Incorrect Answers

A:

The description applies to provider aliases when an engineer needs to configure two connections to the same service for different regions or accounts; the named a provider plugin instead handles the requirement to translate Terraform resource operations into calls to the relevant remote API, so this behavior does not describe A provider plugin in the situation named.

B:

The description applies to Terraform Core when an engineer needs to evaluate HCL expressions and calculate a resource dependency graph; the named a provider plugin instead handles the requirement to translate Terraform resource operations into calls to the relevant remote API, so this behavior does not describe A provider plugin in the situation named.

D:

The description applies to provider-defined resource schemas when an engineer needs to determine which arguments a resource type accepts; the named a provider plugin instead handles the requirement to translate Terraform resource operations into calls to the relevant remote API, so this behavior does not describe A provider plugin in the situation named.

E:

The description applies to the provider block when an engineer needs to configure API connection settings for an already required provider; the named a provider plugin instead handles the requirement to translate Terraform resource operations into calls to the relevant remote API, so this behavior does not describe A provider plugin in the situation named.

Question 29

A change request asks an engineer to make multiple resource instances wait for a shared prerequisite. Which choice best implements the requested behavior?

  1. Dependency cycle resolution
  2. count and depends_on together
  3. Lifecycle ordering versus API support
  4. replace_triggered_by

Explanation

Correct Answer

B:

The depends_on edge can relate the whole counted resource block to an upstream resource, rather than computing one edge by list position; this directly meets the requirement to make multiple resource instances wait for a shared prerequisite. By comparison, dependency cycle resolution is intended to correct a pair of modules that each require the other's output to initialize, which is a different task from make multiple resource instances wait for a shared prerequisite.

Incorrect Answers

A:

Dependency cycles cannot be topologically ordered and require restructuring the relationships or splitting responsibilities; this mechanism is useful when the job is to correct a pair of modules that each require the other's output to initialize, whereas the current scenario requires the engineer to make multiple resource instances wait for a shared prerequisite. These operations have different effects in the stated Terraform workflow.

C:

Terraform can request early replacement creation, but remote API constraints may disallow two objects with the same globally unique name; this mechanism is useful when the job is to understand why create_before_destroy can still fail on a uniquely named object, whereas the current scenario requires the engineer to make multiple resource instances wait for a shared prerequisite. These operations have different effects in the stated Terraform workflow.

D:

This lifecycle rule uses planned resource actions as triggers for replacement and is not a general-purpose dependency selector; this mechanism is useful when the job is to replace one managed resource when another managed resource's attribute changes, whereas the current scenario requires the engineer to make multiple resource instances wait for a shared prerequisite. These operations have different effects in the stated Terraform workflow.

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.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests