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

Question 320

A Terraform change proposal names “A write-only resource argument” to pass a secret to a resource without persisting that argument's value. Which outcome can reviewers attribute to that particular mechanism?

  1. Saved plan files may contain sensitive values and must be handled as confidential artifacts rather than safe public summaries.
  2. Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys.
  3. A sensitive output is redacted in regular presentation, while JSON or raw output modes may reveal its value.
  4. Provider-defined write-only arguments introduced in Terraform 1.11 are available only when the resource schema supports them.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to pass a secret to a resource without persisting that argument's value, so it produces the behavior described. In contrast, sensitive = true on an output serves a different goal: prevent a private output from appearing in normal human-readable CLI output, not pass a secret to a resource without persisting that argument's value.

Incorrect Answers

A:

The description applies to preventing credential leaks in plans when an engineer needs to avoid sharing a plan artifact publicly just because console values appear redacted; the named a write-only resource argument instead handles the requirement to pass a secret to a resource without persisting that argument's value, so this behavior does not describe A write-only resource argument in the situation named.

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 a write-only resource argument instead handles the requirement to pass a secret to a resource without persisting that argument's value, so this behavior does not describe A write-only resource argument in the situation named.

C:

The description applies to sensitive = true on an output when an engineer needs to prevent a private output from appearing in normal human-readable CLI output; the named a write-only resource argument instead handles the requirement to pass a secret to a resource without persisting that argument's value, so this behavior does not describe A write-only resource argument in the situation named.

Question 321

During a design review, the requirement is to limit the lifetime and scope of identities used by infrastructure automation. Which option should the engineer select?

  1. No secrets in version control
  2. sensitive = true on a variable
  3. A write-only resource argument
  4. Vault short-lived credentials
  5. A write-only argument version field

Explanation

Correct Answer

D:

Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys; this directly meets the requirement to limit the lifetime and scope of identities used by infrastructure automation. By comparison, no secrets in version control is intended to keep API keys out of committed terraform.tfvars and .tf files, which is a different task from limit the lifetime and scope of identities used by infrastructure automation.

Incorrect Answers

A:

Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; this mechanism is useful when the job is to keep API keys out of committed terraform.tfvars and .tf files, whereas the current scenario requires the engineer to limit the lifetime and scope of identities used by infrastructure automation. These operations have different effects in the stated Terraform workflow.

B:

Sensitive marks a value for redaction in UI output, but regular sensitive values can still be persisted in plan and state files; this mechanism is useful when the job is to hide a supplied secret from ordinary CLI display without removing it from state, whereas the current scenario requires the engineer to limit the lifetime and scope of identities used by infrastructure automation. These operations have different effects in the stated Terraform workflow.

C:

Provider-defined write-only arguments introduced in Terraform 1.11 are available only when the resource schema supports them; this mechanism is useful when the job is to pass a secret to a resource without persisting that argument's value, whereas the current scenario requires the engineer to limit the lifetime and scope of identities used by infrastructure automation. These operations have different effects in the stated Terraform workflow.

E:

Some write-only provider arguments expose an accompanying nonsecret version marker that triggers a new operation when incremented; this mechanism is useful when the job is to force an update when a write-only secret changes without exposing the secret itself, whereas the current scenario requires the engineer to limit the lifetime and scope of identities used by infrastructure automation. These operations have different effects in the stated Terraform workflow.

Question 322

Reviewers reject “The terraform.tfstate file” as a way to choose where a root deployment's state will be stored. Which actual behavior explains why the proposal is unsuitable?

  1. The default workspace's local state is kept as terraform.tfstate; this file may contain sensitive infrastructure details.
  2. Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state.
  3. Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state.
  4. Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination.

Explanation

Correct Answer

A:

The terraform.tfstate file is used when an operator needs to identify Terraform's default local state artifact. Consequently, this choice cannot meet the separate requirement to choose where a root deployment's state will be stored. The intended action would instead require Backend configuration only in a root module.

Incorrect Answers

B:

This behavior belongs to A local state backup file, which helps engineers recover from a state change without relying solely on an unversioned primary file rather than satisfying the separate requirement to choose where a root deployment's state will be stored. The attempted technique was The terraform.tfstate file; it would instead be used to identify Terraform's default local state artifact, not to produce the effect associated with A local state backup file.

C:

That outcome belongs to Backend configuration only in a root module, the mechanism that can choose where a root deployment's state will be stored. The question concerns the engineer’s actual proposal, The terraform.tfstate file; it is directed at identify Terraform's default local state artifact, not that result.

D:

This behavior belongs to State migration from local storage, which helps engineers move an established project to remote state without abandoning resource identity rather than satisfying the separate requirement to choose where a root deployment's state will be stored. The attempted technique was The terraform.tfstate file; it would instead be used to identify Terraform's default local state artifact, not to produce the effect associated with State migration from local storage.

Question 323

A change request asks an engineer to build one delimited string from a list of strings. Which choice best implements the requested behavior?

  1. The join function
  2. The ternary conditional operator
  3. The try function
  4. The contains function

Explanation

Correct Answer

A:

join takes a separator followed by a list and concatenates elements with that separator between them; this directly meets the requirement to build one delimited string from a list of strings. By comparison, the contains function is intended to check whether a collection contains a specific element, which is a different task from build one delimited string from a list of strings.

Incorrect Answers

B:

The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks; this mechanism is useful when the job is to set a resource argument according to a boolean expression, whereas the current scenario requires the engineer to build one delimited string from a list of strings. These operations have different effects in the stated Terraform workflow.

C:

try evaluates expressions in order and returns the first successful result, rather than simply the first non-null value; this mechanism is useful when the job is to select the first expression that evaluates without a dynamic error, whereas the current scenario requires the engineer to build one delimited string from a list of strings. These operations have different effects in the stated Terraform workflow.

D:

contains(collection, value) evaluates membership and returns a boolean; this mechanism is useful when the job is to check whether a collection contains a specific element, whereas the current scenario requires the engineer to build one delimited string from a list of strings. These operations have different effects in the stated Terraform workflow.

Question 324

A platform engineering team maintaining plugins needs to translate Terraform resource operations into calls to the relevant remote API. Which feature or operation is the most direct match?

  1. Implicit provider selection
  2. Provider-defined data sources
  3. A provider plugin
  4. Provider aliases

Explanation

Correct Answer

C:

Providers implement resource and data-source schemas plus read, create, update and delete operations for their services; this directly meets the requirement to translate Terraform resource operations into calls to the relevant remote API. By comparison, implicit provider selection is intended to use the default provider configuration for a resource type, which is a different task from translate Terraform resource operations into calls to the relevant remote API.

Incorrect Answers

A:

Terraform generally selects the default provider matching a resource's type prefix unless an alternate configuration is specified; this mechanism is useful when the job is to use the default provider configuration for a resource type, whereas the current scenario requires the engineer to translate Terraform resource operations into calls to the relevant remote API. These operations have different effects in the stated Terraform workflow.

B:

A provider's data source reads existing data and exposes attributes without creating or destroying the queried object; this mechanism is useful when the job is to read information from an external service without owning its lifecycle, whereas the current scenario requires the engineer to translate Terraform resource operations into calls to the relevant remote API. These operations have different effects in the stated Terraform workflow.

D:

A provider configuration with alias defines a named alternate that resources or modules can explicitly select; this mechanism is useful when the job is to configure two connections to the same service for different regions or accounts, whereas the current scenario requires the engineer to translate Terraform resource operations into calls to the relevant remote API. These operations have different effects in the stated Terraform workflow.

Question 325

In a Terraform configuration, what value does the HCL expression try(tonumber("oops"), 42) evaluate to?

  1. 0
  2. 42
  3. null
  4. "oops"

Explanation

Correct Answer

B:

The expression try(tonumber("oops"), 42) evaluates to 42 because the conversion of oops to a number fails dynamically and try falls back to its next expression. This is Terraform's direct evaluation of the supplied literal arguments in try(tonumber("oops"), 42), not an external provider lookup.

Incorrect Answers

A:

Try does not replace failed numeric conversions with an invented zero. For try(tonumber("oops"), 42), the conversion of oops to a number fails dynamically and try falls back to its next expression; consequently this candidate is not the value Terraform computes.

C:

The second argument is a valid numeric fallback and will be selected. In this specific evaluation, the conversion of oops to a number fails dynamically and try falls back to its next expression, which rules out the proposed alternative.

D:

The invalid string cannot become a number through tonumber, so try moves to 42. HCL evaluates try(tonumber("oops"), 42) using the supplied arguments: the conversion of oops to a number fails dynamically and try falls back to its next expression; the listed result is therefore incorrect.

Question 326

A team compares Terraform mechanisms for the goal to distinguish static configuration checks from conditions requiring actual resource values. Which stated consequence belongs specifically to “terraform validate versus runtime assertions”?

  1. A postcondition evaluates a condition concerning resource results and blocks downstream use when its assertion fails.
  2. Postconditions validate resultant resource or data-source attributes and prevent dependents from relying on invalid results.
  3. The validation block uses a condition and a custom error_message to enforce rules on caller-supplied values.
  4. Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to distinguish static configuration checks from conditions requiring actual resource values, so it produces the behavior described. In contrast, postconditions for exported IDs serves a different goal: guard a dependent consumer against a provider result that violates an invariant, not distinguish static configuration checks from conditions requiring actual resource values.

Incorrect Answers

A:

The description applies to resource postcondition when an engineer needs to verify an invariant about a resource after reading or managing it; the named terraform validate versus runtime assertions instead handles the requirement to distinguish static configuration checks from conditions requiring actual resource values, so this behavior does not describe terraform validate versus runtime assertions in the situation named.

B:

The description applies to postconditions for exported IDs when an engineer needs to guard a dependent consumer against a provider result that violates an invariant; the named terraform validate versus runtime assertions instead handles the requirement to distinguish static configuration checks from conditions requiring actual resource values, so this behavior does not describe terraform validate versus runtime assertions in the situation named.

C:

The description applies to input variable validation when an engineer needs to reject malformed module inputs before provisioning resources; the named terraform validate versus runtime assertions instead handles the requirement to distinguish static configuration checks from conditions requiring actual resource values, so this behavior does not describe terraform validate versus runtime assertions in the situation named.

Question 327

During a design review, the requirement is to inspect state and re-plan when a provider operation fails partway through. Which option should the engineer select?

  1. Apply using current credentials
  2. Apply failure recovery
  3. Post-apply outputs
  4. Parallel graph execution

Explanation

Correct Answer

B:

A partial apply may have changed some resources, so Terraform should refresh and build a new plan rather than blindly assuming a full rollback; this directly meets the requirement to inspect state and re-plan when a provider operation fails partway through. By comparison, parallel graph execution is intended to allow independent resources to be applied concurrently, which is a different task from inspect state and re-plan when a provider operation fails partway through.

Incorrect Answers

A:

Provider API operations use the provider's configured credentials or supported ambient authentication, not the login name in a commit; this mechanism is useful when the job is to determine which identity actually performs infrastructure changes, whereas the current scenario requires the engineer to inspect state and re-plan when a provider operation fails partway through. These operations have different effects in the stated Terraform workflow.

C:

Root output blocks expose values Terraform calculates from the applied resource graph; output display is not an access-control boundary; this mechanism is useful when the job is to retrieve computed identifiers that can be used by deployment automation, whereas the current scenario requires the engineer to inspect state and re-plan when a provider operation fails partway through. These operations have different effects in the stated Terraform workflow.

D:

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 inspect state and re-plan when a provider operation fails partway through. These operations have different effects in the stated Terraform workflow.

Question 328

A change request asks an engineer to deduplicate a collection of string identifiers for keyed iteration. Which choice best implements the requested behavior?

  1. toset conversion
  2. An optional object attribute
  3. An object type
  4. count with a number

Explanation

Correct Answer

A:

toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved; this directly meets the requirement to deduplicate a collection of string identifiers for keyed iteration. By comparison, an optional object attribute is intended to accept an omitted field in a structured object input, which is a different task from deduplicate a collection of string identifiers for keyed iteration.

Incorrect Answers

B:

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 deduplicate a collection of string identifiers for keyed iteration. These operations have different effects in the stated Terraform workflow.

C:

object({ name = string, size = number }) specifies per-attribute types for a structured input; this mechanism is useful when the job is to require a named structure with typed attributes, whereas the current scenario requires the engineer to deduplicate a collection of string identifiers for keyed iteration. These operations have different effects in the stated Terraform workflow.

D:

The count meta-argument uses an integer expression and creates zero-based numeric instance addresses; this mechanism is useful when the job is to create a specified number of similarly configured resource instances, whereas the current scenario requires the engineer to deduplicate a collection of string identifiers for keyed iteration. These operations have different effects in the stated Terraform workflow.

Question 329

An engineering checklist calls for separate outcomes: (1) translate Terraform resource operations into calls to the relevant remote API; (2) pass an aliased provider configuration into a child module. Which TWO options implement the requested outcomes? Choose TWO.

  1. The providers map on a module call
  2. The provider registry namespace
  3. Provider-defined data sources
  4. A default provider configuration
  5. A provider plugin

Explanation

Correct Answers

A:

The module call's providers argument maps the child's expected provider configuration name to a provider configuration available in the parent; this meets the requirement to pass an aliased provider configuration into a child module, while the other selected techniques address translate Terraform resource operations into calls to the relevant remote API, which require their own distinct Terraform mechanisms.

E:

Providers implement resource and data-source schemas plus read, create, update and delete operations for their services; this meets the requirement to translate Terraform resource operations into calls to the relevant remote API, while the other selected techniques address pass an aliased provider configuration into a child module, which require their own distinct Terraform mechanisms.

Incorrect Answers

B:

The namespace portion of a source address separates provider publishers in the registry; it addresses identify the publisher when providers share a type name, but this delivery instead requires translate Terraform resource operations into calls to the relevant remote API and pass an aliased provider configuration into a child module. The required combination involves A provider plugin and The providers map on a module call, not the behavior of The provider registry namespace.

C:

A provider's data source reads existing data and exposes attributes without creating or destroying the queried object; it addresses read information from an external service without owning its lifecycle, but this delivery instead requires translate Terraform resource operations into calls to the relevant remote API and pass an aliased provider configuration into a child module. The required combination involves A provider plugin and The providers map on a module call, not the behavior of Provider-defined data sources.

D:

An unaliased provider block configures the default instance used by matching resources that do not override provider selection; it addresses make resources use a common account without an explicit provider argument, but this delivery instead requires translate Terraform resource operations into calls to the relevant remote API and pass an aliased provider configuration into a child module. The required combination involves A provider plugin and The providers map on a module call, not the behavior of A default provider configuration.

Question 330

A change-control meeting for a root module requires a way to respond to a modified terraform backend block. Which Terraform approach most directly fulfills that request?

  1. terraform init -upgrade for modules
  2. terraform init for a new directory
  3. terraform init -get=false
  4. Re-run init after a backend change

Explanation

Correct Answer

D:

Terraform requires reinitialization to adopt changed backend settings before normal operations continue; this directly meets the requirement to respond to a modified terraform backend block. By comparison, terraform init -get=false is intended to avoid downloading child modules during a narrowly scoped initialization, which is a different task from respond to a modified terraform backend block.

Incorrect Answers

A:

Upgrade tells init to reconsider prior module selections instead of simply reusing previously installed versions; this mechanism is useful when the job is to fetch newer module releases permitted by version constraints, whereas the current scenario requires the engineer to respond to a modified terraform backend block. These operations have different effects in the stated Terraform workflow.

B:

Initialization installs required providers and modules and establishes the working directory's backend configuration; this mechanism is useful when the job is to prepare a folder containing fresh .tf configuration files, whereas the current scenario requires the engineer to respond to a modified terraform backend block. These operations have different effects in the stated Terraform workflow.

C:

The get=false switch skips child module installation, which is generally safe only if module dependencies are already present; this mechanism is useful when the job is to avoid downloading child modules during a narrowly scoped initialization, whereas the current scenario requires the engineer to respond to a modified terraform backend block. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests