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

Question 410

An engineer intends to read current attributes of managed remote objects during planning and is reviewing “Provider data refresh”. What consequence follows from using it as intended?

  1. Terraform generally selects the default provider matching a resource's type prefix unless an alternate configuration is specified.
  2. Terraform Core handles language evaluation, planning and state orchestration while provider plugins execute service-specific operations.
  3. The namespace portion of a source address separates provider publishers in the registry.
  4. A provider configuration with alias defines a named alternate that resources or modules can explicitly select.
  5. Providers retrieve object details so Terraform can compare observed infrastructure against desired configuration and prior state.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to read current attributes of managed remote objects during planning, so it produces the behavior described. In contrast, Terraform Core serves a different goal: evaluate HCL expressions and calculate a resource dependency graph, not read current attributes of managed remote objects during planning.

Incorrect Answers

A:

The description applies to implicit provider selection when an engineer needs to use the default provider configuration for a resource type; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.

B:

The description applies to Terraform Core when an engineer needs to evaluate HCL expressions and calculate a resource dependency graph; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.

C:

The description applies to the provider registry namespace when an engineer needs to identify the publisher when providers share a type name; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.

D:

The description applies to provider aliases when an engineer needs to configure two connections to the same service for different regions or accounts; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.

Question 411

A Terraform change proposal names “terraform show on a plan file” to inspect the human-readable contents of a saved Terraform plan. Which outcome can reviewers attribute to that particular mechanism?

  1. terraform show can display a saved plan's actions and attributes; sensitive material may appear in machine-readable forms.
  2. In human-readable plan diffs, ~ indicates that Terraform proposes updating existing resource attributes.
  3. The graph command emits a DOT graph representation of Terraform dependencies, useful for spotting unexpected ordering constraints.
  4. Refresh-only planning proposes changes to Terraform state or root outputs based on remote observations, without proposing ordinary resource updates.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to inspect the human-readable contents of a saved Terraform plan, so it produces the behavior described. In contrast, terraform plan -refresh-only serves a different goal: propose updating state or root outputs to reflect remote changes without planning infrastructure remediation, not inspect the human-readable contents of a saved Terraform plan.

Incorrect Answers

B:

The description applies to a resource action marked tilde when an engineer needs to identify an in-place change rather than object recreation; the named terraform show on a plan file instead handles the requirement to inspect the human-readable contents of a saved Terraform plan, so this behavior does not describe terraform show on a plan file in the situation named.

C:

The description applies to terraform graph when an engineer needs to display configuration and state dependencies for troubleshooting; the named terraform show on a plan file instead handles the requirement to inspect the human-readable contents of a saved Terraform plan, so this behavior does not describe terraform show on a plan file in the situation named.

D:

The description applies to terraform plan -refresh-only when an engineer needs to propose updating state or root outputs to reflect remote changes without planning infrastructure remediation; the named terraform show on a plan file instead handles the requirement to inspect the human-readable contents of a saved Terraform plan, so this behavior does not describe terraform show on a plan file in the situation named.

Question 412

An engineer intends to hide a supplied secret from ordinary CLI display without removing it from state and is reviewing “sensitive = true on a variable”. What consequence follows from using it as intended?

  1. Ephemeral outputs are permitted on child modules, allowing a value to travel through an allowed ephemeral context without entering state.
  2. Sensitive marks a value for redaction in UI output, but regular sensitive values can still be persisted in plan and state files.
  3. Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction.
  4. Protecting state requires backend encryption, identity-based authorization and controlled access because state can store raw secret values.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to hide a supplied secret from ordinary CLI display without removing it from state, so it produces the behavior described. In contrast, remote state access controls serves a different goal: prevent unauthorized operators from reading sensitive resource attributes, not hide a supplied secret from ordinary CLI display without removing it from state.

Incorrect Answers

A:

The description applies to an ephemeral child module output when an engineer needs to pass a temporary sensitive value from a child module to its parent; the named sensitive = true on a variable instead handles the requirement to hide a supplied secret from ordinary CLI display without removing it from state, so this behavior does not describe sensitive = true on a variable in the situation named.

C:

The description applies to no secrets in version control when an engineer needs to keep API keys out of committed terraform.tfvars and .tf files; the named sensitive = true on a variable instead handles the requirement to hide a supplied secret from ordinary CLI display without removing it from state, so this behavior does not describe sensitive = true on a variable 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 sensitive = true on a variable instead handles the requirement to hide a supplied secret from ordinary CLI display without removing it from state, so this behavior does not describe sensitive = true on a variable in the situation named.

Question 413

An infrastructure drift investigation has a concrete implementation goal: declare the backend type and settings used to store root-module state. What is the most appropriate Terraform mechanism?

  1. A terraform backend block
  2. Partial backend configuration
  3. terraform init -migrate-state
  4. Remote state encryption at rest

Explanation

Correct Answer

A:

A terraform { backend "TYPE" {} } declaration selects state storage; its settings are initialized separately from provider configuration; this directly meets the requirement to declare the backend type and settings used to store root-module state. By comparison, terraform init -migrate-state is intended to copy a known working state's snapshot into a new configured backend, which is a different task from declare the backend type and settings used to store root-module state.

Incorrect Answers

B:

Backend config arguments supplied at init time fill required values, but sensitive content can still be cached in local metadata or plans; this mechanism is useful when the job is to provide environment-specific backend details at initialization rather than hard-coding them, whereas the current scenario requires the engineer to declare the backend type and settings used to store root-module state. These operations have different effects in the stated Terraform workflow.

C:

After changing backend configuration, migrate-state attempts to transfer existing state instead of starting with an empty one; this mechanism is useful when the job is to copy a known working state's snapshot into a new configured backend, whereas the current scenario requires the engineer to declare the backend type and settings used to store root-module state. These operations have different effects in the stated Terraform workflow.

D:

Encryption is controlled by the chosen backend service; Terraform's remote backend abstraction does not supply one universal encryption mechanism; this mechanism is useful when the job is to protect stored state contents from unauthorized storage-layer access, whereas the current scenario requires the engineer to declare the backend type and settings used to store root-module state. These operations have different effects in the stated Terraform workflow.

Question 414

During a design review, the requirement is to target a particular HCP Terraform workspace from a root configuration. Which option should the engineer select?

  1. An HCP private registry module source
  2. HCP Terraform VCS integration
  3. terraform login
  4. A cloud workspaces name setting

Explanation

Correct Answer

D:

The cloud block's workspaces name attribute identifies one workspace, rather than selecting an arbitrary state path; this directly meets the requirement to target a particular HCP Terraform workspace from a root configuration. By comparison, an HCP private registry module source is intended to consume a module managed by the organization's HCP private registry, which is a different task from target a particular HCP Terraform workspace from a root configuration.

Incorrect Answers

A:

A module source can reference a private registry hostname and namespace after the client has appropriate authentication; this mechanism is useful when the job is to consume a module managed by the organization's HCP private registry, whereas the current scenario requires the engineer to target a particular HCP Terraform workspace from a root configuration. These operations have different effects in the stated Terraform workflow.

B:

A VCS-connected workspace coordinates code changes, speculative plans and controlled applies through supported repository integration; this mechanism is useful when the job is to connect reviewed repository commits to automated infrastructure plans, whereas the current scenario requires the engineer to target a particular HCP Terraform workspace from a root configuration. These operations have different effects in the stated Terraform workflow.

C:

The login command stores a CLI API token for the selected service host so CLI-driven workflows can authenticate; this mechanism is useful when the job is to authenticate the local Terraform CLI to an HCP Terraform or Terraform Enterprise hostname, whereas the current scenario requires the engineer to target a particular HCP Terraform workspace from a root configuration. These operations have different effects in the stated Terraform workflow.

Question 415

A Terraform deployment has independent requirements: (1) instantiate the same module with distinct environment inputs; (2) pin a VCS module to a specific Git branch, tag or commit. Which TWO mechanisms directly address these needs? Choose TWO.

  1. A Git ref query parameter
  2. A local value confined to its module
  3. Registry module documentation
  4. Different values for two module calls
  5. Input object variables

Explanation

Correct Answers

A:

A source address ending in ?ref=... selects a Git revision; it does not use the registry-specific module version argument; this meets the requirement to pin a VCS module to a specific Git branch, tag or commit, while the other selected techniques address instantiate the same module with distinct environment inputs, which require their own distinct Terraform mechanisms.

D:

Each call has its own variable assignments and resource instances, even when both calls reference the same module source directory; this meets the requirement to instantiate the same module with distinct environment inputs, while the other selected techniques address pin a VCS module to a specific Git branch, tag or commit, which require their own distinct Terraform mechanisms.

Incorrect Answers

B:

Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value; it addresses avoid assuming a local calculation is automatically visible in a parent module, but this delivery instead requires instantiate the same module with distinct environment inputs and pin a VCS module to a specific Git branch, tag or commit. The required combination involves A Git ref query parameter and Different values for two module calls, not the behavior of A local value confined to its module.

C:

Published module documentation and metadata describe the module interface and help consumers understand required arguments; it addresses determine a module's declared inputs, outputs, providers and usage examples, but this delivery instead requires instantiate the same module with distinct environment inputs and pin a VCS module to a specific Git branch, tag or commit. The required combination involves A Git ref query parameter and Different values for two module calls, not the behavior of Registry module documentation.

E:

An object type lets a module enforce named configuration fields instead of accepting many untyped values; it addresses pass a structured settings bundle into a reusable module, but this delivery instead requires instantiate the same module with distinct environment inputs and pin a VCS module to a specific Git branch, tag or commit. The required combination involves A Git ref query parameter and Different values for two module calls, not the behavior of Input object variables.

Question 416

A configuration review for an application stack has a concrete implementation goal: identify a computed attribute that Terraform cannot determine until apply. What is the most appropriate Terraform mechanism?

  1. Avoiding index churn with for_each
  2. The any type constraint
  3. An unknown plan-time value
  4. for_each with a map

Explanation

Correct Answer

C:

An unknown value represents future information and can propagate through expressions until a provider supplies the result; this directly meets the requirement to identify a computed attribute that Terraform cannot determine until apply. By comparison, the any type constraint is intended to accept values without imposing a specific static input shape, which is a different task from identify a computed attribute that Terraform cannot determine until apply.

Incorrect Answers

A:

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 identify a computed attribute that Terraform cannot determine until apply. These operations have different effects in the stated Terraform workflow.

B:

The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts; this mechanism is useful when the job is to accept values without imposing a specific static input shape, whereas the current scenario requires the engineer to identify a computed attribute that Terraform cannot determine until apply. These operations have different effects in the stated Terraform workflow.

D:

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 identify a computed attribute that Terraform cannot determine until apply. These operations have different effects in the stated Terraform workflow.

Question 417

A Terraform reviewer encounters “Disabling TF_LOG” while assessing how to return a shell session to ordinary Terraform logging after investigation. Which statement correctly describes its actual behavior?

  1. High verbosity creates large logs and greater secret-exposure risk; enable it for a specific incident and disable it afterward.
  2. Setting TF_LOG to DEBUG exposes useful troubleshooting messages without the full trace-level volume.
  3. Unsetting or disabling Terraform's TF_LOG environment setting removes extra diagnostic verbosity from later commands.
  4. INFO logging provides operational context with less detail than DEBUG and TRACE.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to return a shell session to ordinary Terraform logging after investigation, so it produces the behavior described. In contrast, TF_LOG=DEBUG serves a different goal: enable diagnostic output with lower verbosity than TRACE, not return a shell session to ordinary Terraform logging after investigation.

Incorrect Answers

A:

The description applies to verbose logging only during diagnosis when an engineer needs to avoid permanent trace logs in normal automated runs; the named disabling TF_LOG instead handles the requirement to return a shell session to ordinary Terraform logging after investigation, so this behavior does not describe Disabling TF_LOG in the situation named.

B:

The description applies to TF_LOG=DEBUG when an engineer needs to enable diagnostic output with lower verbosity than TRACE; the named disabling TF_LOG instead handles the requirement to return a shell session to ordinary Terraform logging after investigation, so this behavior does not describe Disabling TF_LOG in the situation named.

D:

The description applies to TF_LOG=INFO when an engineer needs to record higher-level operational messages during troubleshooting; the named disabling TF_LOG instead handles the requirement to return a shell session to ordinary Terraform logging after investigation, so this behavior does not describe Disabling TF_LOG in the situation named.

Question 418

A change request asks an engineer to respond after changing the source address of a required provider. Which choice best implements the requested behavior?

  1. Provider source change reinitialization
  2. The .terraform.lock.hcl file
  3. terraform init -backend=false
  4. The .terraform directory

Explanation

Correct Answer

A:

A modified provider requirement can trigger a need to rerun init to resolve the newly declared plugin dependency; this directly meets the requirement to respond after changing the source address of a required provider. By comparison, the .terraform directory is intended to identify where a working directory keeps installed modules and initialization metadata, which is a different task from respond after changing the source address of a required provider.

Incorrect Answers

B:

Terraform records provider version and checksum selections in its dependency lock file, which teams normally commit to source control; this mechanism is useful when the job is to identify which file should be checked in to preserve selected provider packages, whereas the current scenario requires the engineer to respond after changing the source address of a required provider. These operations have different effects in the stated Terraform workflow.

C:

The backend=false switch suppresses backend setup; commands needing backend access may then be unable to proceed; this mechanism is useful when the job is to skip backend initialization during a specialized init operation, whereas the current scenario requires the engineer to respond after changing the source address of a required provider. These operations have different effects in the stated Terraform workflow.

D:

Terraform creates .terraform for module caches, provider installations and backend/workspace metadata; it is not a substitute for committed configuration; this mechanism is useful when the job is to identify where a working directory keeps installed modules and initialization metadata, whereas the current scenario requires the engineer to respond after changing the source address of a required provider. These operations have different effects in the stated Terraform workflow.

Question 419

During one infrastructure delivery, the team must satisfy all of the following: (1) fail a plan or apply when a prerequisite property is unacceptable; (2) convert a delimiter-separated string into a list. Select TWO appropriate Terraform approaches. Choose TWO.

  1. Resource precondition
  2. The split function
  3. Resource postcondition
  4. The file function
  5. The cidrsubnet function
  6. An assert block inside check

Explanation

Correct Answers

A:

A precondition inside lifecycle requires a true predicate before Terraform can continue the relevant resource operation; this meets the requirement to fail a plan or apply when a prerequisite property is unacceptable, while the other selected techniques address convert a delimiter-separated string into a list, which require their own distinct Terraform mechanisms.

B:

split divides a string at a delimiter and returns its constituent substrings; this meets the requirement to convert a delimiter-separated string into a list, while the other selected techniques address fail a plan or apply when a prerequisite property is unacceptable, which require their own distinct Terraform mechanisms.

Incorrect Answers

C:

A postcondition evaluates a condition concerning resource results and blocks downstream use when its assertion fails; it addresses verify an invariant about a resource after reading or managing it, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and convert a delimiter-separated string into a list. The required combination involves The split function and Resource precondition, not the behavior of Resource postcondition.

D:

file reads existing local text; it does not wait for a provisioner to create the file during apply; it addresses read UTF-8 content already present in a local file during evaluation, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and convert a delimiter-separated string into a list. The required combination involves The split function and Resource precondition, not the behavior of The file function.

E:

cidrsubnet derives a subnet CIDR using additional prefix bits and a network number, without provisioning a network resource; it addresses calculate a nested network prefix from a parent CIDR range, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and convert a delimiter-separated string into a list. The required combination involves The split function and Resource precondition, not the behavior of The cidrsubnet function.

F:

Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion; it addresses define a specific boolean statement for a nonblocking Terraform health check, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and convert a delimiter-separated string into a list. The required combination involves The split function and Resource precondition, not the behavior of An assert block inside check.

Question 420

The team evaluates “terraform output -json” for a requirement to retrieve root outputs for integration with another program. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. Command-line -var assignments take high precedence and are useful for an explicit run-specific override.
  2. The module block assigns arguments corresponding to input variables declared in the child; variables are scoped to modules.
  3. The nullable argument on a variable declaration determines whether null is a valid override of its normal value.
  4. The JSON output mode serializes output values and metadata for automation; it can expose sensitive values and must be protected.
  5. The -var-file flag explicitly selects a variables file rather than relying on auto-loaded naming conventions.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to retrieve root outputs for integration with another program, so it produces the behavior described. In contrast, the -var-file option serves a different goal: load a nonstandard variable file selected for one environment, not retrieve root outputs for integration with another program.

Incorrect Answers

A:

The description applies to the -var option when an engineer needs to supply a single variable assignment when invoking plan or apply; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.

B:

The description applies to passing module inputs explicitly when an engineer needs to configure a child module with parent-provided values; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.

C:

The description applies to a nullable variable setting when an engineer needs to control whether a caller can intentionally pass null to an input variable; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.

E:

The description applies to the -var-file option when an engineer needs to load a nonstandard variable file selected for one environment; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests