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

Question 130

A Terraform change proposal names “Declarative resource configuration” to describe the desired infrastructure state instead of scripting every API step. Which outcome can reviewers attribute to that particular mechanism?

  1. Planning compares configuration with state and refreshed remote data to propose actions that reconcile differences.
  2. Terraform interprets resource declarations, constructs a dependency graph, and asks providers to reconcile real objects with that desired state.
  3. Terraform Core evaluates configuration while provider plugins implement the provider-specific API operations.
  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

B:

The named mechanism is used when the objective is to describe the desired infrastructure state instead of scripting every API step, so it produces the behavior described. In contrast, repeatable environment definition serves a different goal: recreate the same logical infrastructure design across test and production, not describe the desired infrastructure state instead of scripting every API step.

Incorrect Answers

A:

The description applies to desired-state reconciliation when an engineer needs to identify changes between the declared configuration and managed infrastructure; the named declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration in the situation named.

C:

The description applies to provider-mediated API operations when an engineer needs to manage infrastructure services through a shared declarative workflow; the named declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration 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 declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration 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 declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration in the situation named.

Question 131

A remote-state operations review has a concrete implementation goal: check whether a chosen remote backend actually offers state locking. What is the most appropriate Terraform mechanism?

  1. Lock ownership verification
  2. terraform force-unlock
  3. Backend-specific lock support
  4. Lock release after completion

Explanation

Correct Answer

C:

Backend state locking behavior depends on the backend implementation; remote storage alone does not guarantee safe locking; this directly meets the requirement to check whether a chosen remote backend actually offers state locking. By comparison, lock release after completion is intended to understand why a normal Terraform operation frees the lock, which is a different task from check whether a chosen remote backend actually offers state locking.

Incorrect Answers

A:

A lock may belong to another active run, so check its identity and run status rather than immediately forcing removal; this mechanism is useful when the job is to confirm that a held lock is stale before attempting manual removal, whereas the current scenario requires the engineer to check whether a chosen remote backend actually offers state locking. These operations have different effects in the stated Terraform workflow.

B:

The force-unlock command removes a lock by its identifier; using it during an active operation can cause state corruption; this mechanism is useful when the job is to release a stale lock when the original process is definitively gone, whereas the current scenario requires the engineer to check whether a chosen remote backend actually offers state locking. These operations have different effects in the stated Terraform workflow.

D:

Terraform obtains and releases supported backend locks around state-sensitive operations; a crash can sometimes leave manual recovery necessary; this mechanism is useful when the job is to understand why a normal Terraform operation frees the lock, whereas the current scenario requires the engineer to check whether a chosen remote backend actually offers state locking. These operations have different effects in the stated Terraform workflow.

Question 132

A Terraform module author needs to represent arithmetic quantities without parsing string parameters manually. Which feature or operation is the most direct match?

  1. A number variable type
  2. tomap conversion
  3. toset conversion
  4. Avoiding index churn with for_each

Explanation

Correct Answer

A:

The number type supports numerical operations and validation such as comparisons or addition; this directly meets the requirement to represent arithmetic quantities without parsing string parameters manually. By comparison, tomap conversion is intended to turn a compatible collection into a uniform-keyed map, which is a different task from represent arithmetic quantities without parsing string parameters manually.

Incorrect Answers

B:

tomap attempts to convert an input value into a map whose values share a compatible element type; this mechanism is useful when the job is to turn a compatible collection into a uniform-keyed map, whereas the current scenario requires the engineer to represent arithmetic quantities without parsing string parameters manually. These operations have different effects in the stated Terraform workflow.

C:

toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved; this mechanism is useful when the job is to deduplicate a collection of string identifiers for keyed iteration, whereas the current scenario requires the engineer to represent arithmetic quantities without parsing string parameters manually. These operations have different effects in the stated Terraform workflow.

D:

Keyed for_each instances use stable identifiers, whereas count indexes can shift when list elements are deleted; this mechanism is useful when the job is to preserve instance identity when a middle collection item is removed, whereas the current scenario requires the engineer to represent arithmetic quantities without parsing string parameters manually. These operations have different effects in the stated Terraform workflow.

Question 133

A new Terraform working directory needs to accept minor and patch updates without crossing the next major version. Which feature or operation is the most direct match?

  1. terraform providers lock
  2. A provider source address
  3. The dependency lock file
  4. A major-series compatible constraint

Explanation

Correct Answer

D:

The pessimistic constraint ~> 5.3 permits version 5.3 and later releases below 6.0.0; this directly meets the requirement to accept minor and patch updates without crossing the next major version. By comparison, terraform providers lock is intended to populate provider package checksums for selected platforms, which is a different task from accept minor and patch updates without crossing the next major version.

Incorrect Answers

A:

The providers lock subcommand updates dependency lock information, including hashes for specified target operating-system platforms; this mechanism is useful when the job is to populate provider package checksums for selected platforms, whereas the current scenario requires the engineer to accept minor and patch updates without crossing the next major version. These operations have different effects in the stated Terraform workflow.

B:

The source address identifies a provider by registry hostname, namespace and type; local names alone are insufficient to distinguish publishers; this mechanism is useful when the job is to distinguish a community plugin from the HashiCorp-maintained plugin with the same local name, whereas the current scenario requires the engineer to accept minor and patch updates without crossing the next major version. These operations have different effects in the stated Terraform workflow.

C:

The .terraform.lock.hcl file records selected provider versions and checksums to constrain subsequent installations; this mechanism is useful when the job is to reproduce previously selected provider package versions on other machines, whereas the current scenario requires the engineer to accept minor and patch updates without crossing the next major version. These operations have different effects in the stated Terraform workflow.

Question 134

An engineering checklist calls for separate outcomes: (1) repair an isolated broken dependency while acknowledging incomplete plan coverage; (2) represent the absence of an optional argument value; (3) document what input callers should supply when using a module. Which THREE options implement the requested outcomes? Choose THREE.

  1. The null value
  2. A variable description
  3. A child module output block
  4. A map of strings type
  5. Dependency cycle resolution
  6. Resource targeting as an exception

Explanation

Correct Answers

A:

In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset; this meets the requirement to represent the absence of an optional argument value, while the other selected techniques address repair an isolated broken dependency while acknowledging incomplete plan coverage and document what input callers should supply when using a module, which require their own distinct Terraform mechanisms.

B:

Descriptions communicate intended values to users and tooling but do not change evaluation semantics or set defaults; this meets the requirement to document what input callers should supply when using a module, while the other selected techniques address repair an isolated broken dependency while acknowledging incomplete plan coverage and represent the absence of an optional argument value, which require their own distinct Terraform mechanisms.

F:

The -target option narrows an operation to selected objects and prerequisites; routine selective deployment is not its intended model; this meets the requirement to repair an isolated broken dependency while acknowledging incomplete plan coverage, while the other selected techniques address represent the absence of an optional argument value and document what input callers should supply when using a module, which require their own distinct Terraform mechanisms.

Incorrect Answers

C:

A child module must explicitly export an output for its parent to access it through module.CHILD.OUTPUT; it addresses make a child module's private resource attribute available to its caller, but this delivery instead requires repair an isolated broken dependency while acknowledging incomplete plan coverage and represent the absence of an optional argument value and document what input callers should supply when using a module. The required combination involves A variable description and The null value and Resource targeting as an exception, not the behavior of A child module output block.

D:

The map(string) type models uniform values accessed by key rather than by positional index; it addresses associate arbitrary string keys with string values, but this delivery instead requires repair an isolated broken dependency while acknowledging incomplete plan coverage and represent the absence of an optional argument value and document what input callers should supply when using a module. The required combination involves A variable description and The null value and Resource targeting as an exception, not the behavior of A map of strings type.

E:

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 repair an isolated broken dependency while acknowledging incomplete plan coverage and represent the absence of an optional argument value and document what input callers should supply when using a module. The required combination involves A variable description and The null value and Resource targeting as an exception, not the behavior of Dependency cycle resolution.

Question 135

A Terraform reviewer encounters “Workspace access separation” while assessing how to prevent a developer with read access from automatically applying production changes. Which statement correctly describes its actual behavior?

  1. Variable sets let administrators manage common workspace variables centrally and scope them to intended workspaces or projects.
  2. HCP Terraform can use supported dynamic provider credentials that are generated for runs rather than stored as permanent workspace secrets.
  3. HCP Terraform permissions differentiate viewing configuration and runs from authorized apply or administration operations.
  4. Registry access and publishing permissions help centralize reusable module governance across teams.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to prevent a developer with read access from automatically applying production changes, so it produces the behavior described. In contrast, organization variable sets serves a different goal: supply shared environment or Terraform input values across several workspaces, not prevent a developer with read access from automatically applying production changes.

Incorrect Answers

A:

The description applies to organization variable sets when an engineer needs to supply shared environment or Terraform input values across several workspaces; the named workspace access separation instead handles the requirement to prevent a developer with read access from automatically applying production changes, so this behavior does not describe Workspace access separation in the situation named.

B:

The description applies to HCP provider dynamic credentials when an engineer needs to replace standing cloud keys with short-lived run identities; the named workspace access separation instead handles the requirement to prevent a developer with read access from automatically applying production changes, so this behavior does not describe Workspace access separation in the situation named.

D:

The description applies to a restricted private registry when an engineer needs to let approved teams discover modules while controlling publication rights; the named workspace access separation instead handles the requirement to prevent a developer with read access from automatically applying production changes, so this behavior does not describe Workspace access separation in the situation named.

Question 136

A new infrastructure-as-code adoption project has a concrete implementation goal: represent managed infrastructure using Terraform's native declarative language. What is the most appropriate Terraform mechanism?

  1. Desired-state reconciliation
  2. Version-controlled infrastructure definition
  3. HCL configuration files
  4. Declarative resource configuration

Explanation

Correct Answer

C:

Terraform reads .tf files written in HCL, including blocks, arguments, expressions and references that describe the intended objects; this directly meets the requirement to represent managed infrastructure using Terraform's native declarative language. By comparison, version-controlled infrastructure definition is intended to review a proposed infrastructure change before team members deploy it, which is a different task from represent managed infrastructure using Terraform's native declarative language.

Incorrect Answers

A:

Planning compares configuration with state and refreshed remote data to propose actions that reconcile differences; this mechanism is useful when the job is to identify changes between the declared configuration and managed infrastructure, whereas the current scenario requires the engineer to represent managed infrastructure using Terraform's native declarative language. These operations have different effects in the stated Terraform workflow.

B:

Infrastructure configuration can be committed and reviewed in version control so the intended change is traceable before a Terraform run; this mechanism is useful when the job is to review a proposed infrastructure change before team members deploy it, whereas the current scenario requires the engineer to represent managed infrastructure using Terraform's native declarative language. These operations have different effects in the stated Terraform workflow.

D:

Terraform interprets resource declarations, constructs a dependency graph, and asks providers to reconcile real objects with that desired state; this concerns the task to describe the desired infrastructure state instead of scripting every API step, not the current need to represent managed infrastructure using Terraform's native declarative language. A HCL configuration files approach is appropriate here; the substituted Declarative resource configuration option does not supply the specified Terraform capability.

Question 137

A Terraform state maintenance procedure requires a way to rename or relocate a managed resource address without recreating the remote object. Which Terraform approach most directly fulfills that request?

  1. A normal plan with drift
  2. Avoid direct state JSON editing
  3. Serial and lineage checks
  4. A moved block

Explanation

Correct Answer

D:

A moved block maps an old Terraform address to a new one so state follows the refactor rather than planning destruction and creation; this directly meets the requirement to rename or relocate a managed resource address without recreating the remote object. By comparison, serial and lineage checks is intended to detect that a state snapshot belongs to a different history or older generation, which is a different task from rename or relocate a managed resource address without recreating the remote object.

Incorrect Answers

A:

Providers refresh remote resource attributes, and planning can propose updates to bring changed objects back to declared configuration; this mechanism is useful when the job is to detect and propose correction for changes made outside Terraform, whereas the current scenario requires the engineer to rename or relocate a managed resource address without recreating the remote object. These operations have different effects in the stated Terraform workflow.

B:

Manual state-file changes can break address mappings or serial consistency; commands such as state mv and moved blocks are safer; this mechanism is useful when the job is to make state changes through supported Terraform commands and declarative refactors, whereas the current scenario requires the engineer to rename or relocate a managed resource address without recreating the remote object. These operations have different effects in the stated Terraform workflow.

C:

State metadata such as lineage and serial helps protect against incompatible or stale state updates; this mechanism is useful when the job is to detect that a state snapshot belongs to a different history or older generation, whereas the current scenario requires the engineer to rename or relocate a managed resource address without recreating the remote object. These operations have different effects in the stated Terraform workflow.

Question 138

A change request asks an engineer to identify how the local backend stores nondefault workspaces. Which choice best implements the requested behavior?

  1. Local state in CI
  2. A local state backup file
  3. Local workspace state directories
  4. Backend configuration only in a root module

Explanation

Correct Answer

C:

When local workspaces are used, nondefault state snapshots are placed under a terraform.tfstate.d directory structure; this directly meets the requirement to identify how the local backend stores nondefault workspaces. By comparison, backend configuration only in a root module is intended to choose where a root deployment's state will be stored, which is a different task from identify how the local backend stores nondefault workspaces.

Incorrect Answers

A:

A temporary runner may lose its filesystem after a job, so durable shared state is usually needed for repeatable team automation; this mechanism is useful when the job is to recognize why ephemeral build agents should not rely on a machine-local state file, whereas the current scenario requires the engineer to identify how the local backend stores nondefault workspaces. These operations have different effects in the stated Terraform workflow.

B:

Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state; this mechanism is useful when the job is to recover from a state change without relying solely on an unversioned primary file, whereas the current scenario requires the engineer to identify how the local backend stores nondefault workspaces. These operations have different effects in the stated Terraform workflow.

D:

Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state; this mechanism is useful when the job is to choose where a root deployment's state will be stored, whereas the current scenario requires the engineer to identify how the local backend stores nondefault workspaces. These operations have different effects in the stated Terraform workflow.

Question 139

An engineer troubleshooting a .tf configuration requires a way to keep API keys out of committed terraform.tfvars and .tf files. Which Terraform approach most directly fulfills that request?

  1. sensitive = true on an output
  2. Remote state access controls
  3. No secrets in version control
  4. Vault short-lived credentials

Explanation

Correct Answer

C:

Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; this directly meets the requirement to keep API keys out of committed terraform.tfvars and .tf files. By comparison, remote state access controls is intended to prevent unauthorized operators from reading sensitive resource attributes, which is a different task from keep API keys out of committed terraform.tfvars and .tf files.

Incorrect Answers

A:

A sensitive output is redacted in regular presentation, while JSON or raw output modes may reveal its value; this mechanism is useful when the job is to prevent a private output from appearing in normal human-readable CLI output, whereas the current scenario requires the engineer to keep API keys out of committed terraform.tfvars and .tf files. These operations have different effects in the stated Terraform workflow.

B:

Protecting state requires backend encryption, identity-based authorization and controlled access because state can store raw secret values; this mechanism is useful when the job is to prevent unauthorized operators from reading sensitive resource attributes, whereas the current scenario requires the engineer to keep API keys out of committed terraform.tfvars and .tf files. These operations have different effects in the stated Terraform workflow.

D:

Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys; this mechanism is useful when the job is to limit the lifetime and scope of identities used by infrastructure automation, whereas the current scenario requires the engineer to keep API keys out of committed terraform.tfvars and .tf files. These operations have different effects in the stated Terraform workflow.

Question 140

A Terraform reviewer encounters “Preconditions for external assumptions” while assessing how to guard a resource against prerequisites outside the provider's basic schema. Which statement correctly describes its actual behavior?

  1. Validation, precondition and postcondition definitions use error_message to tell the operator why a rule failed.
  2. Variable validation rejects unacceptable values, whereas failed check assertions are intended for diagnostic warnings.
  3. A precondition can express a domain requirement such as a selected image having an expected property before using it.
  4. Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to guard a resource against prerequisites outside the provider's basic schema, so it produces the behavior described. In contrast, the error_message field serves a different goal: present a meaningful explanation when a custom condition evaluates false, not guard a resource against prerequisites outside the provider's basic schema.

Incorrect Answers

A:

The description applies to the error_message field when an engineer needs to present a meaningful explanation when a custom condition evaluates false; the named preconditions for external assumptions instead handles the requirement to guard a resource against prerequisites outside the provider's basic schema, so this behavior does not describe Preconditions for external assumptions in the situation named.

B:

The description applies to input validation versus check blocks when an engineer needs to choose a blocking input constraint rather than a monitoring-style assertion; the named preconditions for external assumptions instead handles the requirement to guard a resource against prerequisites outside the provider's basic schema, so this behavior does not describe Preconditions for external assumptions in the situation named.

D:

The description applies to an assert block inside check when an engineer needs to define a specific boolean statement for a nonblocking Terraform health check; the named preconditions for external assumptions instead handles the requirement to guard a resource against prerequisites outside the provider's basic schema, so this behavior does not describe Preconditions for external assumptions in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests