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

Question 650

A release pipeline preparing provider access has a concrete implementation goal: declare which alternate provider configurations a child module is allowed to receive. What is the most appropriate Terraform mechanism?

  1. An aliased provider instance
  2. Separate required provider names
  3. configuration_aliases in required_providers
  4. Provider-local name mapping

Explanation

Correct Answer

C:

A child module's required_providers entry uses configuration_aliases to advertise provider aliases referenced inside the module; this directly meets the requirement to declare which alternate provider configurations a child module is allowed to receive. By comparison, a resource's provider meta-argument is intended to route a particular managed object to the named alternate provider configuration, which is a different task from declare which alternate provider configurations a child module is allowed to receive.

Incorrect Answers

A:

Declare an aliased provider configuration and assign provider = provider_name.alias on resources that need the alternate region; this mechanism is useful when the job is to create resources in a second region using the same provider type, whereas the current scenario requires the engineer to declare which alternate provider configurations a child module is allowed to receive. These operations have different effects in the stated Terraform workflow.

B:

List both plugins under required_providers and configure each service's provider independently as needed; this concerns the task to use two unrelated service APIs in one root configuration, not the current need to declare which alternate provider configurations a child module is allowed to receive. A configuration_aliases in required_providers approach is appropriate here; the substituted Separate required provider names option does not supply the specified Terraform capability.

D:

The required_providers entry maps the chosen local name to a specific fully qualified provider source address; this mechanism is useful when the job is to reuse a provider whose source address differs from its short local identifier, whereas the current scenario requires the engineer to declare which alternate provider configurations a child module is allowed to receive. These operations have different effects in the stated Terraform workflow.

Question 651

A remote-state operations review has a concrete implementation goal: identify Terraform's default local state artifact. What is the most appropriate Terraform mechanism?

  1. State file confidentiality
  2. The terraform.tfstate file
  3. State migration from local storage
  4. The default local backend
  5. A local state backup file

Explanation

Correct Answer

B:

The default workspace's local state is kept as terraform.tfstate; this file may contain sensitive infrastructure details; this directly meets the requirement to identify Terraform's default local state artifact. By comparison, state migration from local storage is intended to move an established project to remote state without abandoning resource identity, which is a different task from identify Terraform's default local state artifact.

Incorrect Answers

A:

Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter; this mechanism is useful when the job is to protect a workstation's local state file even when output values are hidden, whereas the current scenario requires the engineer to identify Terraform's default local state artifact. These operations have different effects in the stated Terraform workflow.

C:

Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination; this mechanism is useful when the job is to move an established project to remote state without abandoning resource identity, whereas the current scenario requires the engineer to identify Terraform's default local state artifact. These operations have different effects in the stated Terraform workflow.

D:

Without another backend, Terraform uses the local backend and writes its default workspace state to terraform.tfstate; this mechanism is useful when the job is to store Terraform state in a file in the working directory by default, whereas the current scenario requires the engineer to identify Terraform's default local state artifact. These operations have different effects in the stated Terraform workflow.

E:

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 Terraform's default local state artifact. These operations have different effects in the stated Terraform workflow.

Question 652

During an infrastructure design review about how to rename or relocate a managed resource address without recreating the remote object, a maintainer asks what “A moved block” does. Which description is accurate?

  1. A moved block maps an old Terraform address to a new one so state follows the refactor rather than planning destruction and creation.
  2. Providers refresh remote resource attributes, and planning can propose updates to bring changed objects back to declared configuration.
  3. A plan does not discover every unmanaged object in an account; its normal focus is tracked resources and configured data sources.
  4. State metadata such as lineage and serial helps protect against incompatible or stale state updates.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to rename or relocate a managed resource address without recreating the remote object, so it produces the behavior described. In contrast, drift detection boundaries serves a different goal: understand that Terraform only examines infrastructure represented in its configuration or state scope, not rename or relocate a managed resource address without recreating the remote object.

Incorrect Answers

B:

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 a moved block instead handles the requirement to rename or relocate a managed resource address without recreating the remote object, so this behavior does not describe A moved block in the situation named.

C:

The description applies to drift detection boundaries when an engineer needs to understand that Terraform only examines infrastructure represented in its configuration or state scope; the named a moved block instead handles the requirement to rename or relocate a managed resource address without recreating the remote object, so this behavior does not describe A moved block 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 a moved block instead handles the requirement to rename or relocate a managed resource address without recreating the remote object, so this behavior does not describe A moved block in the situation named.

Question 653

A team compares Terraform mechanisms for the goal to prevent a private output from appearing in normal human-readable CLI output. Which stated consequence belongs specifically to “sensitive = true on an output”?

  1. Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL.
  2. Some write-only provider arguments expose an accompanying nonsecret version marker that triggers a new operation when incremented.
  3. A sensitive output is redacted in regular presentation, while JSON or raw output modes may reveal its value.
  4. Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to prevent a private output from appearing in normal human-readable CLI output, so it produces the behavior described. In contrast, vault short-lived credentials serves a different goal: limit the lifetime and scope of identities used by infrastructure automation, not prevent a private output from appearing in normal human-readable CLI output.

Incorrect Answers

A:

The description applies to environment-based provider credentials when an engineer needs to avoid putting provider access tokens directly in configuration source; the named sensitive = true on an output instead handles the requirement to prevent a private output from appearing in normal human-readable CLI output, so this behavior does not describe sensitive = true on an output in the situation named.

B:

The description applies to a write-only argument version field when an engineer needs to force an update when a write-only secret changes without exposing the secret itself; the named sensitive = true on an output instead handles the requirement to prevent a private output from appearing in normal human-readable CLI output, so this behavior does not describe sensitive = true on an output in the situation named.

D:

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 sensitive = true on an output instead handles the requirement to prevent a private output from appearing in normal human-readable CLI output, so this behavior does not describe sensitive = true on an output in the situation named.

Question 654

A Terraform change proposal names “count with a number” to create a specified number of similarly configured resource instances. Which outcome can reviewers attribute to that particular mechanism?

  1. The count meta-argument uses an integer expression and creates zero-based numeric instance addresses.
  2. The set(string) type deduplicates values and does not preserve a meaningful input element order.
  3. The map(string) type models uniform values accessed by key rather than by positional index.
  4. toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to create a specified number of similarly configured resource instances, so it produces the behavior described. In contrast, a map of strings type serves a different goal: associate arbitrary string keys with string values, not create a specified number of similarly configured resource instances.

Incorrect Answers

B:

The description applies to a set of strings type when an engineer needs to store a collection with no duplicate members and no guaranteed order; the named count with a number instead handles the requirement to create a specified number of similarly configured resource instances, so this behavior does not describe count with a number in the situation named.

C:

The description applies to a map of strings type when an engineer needs to associate arbitrary string keys with string values; the named count with a number instead handles the requirement to create a specified number of similarly configured resource instances, so this behavior does not describe count with a number in the situation named.

D:

The description applies to toset conversion when an engineer needs to deduplicate a collection of string identifiers for keyed iteration; the named count with a number instead handles the requirement to create a specified number of similarly configured resource instances, so this behavior does not describe count with a number in the situation named.

Question 655

A change request asks an engineer to change the address of a tracked object directly within state. Which choice best implements the requested behavior?

  1. ignore_changes for shared ownership
  2. Serial and lineage checks
  3. A refreshed changed resource
  4. terraform state mv

Explanation

Correct Answer

D:

The state mv command reassigns a managed resource's address without contacting the provider to destroy the object; this directly meets the requirement to change the address of a tracked object directly within state. 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 change the address of a tracked object directly within state.

Incorrect Answers

A:

The lifecycle ignore_changes rule suppresses post-creation update plans for selected attributes while leaving other attributes managed; this mechanism is useful when the job is to stop Terraform from overwriting a field delegated to an external controller, whereas the current scenario requires the engineer to change the address of a tracked object directly within state. These operations have different effects in the stated Terraform workflow.

B:

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 change the address of a tracked object directly within state. These operations have different effects in the stated Terraform workflow.

C:

Configuration still describes the preferred value, so normal planning can propose undoing an out-of-band modification unless ignored; this mechanism is useful when the job is to understand why Terraform tries to reset a manually edited resource attribute, whereas the current scenario requires the engineer to change the address of a tracked object directly within state. These operations have different effects in the stated Terraform workflow.

Question 656

A runbook lists “terraform show” for the task to display the current state or a saved plan in a human-readable way. Which technical effect should its description include?

  1. Replace-provider rewrites provider source references in state and creates a backup before the edit.
  2. State pull reads the current snapshot to standard output, including potentially sensitive provider attributes.
  3. The show command renders state or plan content without being an apply operation.
  4. State mv updates address mapping within state and does not move the real infrastructure object between regions or accounts.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to display the current state or a saved plan in a human-readable way, so it produces the behavior described. In contrast, terraform state mv serves a different goal: change a tracked object's resource address after an intentional refactor, not display the current state or a saved plan in a human-readable way.

Incorrect Answers

A:

The description applies to terraform state replace-provider when an engineer needs to update the provider source address recorded for affected state resources; the named terraform show instead handles the requirement to display the current state or a saved plan in a human-readable way, so this behavior does not describe terraform show in the situation named.

B:

The description applies to terraform state pull when an engineer needs to export a state snapshot from the configured backend for careful examination; the named terraform show instead handles the requirement to display the current state or a saved plan in a human-readable way, so this behavior does not describe terraform show in the situation named.

D:

The description applies to terraform state mv when an engineer needs to change a tracked object's resource address after an intentional refactor; the named terraform show instead handles the requirement to display the current state or a saved plan in a human-readable way, so this behavior does not describe terraform show in the situation named.

Question 657

During a design review, the requirement is to pass a secret to a resource without persisting that argument's value. Which option should the engineer select?

  1. An ephemeral resource block
  2. No secrets in version control
  3. Environment-based provider credentials
  4. sensitive = true on an output
  5. A write-only resource argument

Explanation

Correct Answer

E:

Provider-defined write-only arguments introduced in Terraform 1.11 are available only when the resource schema supports them; this directly meets the requirement to pass a secret to a resource without persisting that argument's value. By comparison, sensitive = true on an output is intended to prevent a private output from appearing in normal human-readable CLI output, which is a different task from pass a secret to a resource without persisting that argument's value.

Incorrect Answers

A:

Provider-supported ephemeral resources exist only during an operation and can feed appropriate ephemeral consumers; this mechanism is useful when the job is to retrieve or generate temporary data that should not be persisted in Terraform state, whereas the current scenario requires the engineer to pass a secret to a resource without persisting that argument's value. These operations have different effects in the stated Terraform workflow.

B:

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 pass a secret to a resource without persisting that argument's value. These operations have different effects in the stated Terraform workflow.

C:

Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL; this mechanism is useful when the job is to avoid putting provider access tokens directly in configuration source, whereas the current scenario requires the engineer to pass a secret to a resource without persisting that argument's value. These operations have different effects in the stated Terraform workflow.

D:

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 pass a secret to a resource without persisting that argument's value. These operations have different effects in the stated Terraform workflow.

Question 658

In a Terraform configuration, what value does the HCL expression can(tonumber("nope")) evaluate to?

  1. 0
  2. true
  3. false
  4. null

Explanation

Correct Answer

C:

The expression can(tonumber("nope")) evaluates to false because can traps the failed string-to-number evaluation and reports whether the expression succeeds. This is Terraform's direct evaluation of the supplied literal arguments in can(tonumber("nope")), not an external provider lookup.

Incorrect Answers

A:

Can returns a boolean, not the numeric result of a failed conversion. In this specific evaluation, can traps the failed string-to-number evaluation and reports whether the expression succeeds, which rules out the proposed alternative.

B:

The word nope is not a valid numeric representation. For can(tonumber("nope")), can traps the failed string-to-number evaluation and reports whether the expression succeeds; consequently this candidate is not the value Terraform computes.

D:

The failed conversion yields false from can, not an unknown value. HCL evaluates can(tonumber("nope")) using the supplied arguments: can traps the failed string-to-number evaluation and reports whether the expression succeeds; the listed result is therefore incorrect.

Question 659

A team compares Terraform mechanisms for the goal to install a newly allowed child module release after editing its version requirement. Which stated consequence belongs specifically to “Init after module version change”?

  1. A module upgrade can change resource definitions and outputs, so the consumer should inspect the new source and resulting Terraform plan.
  2. A module version constraint such as = 2.1.3 selects only that published version until the requirement changes.
  3. Changing a module source or version constraint requires reinitializing to resolve the updated selection.
  4. The module version argument accepts version constraints for registry sources and Terraform resolves compatible published releases during init.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to install a newly allowed child module release after editing its version requirement, so it produces the behavior described. In contrast, reviewing module upgrade changes serves a different goal: control behavioral changes after moving to a new module release, not install a newly allowed child module release after editing its version requirement.

Incorrect Answers

A:

The description applies to reviewing module upgrade changes when an engineer needs to control behavioral changes after moving to a new module release; the named init after module version change instead handles the requirement to install a newly allowed child module release after editing its version requirement, so this behavior does not describe Init after module version change in the situation named.

B:

The description applies to a strict registry module pin when an engineer needs to reproduce a vetted module release without automatically selecting a newer one; the named init after module version change instead handles the requirement to install a newly allowed child module release after editing its version requirement, so this behavior does not describe Init after module version change in the situation named.

D:

The description applies to a registry module version constraint when an engineer needs to select a supported module release range from the registry; the named init after module version change instead handles the requirement to install a newly allowed child module release after editing its version requirement, so this behavior does not describe Init after module version change in the situation named.

Question 660

The team evaluates “Avoid direct state JSON editing” for a requirement to make state changes through supported Terraform commands and declarative refactors. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. The state rm command removes the association so the remote object remains but is no longer tracked by that state.
  2. If a provider reports a tracked object no longer exists, a normal plan generally proposes recreating it when its resource block remains.
  3. Manual state-file changes can break address mappings or serial consistency; commands such as state mv and moved blocks are safer.
  4. The state pull command retrieves state from the configured backend and prints a snapshot that may contain secrets.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to make state changes through supported Terraform commands and declarative refactors, so it produces the behavior described. In contrast, terraform state rm serves a different goal: forget a managed object without destroying the corresponding real infrastructure, not make state changes through supported Terraform commands and declarative refactors.

Incorrect Answers

A:

The description applies to terraform state rm when an engineer needs to forget a managed object without destroying the corresponding real infrastructure; the named avoid direct state JSON editing instead handles the requirement to make state changes through supported Terraform commands and declarative refactors, so this behavior does not describe Avoid direct state JSON editing in the situation named.

B:

The description applies to a refreshed missing resource when an engineer needs to understand why Terraform proposes creating a managed object deleted outside the workflow; the named avoid direct state JSON editing instead handles the requirement to make state changes through supported Terraform commands and declarative refactors, so this behavior does not describe Avoid direct state JSON editing 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 avoid direct state JSON editing instead handles the requirement to make state changes through supported Terraform commands and declarative refactors, so this behavior does not describe Avoid direct state JSON editing in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests