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

Question 360

A Terraform module author requires a way to replace one managed resource when another managed resource's attribute changes. Which Terraform approach most directly fulfills that request?

  1. Output-level depends_on
  2. replace_triggered_by
  3. Dependency cycle resolution
  4. An implicit dependency through an ID

Explanation

Correct Answer

B:

This lifecycle rule uses planned resource actions as triggers for replacement and is not a general-purpose dependency selector; this directly meets the requirement to replace one managed resource when another managed resource's attribute changes. 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 replace one managed resource when another managed resource's attribute changes.

Incorrect Answers

A:

An output block can express an explicit dependency beyond references contained in its value expression; this mechanism is useful when the job is to prevent a module output from being considered ready before an additional side-effect resource, whereas the current scenario requires the engineer to replace one managed resource when another managed resource's attribute changes. These operations have different effects in the stated Terraform workflow.

C:

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 replace one managed resource when another managed resource's attribute changes. These operations have different effects in the stated Terraform workflow.

D:

Using the network object's ID in the subnet argument automatically creates a dependency edge in the graph; this mechanism is useful when the job is to make a subnet wait for the network resource it references, whereas the current scenario requires the engineer to replace one managed resource when another managed resource's attribute changes. These operations have different effects in the stated Terraform workflow.

Question 361

A runbook lists “The error_message field” for the task to present a meaningful explanation when a custom condition evaluates false. Which technical effect should its description include?

  1. Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply.
  2. Validation, precondition and postcondition definitions use error_message to tell the operator why a rule failed.
  3. Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion.
  4. Terraform may defer condition evaluation to apply when required expression values are unknown during planning.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to present a meaningful explanation when a custom condition evaluates false, so it produces the behavior described. In contrast, terraform validate versus runtime assertions serves a different goal: distinguish static configuration checks from conditions requiring actual resource values, not present a meaningful explanation when a custom condition evaluates false.

Incorrect Answers

A:

The description applies to terraform validate versus runtime assertions when an engineer needs to distinguish static configuration checks from conditions requiring actual resource values; the named the error_message field instead handles the requirement to present a meaningful explanation when a custom condition evaluates false, so this behavior does not describe The error_message field in the situation named.

C:

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 the error_message field instead handles the requirement to present a meaningful explanation when a custom condition evaluates false, so this behavior does not describe The error_message field in the situation named.

D:

The description applies to custom conditions with unknown values when an engineer needs to understand when a validation cannot yet be decided at planning time; the named the error_message field instead handles the requirement to present a meaningful explanation when a custom condition evaluates false, so this behavior does not describe The error_message field in the situation named.

Question 362

A Terraform reviewer encounters “The state serial number” while assessing how to understand how successive snapshots are ordered. Which statement correctly describes its actual behavior?

  1. State can retain dependency information needed to correctly destroy objects no longer declared in configuration.
  2. A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes.
  3. State metadata includes lineage and serial information that helps Terraform identify state history and updates.
  4. State maps Terraform instance addresses to remote object identifiers and remembered attributes for subsequent comparisons.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to understand how successive snapshots are ordered, so it produces the behavior described. In contrast, state-backed dependency links serves a different goal: maintain dependencies for resources that have been removed from configuration, not understand how successive snapshots are ordered.

Incorrect Answers

A:

The description applies to state-backed dependency links when an engineer needs to maintain dependencies for resources that have been removed from configuration; the named the state serial number instead handles the requirement to understand how successive snapshots are ordered, so this behavior does not describe The state serial number in the situation named.

B:

The description applies to state locking when an engineer needs to prevent concurrent state writers from overwriting each other's updates; the named the state serial number instead handles the requirement to understand how successive snapshots are ordered, so this behavior does not describe The state serial number in the situation named.

D:

The description applies to state resource addresses when an engineer needs to identify which remote object corresponds to a particular configuration resource; the named the state serial number instead handles the requirement to understand how successive snapshots are ordered, so this behavior does not describe The state serial number in the situation named.

Question 363

The team evaluates “Avoiding hard-coded child credentials” for a requirement to keep authentication and deployment-specific region choices outside a reusable child module. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. Reusable modules normally declare provider requirements while callers supply provider configurations and credentials.
  2. An output-to-input reference establishes a natural dependency and avoids imposing broad depends_on edges unnecessarily.
  3. Two module blocks that use the same source create separate module instances and separate resource addresses.
  4. The count meta-argument creates numerically indexed module instances such as module.worker[0].
  5. The for_each meta-argument instantiates keyed module instances addressable as module.NAME["key"].

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to keep authentication and deployment-specific region choices outside a reusable child module, so it produces the behavior described. In contrast, a module dependency interface serves a different goal: connect two modules by declared output and input values, not keep authentication and deployment-specific region choices outside a reusable child module.

Incorrect Answers

B:

The description applies to a module dependency interface when an engineer needs to connect two modules by declared output and input values; the named avoiding hard-coded child credentials instead handles the requirement to keep authentication and deployment-specific region choices outside a reusable child module, so this behavior does not describe Avoiding hard-coded child credentials in the situation named.

C:

The description applies to multiple calls to one module when an engineer needs to deploy two independently managed stacks from the same module definition; the named avoiding hard-coded child credentials instead handles the requirement to keep authentication and deployment-specific region choices outside a reusable child module, so this behavior does not describe Avoiding hard-coded child credentials in the situation named.

D:

The description applies to a module with count when an engineer needs to instantiate a fixed number of child module copies; the named avoiding hard-coded child credentials instead handles the requirement to keep authentication and deployment-specific region choices outside a reusable child module, so this behavior does not describe Avoiding hard-coded child credentials in the situation named.

E:

The description applies to a module with for_each when an engineer needs to create one child module instance for each stable application key; the named avoiding hard-coded child credentials instead handles the requirement to keep authentication and deployment-specific region choices outside a reusable child module, so this behavior does not describe Avoiding hard-coded child credentials in the situation named.

Question 364

A team consuming shared Terraform modules requires a way to reuse a neighboring module directory in the same repository. Which Terraform approach most directly fulfills that request?

  1. A relative local module source
  2. A Git SSH module source
  3. Registry module documentation
  4. terraform init for modules

Explanation

Correct Answer

A:

A module source such as ./modules/network points to a local directory and requires no registry download or semantic version selection; this directly meets the requirement to reuse a neighboring module directory in the same repository. By comparison, terraform init for modules is intended to install all referenced remote child modules before planning, which is a different task from reuse a neighboring module directory in the same repository.

Incorrect Answers

B:

A git::ssh:// module source delegates repository authentication to Git and SSH rather than a Terraform registry token; this mechanism is useful when the job is to obtain module code from a repository that requires SSH-based access, whereas the current scenario requires the engineer to reuse a neighboring module directory in the same repository. These operations have different effects in the stated Terraform workflow.

C:

Published module documentation and metadata describe the module interface and help consumers understand required arguments; this mechanism is useful when the job is to determine a module's declared inputs, outputs, providers and usage examples, whereas the current scenario requires the engineer to reuse a neighboring module directory in the same repository. These operations have different effects in the stated Terraform workflow.

D:

Initialization retrieves module sources and populates .terraform/modules while preparing other required dependencies; this mechanism is useful when the job is to install all referenced remote child modules before planning, whereas the current scenario requires the engineer to reuse a neighboring module directory in the same repository. These operations have different effects in the stated Terraform workflow.

Question 365

A team compares Terraform mechanisms for the goal to specify which resource instance address should receive the imported object. Which stated consequence belongs specifically to “An import block's to argument”?

  1. The to argument points to an intended Terraform resource address rather than a provider account name or state backend.
  2. Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID.
  3. After import, planning reveals mismatches between the declared resource arguments and the discovered remote object's attributes.
  4. The experimental config-generation flag can write suggested resource declarations for review and correction before apply.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to specify which resource instance address should receive the imported object, so it produces the behavior described. In contrast, terraform plan -generate-config-out serves a different goal: produce draft HCL for resources named in import blocks without matching configuration, not specify which resource instance address should receive the imported object.

Incorrect Answers

B:

The description applies to provider permissions during import when an engineer needs to read an existing cloud object so Terraform can associate it with state; the named an import block's to argument instead handles the requirement to specify which resource instance address should receive the imported object, so this behavior does not describe An import block's to argument in the situation named.

C:

The description applies to a post-import plan when an engineer needs to review whether Terraform intends to change imported infrastructure unexpectedly; the named an import block's to argument instead handles the requirement to specify which resource instance address should receive the imported object, so this behavior does not describe An import block's to argument in the situation named.

D:

The description applies to terraform plan -generate-config-out when an engineer needs to produce draft HCL for resources named in import blocks without matching configuration; the named an import block's to argument instead handles the requirement to specify which resource instance address should receive the imported object, so this behavior does not describe An import block's to argument in the situation named.

Question 366

During one infrastructure delivery, the team must satisfy all of the following: (1) accept current remote readings into Terraform's state through an apply operation; (2) avoid expecting var.region or local.name to populate backend settings. Select TWO appropriate Terraform approaches. Choose TWO.

  1. terraform apply -refresh-only
  2. Remote state encryption at rest
  3. No input variable interpolation in a backend block
  4. A data source instead of import
  5. The S3 backend

Explanation

Correct Answers

A:

Refresh-only apply can update the recorded state to match observed remote attributes without modifying cloud resources; this meets the requirement to accept current remote readings into Terraform's state through an apply operation, while the other selected techniques address avoid expecting var.region or local.name to populate backend settings, which require their own distinct Terraform mechanisms.

C:

Backend configuration is processed at initialization, before ordinary input expressions are evaluated, so it cannot use regular variables or locals; this meets the requirement to avoid expecting var.region or local.name to populate backend settings, while the other selected techniques address accept current remote readings into Terraform's state through an apply operation, which require their own distinct Terraform mechanisms.

Incorrect Answers

B:

Encryption is controlled by the chosen backend service; Terraform's remote backend abstraction does not supply one universal encryption mechanism; it addresses protect stored state contents from unauthorized storage-layer access, but this delivery instead requires accept current remote readings into Terraform's state through an apply operation and avoid expecting var.region or local.name to populate backend settings. The required combination involves No input variable interpolation in a backend block and terraform apply -refresh-only, not the behavior of Remote state encryption at rest.

D:

A data block can read an external object's attributes while avoiding taking over its create-update-delete lifecycle; it addresses refer to shared infrastructure that another stack owns without changing its lifecycle, but this delivery instead requires accept current remote readings into Terraform's state through an apply operation and avoid expecting var.region or local.name to populate backend settings. The required combination involves No input variable interpolation in a backend block and terraform apply -refresh-only, not the behavior of A data source instead of import.

E:

The S3 backend uses configured bucket and key settings, plus suitable authentication and optional locking support; it addresses store Terraform state as an object in an S3 bucket, but this delivery instead requires accept current remote readings into Terraform's state through an apply operation and avoid expecting var.region or local.name to populate backend settings. The required combination involves No input variable interpolation in a backend block and terraform apply -refresh-only, not the behavior of The S3 backend.

Question 367

A team compares Terraform mechanisms for the goal to make a module input optional when callers do not require customization. Which stated consequence belongs specifically to “A variable default inside a child”?

  1. A default inside the child variable declaration applies when the caller omits that module argument.
  2. A child output can be marked sensitive, but its underlying value may still reside in state unless it uses permitted ephemeral handling.
  3. The output block defines a published module interface; the parent reads the value as module.NAME.OUTPUT.
  4. A module block explicitly sets the child's declared input variables using arguments of matching names.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to make a module input optional when callers do not require customization, so it produces the behavior described. In contrast, child module outputs and sensitivity serves a different goal: limit ordinary display of a sensitive result exported from a reusable module, not make a module input optional when callers do not require customization.

Incorrect Answers

B:

The description applies to child module outputs and sensitivity when an engineer needs to limit ordinary display of a sensitive result exported from a reusable module; the named a variable default inside a child instead handles the requirement to make a module input optional when callers do not require customization, so this behavior does not describe A variable default inside a child in the situation named.

C:

The description applies to a child module output when an engineer needs to expose a chosen internal attribute to the calling parent module; the named a variable default inside a child instead handles the requirement to make a module input optional when callers do not require customization, so this behavior does not describe A variable default inside a child in the situation named.

D:

The description applies to parent-to-child argument passing when an engineer needs to set a reusable module's environment tag from the caller; the named a variable default inside a child instead handles the requirement to make a module input optional when callers do not require customization, so this behavior does not describe A variable default inside a child in the situation named.

Question 368

A platform engineering team maintaining plugins needs to inspect the addresses of instances currently tracked in state. Which feature or operation is the most direct match?

  1. terraform state list
  2. State access protection
  3. Terraform refresh during planning
  4. Remote state sharing boundaries

Explanation

Correct Answer

A:

The state list command enumerates Terraform resource addresses without creating or deleting infrastructure; this directly meets the requirement to inspect the addresses of instances currently tracked in state. By comparison, Terraform refresh during planning is intended to detect actual resource attributes rather than relying only on historical saved values, which is a different task from inspect the addresses of instances currently tracked in state.

Incorrect Answers

B:

State may contain secret values even when CLI output is redacted, so storage encryption and access controls matter; this mechanism is useful when the job is to treat a Terraform state file as potentially sensitive data, whereas the current scenario requires the engineer to inspect the addresses of instances currently tracked in state. These operations have different effects in the stated Terraform workflow.

C:

A normal plan attempts to refresh state from providers before comparing objects to the current configuration; this mechanism is useful when the job is to detect actual resource attributes rather than relying only on historical saved values, whereas the current scenario requires the engineer to inspect the addresses of instances currently tracked in state. These operations have different effects in the stated Terraform workflow.

D:

Reading a remote state output still requires access to the underlying snapshot; exporting data through a narrower interface can reduce exposure; this mechanism is useful when the job is to avoid exposing full state when another stack only needs a published identifier, whereas the current scenario requires the engineer to inspect the addresses of instances currently tracked in state. These operations have different effects in the stated Terraform workflow.

Question 369

A Terraform module author has a concrete implementation goal: select between two expression results based on a boolean predicate. What is the most appropriate Terraform mechanism?

  1. for_each with a map
  2. A number variable type
  3. A conditional expression
  4. An optional object attribute

Explanation

Correct Answer

C:

Terraform's condition ? true_value : false_value syntax chooses one branch while reconciling compatible result types; this directly meets the requirement to select between two expression results based on a boolean predicate. By comparison, a number variable type is intended to represent arithmetic quantities without parsing string parameters manually, which is a different task from select between two expression results based on a boolean predicate.

Incorrect Answers

A:

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 select between two expression results based on a boolean predicate. These operations have different effects in the stated Terraform workflow.

B:

The number type supports numerical operations and validation such as comparisons or addition; this mechanism is useful when the job is to represent arithmetic quantities without parsing string parameters manually, whereas the current scenario requires the engineer to select between two expression results based on a boolean predicate. These operations have different effects in the stated Terraform workflow.

D:

The optional type modifier inside an object constraint allows the caller to omit a field and optionally sets a default; this mechanism is useful when the job is to accept an omitted field in a structured object input, whereas the current scenario requires the engineer to select between two expression results based on a boolean predicate. These operations have different effects in the stated Terraform workflow.

Question 370

A Terraform reviewer encounters “HCP Terraform sensitive workspace variables” while assessing how to avoid exposing a secret in ordinary workspace variable screens and logs. Which statement correctly describes its actual behavior?

  1. HCP Terraform can mark workspace variables sensitive to limit UI exposure, though sensitive flags do not replace secure state access.
  2. Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys.
  3. Base64 is reversible encoding; exposing encoded credentials in configuration or state still risks disclosure.
  4. Protecting state requires backend encryption, identity-based authorization and controlled access because state can store raw secret values.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to avoid exposing a secret in ordinary workspace variable screens and logs, so it produces the behavior described. In contrast, not treating Base64 as secrecy serves a different goal: recognize that an encoded password remains sensitive information, not avoid exposing a secret in ordinary workspace variable screens and logs.

Incorrect Answers

B:

The description applies to vault short-lived credentials when an engineer needs to limit the lifetime and scope of identities used by infrastructure automation; the named HCP Terraform sensitive workspace variables instead handles the requirement to avoid exposing a secret in ordinary workspace variable screens and logs, so this behavior does not describe HCP Terraform sensitive workspace variables in the situation named.

C:

The description applies to not treating Base64 as secrecy when an engineer needs to recognize that an encoded password remains sensitive information; the named HCP Terraform sensitive workspace variables instead handles the requirement to avoid exposing a secret in ordinary workspace variable screens and logs, so this behavior does not describe HCP Terraform sensitive workspace variables in the situation named.

D:

The description applies to remote state access controls when an engineer needs to prevent unauthorized operators from reading sensitive resource attributes; the named HCP Terraform sensitive workspace variables instead handles the requirement to avoid exposing a secret in ordinary workspace variable screens and logs, so this behavior does not describe HCP Terraform sensitive workspace variables in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests