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

Question 50

A Terraform operations troubleshooting session has a concrete implementation goal: read an existing cloud object so Terraform can associate it with state. What is the most appropriate Terraform mechanism?

  1. An import block's to argument
  2. A matching resource declaration
  3. Provider permissions during import
  4. The import block

Explanation

Correct Answer

C:

Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID; this directly meets the requirement to read an existing cloud object so Terraform can associate it with state. By comparison, a matching resource declaration is intended to avoid unintended changes immediately after importing a remote object, which is a different task from read an existing cloud object so Terraform can associate it with state.

Incorrect Answers

A:

The to argument points to an intended Terraform resource address rather than a provider account name or state backend; this mechanism is useful when the job is to specify which resource instance address should receive the imported object, whereas the current scenario requires the engineer to read an existing cloud object so Terraform can associate it with state. These operations have different effects in the stated Terraform workflow.

B:

Imported infrastructure should have a corresponding resource block with configuration matching the desired attributes so the next plan is safe; this mechanism is useful when the job is to avoid unintended changes immediately after importing a remote object, whereas the current scenario requires the engineer to read an existing cloud object so Terraform can associate it with state. These operations have different effects in the stated Terraform workflow.

D:

A top-level import block identifies a target resource address and import identity so the operation participates in plan and apply; this mechanism is useful when the job is to declare a managed import operation in configuration for planning and applying, whereas the current scenario requires the engineer to read an existing cloud object so Terraform can associate it with state. These operations have different effects in the stated Terraform workflow.

Question 51

A change request asks an engineer to identify where a working directory keeps installed modules and initialization metadata. Which choice best implements the requested behavior?

  1. Re-run init after a backend change
  2. terraform init -reconfigure
  3. terraform init -backend-config
  4. The .terraform directory

Explanation

Correct Answer

D:

Terraform creates .terraform for module caches, provider installations and backend/workspace metadata; it is not a substitute for committed configuration; this directly meets the requirement to identify where a working directory keeps installed modules and initialization metadata. By comparison, terraform init -backend-config is intended to inject partial backend settings at initialization time, which is a different task from identify where a working directory keeps installed modules and initialization metadata.

Incorrect Answers

A:

Terraform requires reinitialization to adopt changed backend settings before normal operations continue; this mechanism is useful when the job is to respond to a modified terraform backend block, whereas the current scenario requires the engineer to identify where a working directory keeps installed modules and initialization metadata. These operations have different effects in the stated Terraform workflow.

B:

Reconfigure tells init to treat the supplied backend configuration as new, rather than performing a state migration; this mechanism is useful when the job is to discard the previously cached backend connection without copying existing state, whereas the current scenario requires the engineer to identify where a working directory keeps installed modules and initialization metadata. These operations have different effects in the stated Terraform workflow.

C:

This option provides backend configuration values separately from static code, although locally cached backend settings may still contain secrets; this mechanism is useful when the job is to inject partial backend settings at initialization time, whereas the current scenario requires the engineer to identify where a working directory keeps installed modules and initialization metadata. These operations have different effects in the stated Terraform workflow.

Question 52

An engineering checklist calls for separate outcomes: (1) read an existing cloud object so Terraform can associate it with state; (2) avoid permanent trace logs in normal automated runs. Which TWO options implement the requested outcomes? Choose TWO.

  1. TF_LOG=INFO
  2. Provider permissions during import
  3. An import configuration review
  4. Verbose logging only during diagnosis
  5. terraform plan -generate-config-out
  6. An import block's to argument

Explanation

Correct Answers

B:

Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID; this meets the requirement to read an existing cloud object so Terraform can associate it with state, while the other selected techniques address avoid permanent trace logs in normal automated runs, which require their own distinct Terraform mechanisms.

D:

High verbosity creates large logs and greater secret-exposure risk; enable it for a specific incident and disable it afterward; this meets the requirement to avoid permanent trace logs in normal automated runs, while the other selected techniques address read an existing cloud object so Terraform can associate it with state, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

INFO logging provides operational context with less detail than DEBUG and TRACE; it addresses record higher-level operational messages during troubleshooting, but this delivery instead requires read an existing cloud object so Terraform can associate it with state and avoid permanent trace logs in normal automated runs. The required combination involves Provider permissions during import and Verbose logging only during diagnosis, not the behavior of TF_LOG=INFO.

C:

Generated resource declarations are a starting point and can include computed or unsuitable attributes requiring manual cleanup; it addresses correct provider-generated HCL rather than trusting every inferred argument, but this delivery instead requires read an existing cloud object so Terraform can associate it with state and avoid permanent trace logs in normal automated runs. The required combination involves Provider permissions during import and Verbose logging only during diagnosis, not the behavior of An import configuration review.

E:

The experimental config-generation flag can write suggested resource declarations for review and correction before apply; it addresses produce draft HCL for resources named in import blocks without matching configuration, but this delivery instead requires read an existing cloud object so Terraform can associate it with state and avoid permanent trace logs in normal automated runs. The required combination involves Provider permissions during import and Verbose logging only during diagnosis, not the behavior of terraform plan -generate-config-out.

F:

The to argument points to an intended Terraform resource address rather than a provider account name or state backend; it addresses specify which resource instance address should receive the imported object, but this delivery instead requires read an existing cloud object so Terraform can associate it with state and avoid permanent trace logs in normal automated runs. The required combination involves Provider permissions during import and Verbose logging only during diagnosis, not the behavior of An import block's to argument.

Question 53

A change request asks an engineer to send proposed changes to a third-party quality or security check service. Which choice best implements the requested behavior?

  1. HCP Terraform run tasks integration
  2. A cloud workspaces tags setting
  3. A cloud block project selector
  4. Mutual exclusivity of cloud and backend

Explanation

Correct Answer

A:

Run tasks integrate external systems into workflow checkpoints without changing the Terraform resource graph directly; this directly meets the requirement to send proposed changes to a third-party quality or security check service. By comparison, a cloud block project selector is intended to associate an HCP Terraform workspace with an intended project during configuration, which is a different task from send proposed changes to a third-party quality or security check service.

Incorrect Answers

B:

The cloud integration can choose workspaces based on tags, subject to the workspaces block's allowed configuration form; this mechanism is useful when the job is to select an HCP Terraform workspace collection by workspace tags, whereas the current scenario requires the engineer to send proposed changes to a third-party quality or security check service. These operations have different effects in the stated Terraform workflow.

C:

The cloud workspaces block supports a project setting for organizing related workspace integration; this mechanism is useful when the job is to associate an HCP Terraform workspace with an intended project during configuration, whereas the current scenario requires the engineer to send proposed changes to a third-party quality or security check service. These operations have different effects in the stated Terraform workflow.

D:

Terraform does not allow simultaneous cloud and backend blocks because both would compete to control the state and execution connection; this mechanism is useful when the job is to avoid declaring both HCP cloud integration and a standard backend in the same root module, whereas the current scenario requires the engineer to send proposed changes to a third-party quality or security check service. These operations have different effects in the stated Terraform workflow.

Question 54

A configuration review for an application stack requires a way to correct a pair of modules that each require the other's output to initialize. Which Terraform approach most directly fulfills that request?

  1. Resource targeting as an exception
  2. create_before_destroy
  3. terraform_data as a replacement trigger
  4. Dependency cycle resolution

Explanation

Correct Answer

D:

Dependency cycles cannot be topologically ordered and require restructuring the relationships or splitting responsibilities; this directly meets the requirement to correct a pair of modules that each require the other's output to initialize. By comparison, resource targeting as an exception is intended to repair an isolated broken dependency while acknowledging incomplete plan coverage, which is a different task from correct a pair of modules that each require the other's output to initialize.

Incorrect Answers

A:

The -target option narrows an operation to selected objects and prerequisites; routine selective deployment is not its intended model; this mechanism is useful when the job is to repair an isolated broken dependency while acknowledging incomplete plan coverage, whereas the current scenario requires the engineer to correct a pair of modules that each require the other's output to initialize. These operations have different effects in the stated Terraform workflow.

B:

This lifecycle setting changes replacement order, but requires names and quotas to permit temporary coexistence; this mechanism is useful when the job is to create a replacement object before deleting the previous instance, whereas the current scenario requires the engineer to correct a pair of modules that each require the other's output to initialize. These operations have different effects in the stated Terraform workflow.

C:

A terraform_data resource can expose input-related lifecycle actions for replace_triggered_by, which expects managed resource changes; this mechanism is useful when the job is to trigger replacement from a plain variable value change, whereas the current scenario requires the engineer to correct a pair of modules that each require the other's output to initialize. These operations have different effects in the stated Terraform workflow.

Question 55

An engineer intends to isolate state and runs for two deployment environments and is reviewing “Distinct production and staging workspaces”. What consequence follows from using it as intended?

  1. Workspace tags help group and select workspaces, including when a CLI cloud block targets tagged workspace sets.
  2. Project-level access scopes workspace capabilities for teams based on organizational boundaries.
  3. Workspaces can reference separate branches or release controls while retaining isolated state for each environment.
  4. Each HCP Terraform workspace has its own state and run configuration so changes in one do not automatically update the other.
  5. Organizations provide a broader boundary containing projects, workspaces, teams and policy configuration.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to isolate state and runs for two deployment environments, so it produces the behavior described. In contrast, environment promotion via workspaces serves a different goal: use a reviewed configuration revision across separate testing and production states, not isolate state and runs for two deployment environments.

Incorrect Answers

A:

The description applies to workspace tags when an engineer needs to categorize HCP Terraform workspaces for filtering or configuration selection; the named distinct production and staging workspaces instead handles the requirement to isolate state and runs for two deployment environments, so this behavior does not describe Distinct production and staging workspaces in the situation named.

B:

The description applies to project-scoped team access when an engineer needs to delegate administration of one team's project without granting universal organization access; the named distinct production and staging workspaces instead handles the requirement to isolate state and runs for two deployment environments, so this behavior does not describe Distinct production and staging workspaces in the situation named.

C:

The description applies to environment promotion via workspaces when an engineer needs to use a reviewed configuration revision across separate testing and production states; the named distinct production and staging workspaces instead handles the requirement to isolate state and runs for two deployment environments, so this behavior does not describe Distinct production and staging workspaces in the situation named.

E:

The description applies to HCP Terraform organization separation when an engineer needs to separate independent business units with different governance needs; the named distinct production and staging workspaces instead handles the requirement to isolate state and runs for two deployment environments, so this behavior does not describe Distinct production and staging workspaces in the situation named.

Question 56

A Terraform deployment has independent requirements: (1) read a map element and provide a fallback when the key is absent; (2) preserve instance identity when a middle collection item is removed. Which TWO mechanisms directly address these needs? Choose TWO.

  1. The for expression
  2. The lookup function
  3. A number variable type
  4. The jsondecode function
  5. Avoiding index churn with for_each
  6. The base64encode function

Explanation

Correct Answers

B:

lookup(map, key, default) retrieves the selected key's value or the supplied default if the key does not exist; this meets the requirement to read a map element and provide a fallback when the key is absent, while the other selected techniques address preserve instance identity when a middle collection item is removed, which require their own distinct Terraform mechanisms.

E:

Keyed for_each instances use stable identifiers, whereas count indexes can shift when list elements are deleted; this meets the requirement to preserve instance identity when a middle collection item is removed, while the other selected techniques address read a map element and provide a fallback when the key is absent, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

A for expression builds derived collection values, optionally filtering with an if clause and transforming keys or values; it addresses transform a collection's elements into a new list or map, but this delivery instead requires read a map element and provide a fallback when the key is absent and preserve instance identity when a middle collection item is removed. The required combination involves Avoiding index churn with for_each and The lookup function, not the behavior of The for expression.

C:

The number type supports numerical operations and validation such as comparisons or addition; it addresses represent arithmetic quantities without parsing string parameters manually, but this delivery instead requires read a map element and provide a fallback when the key is absent and preserve instance identity when a middle collection item is removed. The required combination involves Avoiding index churn with for_each and The lookup function, not the behavior of A number variable type.

D:

jsondecode converts JSON input into native maps, objects, lists or primitives used in expressions; it addresses parse a JSON document string into Terraform values, but this delivery instead requires read a map element and provide a fallback when the key is absent and preserve instance identity when a middle collection item is removed. The required combination involves Avoiding index churn with for_each and The lookup function, not the behavior of The jsondecode function.

F:

base64encode applies a reversible encoding and should not be mistaken for encryption of secrets; it addresses turn ordinary string content into Base64 text, but this delivery instead requires read a map element and provide a fallback when the key is absent and preserve instance identity when a middle collection item is removed. The required combination involves Avoiding index churn with for_each and The lookup function, not the behavior of The base64encode function.

Question 57

During a design review, the requirement is to pass a structured settings bundle into a reusable module. Which option should the engineer select?

  1. Parent-to-child argument passing
  2. Input object variables
  3. A local value confined to its module
  4. Child input variable scope
  5. Variable validation inside a module
  6. A child module output

Explanation

Correct Answer

B:

An object type lets a module enforce named configuration fields instead of accepting many untyped values; this directly meets the requirement to pass a structured settings bundle into a reusable module. By comparison, a child module output is intended to expose a chosen internal attribute to the calling parent module, which is a different task from pass a structured settings bundle into a reusable module.

Incorrect Answers

A:

A module block explicitly sets the child's declared input variables using arguments of matching names; this mechanism is useful when the job is to set a reusable module's environment tag from the caller, whereas the current scenario requires the engineer to pass a structured settings bundle into a reusable module. These operations have different effects in the stated Terraform workflow.

C:

Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value; this mechanism is useful when the job is to avoid assuming a local calculation is automatically visible in a parent module, whereas the current scenario requires the engineer to pass a structured settings bundle into a reusable module. These operations have different effects in the stated Terraform workflow.

D:

Variables declared by a child module belong to that module and receive values via the caller's module block; this mechanism is useful when the job is to make a setting available inside a called module without creating a global variable, whereas the current scenario requires the engineer to pass a structured settings bundle into a reusable module. These operations have different effects in the stated Terraform workflow.

E:

A child module may validate its input variables using conditions and errors independent of the parent's variable definitions; this mechanism is useful when the job is to enforce a reusable module's own input contract, whereas the current scenario requires the engineer to pass a structured settings bundle into a reusable module. These operations have different effects in the stated Terraform workflow.

F:

The output block defines a published module interface; the parent reads the value as module.NAME.OUTPUT; this mechanism is useful when the job is to expose a chosen internal attribute to the calling parent module, whereas the current scenario requires the engineer to pass a structured settings bundle into a reusable module. These operations have different effects in the stated Terraform workflow.

Question 58

A Terraform change proposal names “A private registry module source” to reuse an internally published module available to authorized organization members. Which outcome can reviewers attribute to that particular mechanism?

  1. Published module documentation and metadata describe the module interface and help consumers understand required arguments.
  2. Keeping reusable child modules separately versioned allows independent adoption and maintenance by different Terraform root modules.
  3. Module source syntax places //subdir after the package address to select the intended directory within the downloaded package.
  4. A git::ssh:// module source delegates repository authentication to Git and SSH rather than a Terraform registry token.
  5. HCP Terraform's private registry can distribute approved modules with access control and supported version metadata.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to reuse an internally published module available to authorized organization members, so it produces the behavior described. In contrast, a separate module repository serves a different goal: share reusable Terraform configuration with multiple root projects, not reuse an internally published module available to authorized organization members.

Incorrect Answers

A:

The description applies to registry module documentation when an engineer needs to determine a module's declared inputs, outputs, providers and usage examples; the named a private registry module source instead handles the requirement to reuse an internally published module available to authorized organization members, so this behavior does not describe A private registry module source in the situation named.

B:

The description applies to a separate module repository when an engineer needs to share reusable Terraform configuration with multiple root projects; the named a private registry module source instead handles the requirement to reuse an internally published module available to authorized organization members, so this behavior does not describe A private registry module source in the situation named.

C:

The description applies to the double-slash source subdirectory when an engineer needs to use a nested module stored below a repository's root directory; the named a private registry module source instead handles the requirement to reuse an internally published module available to authorized organization members, so this behavior does not describe A private registry module source in the situation named.

D:

The description applies to a Git SSH module source when an engineer needs to obtain module code from a repository that requires SSH-based access; the named a private registry module source instead handles the requirement to reuse an internally published module available to authorized organization members, so this behavior does not describe A private registry module source in the situation named.

Question 59

A Terraform change proposal names “Input object variables” to pass a structured settings bundle into a reusable module. Which outcome can reviewers attribute to that particular mechanism?

  1. An object type lets a module enforce named configuration fields instead of accepting many untyped values.
  2. Each module boundary needs an output passthrough because the root cannot directly access an arbitrary grandchild's private resources.
  3. A child output can be marked sensitive, but its underlying value may still reside in state unless it uses permitted ephemeral handling.
  4. Root variables accept runtime assignments, whereas a child module normally receives its inputs through the parent's module call.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to pass a structured settings bundle into a reusable module, so it produces the behavior described. In contrast, root input variable scope serves a different goal: read command-line and tfvars input values for the root module, not pass a structured settings bundle into a reusable module.

Incorrect Answers

B:

The description applies to nested module output propagation when an engineer needs to make a value from a grandchild module visible to the root module; the named input object variables instead handles the requirement to pass a structured settings bundle into a reusable module, so this behavior does not describe Input object variables in the situation named.

C:

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 input object variables instead handles the requirement to pass a structured settings bundle into a reusable module, so this behavior does not describe Input object variables in the situation named.

D:

The description applies to root input variable scope when an engineer needs to read command-line and tfvars input values for the root module; the named input object variables instead handles the requirement to pass a structured settings bundle into a reusable module, so this behavior does not describe Input object variables in the situation named.

Question 60

During an infrastructure design review about how to check proposed infrastructure against rules expressed in Open Policy Agent policies, a maintainer asks what “OPA policy enforcement” does. Which description is accurate?

  1. Projects group workspaces and support scoped access management for organizational teams.
  2. HCP Terraform supports OPA-based policy sets for automated governance on applicable runs.
  3. Team access controls define which users may perform supported workspace operations rather than relying only on provider credentials.
  4. Registry access and publishing permissions help centralize reusable module governance across teams.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to check proposed infrastructure against rules expressed in Open Policy Agent policies, so it produces the behavior described. In contrast, project-based permission boundaries serves a different goal: delegate administration of grouped HCP Terraform workspaces, not check proposed infrastructure against rules expressed in Open Policy Agent policies.

Incorrect Answers

A:

The description applies to project-based permission boundaries when an engineer needs to delegate administration of grouped HCP Terraform workspaces; the named oPA policy enforcement instead handles the requirement to check proposed infrastructure against rules expressed in Open Policy Agent policies, so this behavior does not describe OPA policy enforcement in the situation named.

C:

The description applies to HCP team permissions when an engineer needs to grant operators different abilities to view, plan or apply workspace changes; the named oPA policy enforcement instead handles the requirement to check proposed infrastructure against rules expressed in Open Policy Agent policies, so this behavior does not describe OPA policy enforcement in the situation named.

D:

The description applies to a restricted private registry when an engineer needs to let approved teams discover modules while controlling publication rights; the named oPA policy enforcement instead handles the requirement to check proposed infrastructure against rules expressed in Open Policy Agent policies, so this behavior does not describe OPA policy enforcement in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests