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

Question 260

During a design review, the requirement is to fail a plan or apply when a prerequisite property is unacceptable. Which option should the engineer select?

  1. Input variable validation
  2. An assert block inside check
  3. Resource precondition
  4. Postconditions for exported IDs

Explanation

Correct Answer

C:

A precondition inside lifecycle requires a true predicate before Terraform can continue the relevant resource operation; this directly meets the requirement to fail a plan or apply when a prerequisite property is unacceptable. By comparison, an assert block inside check is intended to define a specific boolean statement for a nonblocking Terraform health check, which is a different task from fail a plan or apply when a prerequisite property is unacceptable.

Incorrect Answers

A:

The validation block uses a condition and a custom error_message to enforce rules on caller-supplied values; this mechanism is useful when the job is to reject malformed module inputs before provisioning resources, whereas the current scenario requires the engineer to fail a plan or apply when a prerequisite property is unacceptable. These operations have different effects in the stated Terraform workflow.

B:

Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion; this mechanism is useful when the job is to define a specific boolean statement for a nonblocking Terraform health check, whereas the current scenario requires the engineer to fail a plan or apply when a prerequisite property is unacceptable. These operations have different effects in the stated Terraform workflow.

D:

Postconditions validate resultant resource or data-source attributes and prevent dependents from relying on invalid results; this mechanism is useful when the job is to guard a dependent consumer against a provider result that violates an invariant, whereas the current scenario requires the engineer to fail a plan or apply when a prerequisite property is unacceptable. These operations have different effects in the stated Terraform workflow.

Question 261

A new infrastructure-as-code adoption project requires a way to manage cloud resources and SaaS resources in one configuration. Which Terraform approach most directly fulfills that request?

  1. Multi-cloud state visibility
  2. Cross-provider references
  3. Provider-specific capabilities
  4. Multiple provider requirements

Explanation

Correct Answer

D:

Terraform can install different providers and let each manage its own service API within a single graph; this directly meets the requirement to manage cloud resources and SaaS resources in one configuration. By comparison, cross-provider references is intended to link an output from one service to a dependent resource on another service, which is a different task from manage cloud resources and SaaS resources in one configuration.

Incorrect Answers

A:

One Terraform state can map managed resources from multiple providers, although separate configurations may improve blast-radius isolation; this mechanism is useful when the job is to track resources in distinct providers together within the chosen state scope, whereas the current scenario requires the engineer to manage cloud resources and SaaS resources in one configuration. These operations have different effects in the stated Terraform workflow.

B:

An attribute reference between resource instances can create a dependency across provider boundaries; this mechanism is useful when the job is to link an output from one service to a dependent resource on another service, whereas the current scenario requires the engineer to manage cloud resources and SaaS resources in one configuration. These operations have different effects in the stated Terraform workflow.

C:

A shared Terraform language does not erase provider API differences; each provider defines supported resource schemas and behavior; this mechanism is useful when the job is to avoid assuming that all providers expose identical resource types and options, whereas the current scenario requires the engineer to manage cloud resources and SaaS resources in one configuration. These operations have different effects in the stated Terraform workflow.

Question 262

A runbook lists “TF_LOG_PROVIDER” for the task to isolate provider-related diagnostic output during API troubleshooting. Which technical effect should its description include?

  1. ERROR restricts diagnostic output to serious problems rather than normal trace-level activity.
  2. Setting TF_LOG to DEBUG exposes useful troubleshooting messages without the full trace-level volume.
  3. The TF_LOG_PROVIDER setting controls provider log verbosity and can help locate failures involving provider communication.
  4. TF_LOG_PATH directs log output to a file and should be combined with an enabled TF_LOG level.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to isolate provider-related diagnostic output during API troubleshooting, so it produces the behavior described. In contrast, TF_LOG_PATH serves a different goal: save enabled Terraform diagnostic logs to a designated file, not isolate provider-related diagnostic output during API troubleshooting.

Incorrect Answers

A:

The description applies to TF_LOG=ERROR when an engineer needs to focus logging on error-level diagnostics; the named TF_LOG_PROVIDER instead handles the requirement to isolate provider-related diagnostic output during API troubleshooting, so this behavior does not describe TF_LOG_PROVIDER 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 TF_LOG_PROVIDER instead handles the requirement to isolate provider-related diagnostic output during API troubleshooting, so this behavior does not describe TF_LOG_PROVIDER in the situation named.

D:

The description applies to TF_LOG_PATH when an engineer needs to save enabled Terraform diagnostic logs to a designated file; the named TF_LOG_PROVIDER instead handles the requirement to isolate provider-related diagnostic output during API troubleshooting, so this behavior does not describe TF_LOG_PROVIDER in the situation named.

Question 263

An engineer proposes “An aliased provider instance” to route a particular managed object to the named alternate provider configuration. Which outcome does the proposed technique actually provide?

  1. The resource-level provider meta-argument selects a provider instance, not a different backend or Terraform workspace.
  2. List both plugins under required_providers and configure each service's provider independently as needed.
  3. Declare an aliased provider configuration and assign provider = provider_name.alias on resources that need the alternate region.
  4. The required_providers entry maps the chosen local name to a specific fully qualified provider source address.

Explanation

Correct Answer

C:

An aliased provider instance is used when an operator needs to create resources in a second region using the same provider type. Consequently, this choice cannot meet the separate requirement to route a particular managed object to the named alternate provider configuration. The intended action would instead require A resource's provider meta-argument.

Incorrect Answers

A:

That outcome belongs to A resource's provider meta-argument, the mechanism that can route a particular managed object to the named alternate provider configuration. The question concerns the engineer’s actual proposal, An aliased provider instance; it is directed at create resources in a second region using the same provider type, not that result.

B:

This behavior belongs to Separate required provider names, which helps engineers use two unrelated service APIs in one root configuration rather than satisfying the separate requirement to route a particular managed object to the named alternate provider configuration. The attempted technique was An aliased provider instance; it would instead be used to create resources in a second region using the same provider type, not to produce the effect associated with Separate required provider names.

D:

This behavior belongs to Provider-local name mapping, which helps engineers reuse a provider whose source address differs from its short local identifier rather than satisfying the separate requirement to route a particular managed object to the named alternate provider configuration. The attempted technique was An aliased provider instance; it would instead be used to create resources in a second region using the same provider type, not to produce the effect associated with Provider-local name mapping.

Question 264

The team evaluates “Nested module output propagation” for a requirement to make a value from a grandchild module visible to the root module. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. Variables declared by a child module belong to that module and receive values via the caller's module block.
  2. Each call has its own variable assignments and resource instances, even when both calls reference the same module source directory.
  3. Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value.
  4. A default inside the child variable declaration applies when the caller omits that module argument.
  5. Each module boundary needs an output passthrough because the root cannot directly access an arbitrary grandchild's private resources.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to make a value from a grandchild module visible to the root module, so it produces the behavior described. In contrast, child input variable scope serves a different goal: make a setting available inside a called module without creating a global variable, not make a value from a grandchild module visible to the root module.

Incorrect Answers

A:

The description applies to child input variable scope when an engineer needs to make a setting available inside a called module without creating a global variable; the named nested module output propagation instead handles the requirement to make a value from a grandchild module visible to the root module, so this behavior does not describe Nested module output propagation in the situation named.

B:

The description applies to different values for two module calls when an engineer needs to instantiate the same module with distinct environment inputs; the named nested module output propagation instead handles the requirement to make a value from a grandchild module visible to the root module, so this behavior does not describe Nested module output propagation in the situation named.

C:

The description applies to a local value confined to its module when an engineer needs to avoid assuming a local calculation is automatically visible in a parent module; the named nested module output propagation instead handles the requirement to make a value from a grandchild module visible to the root module, so this behavior does not describe Nested module output propagation in the situation named.

D:

The description applies to a variable default inside a child when an engineer needs to make a module input optional when callers do not require customization; the named nested module output propagation instead handles the requirement to make a value from a grandchild module visible to the root module, so this behavior does not describe Nested module output propagation in the situation named.

Question 265

During one infrastructure delivery, the team must satisfy all of the following: (1) use a network module's subnet IDs inside an application module call; (2) obtain module code from a repository that requires SSH-based access. Select TWO appropriate Terraform approaches. Choose TWO.

  1. Module-level depends_on
  2. Registry module documentation
  3. A module output reference
  4. Avoiding hard-coded child credentials
  5. A Git SSH module source

Explanation

Correct Answers

C:

Module outputs provide explicit integration points between modules without relying on child resource addresses; this meets the requirement to use a network module's subnet IDs inside an application module call, while the other selected techniques address obtain module code from a repository that requires SSH-based access, which require their own distinct Terraform mechanisms.

E:

A git::ssh:// module source delegates repository authentication to Git and SSH rather than a Terraform registry token; this meets the requirement to obtain module code from a repository that requires SSH-based access, while the other selected techniques address use a network module's subnet IDs inside an application module call, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

depends_on on a module call affects all resources and data sources inside that module and can constrain concurrency; it addresses create an explicit ordering edge for module resources that have a real hidden dependency, but this delivery instead requires use a network module's subnet IDs inside an application module call and obtain module code from a repository that requires SSH-based access. The required combination involves A Git SSH module source and A module output reference, not the behavior of Module-level depends_on.

B:

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 use a network module's subnet IDs inside an application module call and obtain module code from a repository that requires SSH-based access. The required combination involves A Git SSH module source and A module output reference, not the behavior of Registry module documentation.

D:

Reusable modules normally declare provider requirements while callers supply provider configurations and credentials; it addresses keep authentication and deployment-specific region choices outside a reusable child module, but this delivery instead requires use a network module's subnet IDs inside an application module call and obtain module code from a repository that requires SSH-based access. The required combination involves A Git SSH module source and A module output reference, not the behavior of Avoiding hard-coded child credentials.

Question 266

A runbook lists “Run triggers” for the task to start downstream workspace runs after upstream workspace changes complete. Which technical effect should its description include?

  1. HCP Terraform can use supported dynamic provider credentials that are generated for runs rather than stored as permanent workspace secrets.
  2. Run triggers coordinate dependent HCP Terraform workspaces through an event relationship without merging their states.
  3. Variable sets let administrators manage common workspace variables centrally and scope them to intended workspaces or projects.
  4. Private registry modules can be published, versioned and discovered by authorized HCP Terraform users.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to start downstream workspace runs after upstream workspace changes complete, so it produces the behavior described. In contrast, organization variable sets serves a different goal: supply shared environment or Terraform input values across several workspaces, not start downstream workspace runs after upstream workspace changes complete.

Incorrect Answers

A:

The description applies to HCP provider dynamic credentials when an engineer needs to replace standing cloud keys with short-lived run identities; the named run triggers instead handles the requirement to start downstream workspace runs after upstream workspace changes complete, so this behavior does not describe Run triggers in the situation named.

C:

The description applies to organization variable sets when an engineer needs to supply shared environment or Terraform input values across several workspaces; the named run triggers instead handles the requirement to start downstream workspace runs after upstream workspace changes complete, so this behavior does not describe Run triggers in the situation named.

D:

The description applies to the HCP private module registry when an engineer needs to share approved modules with organization members without relying on public registry visibility; the named run triggers instead handles the requirement to start downstream workspace runs after upstream workspace changes complete, so this behavior does not describe Run triggers in the situation named.

Question 267

A reproducibility-focused deployment review has a concrete implementation goal: run unchanged configuration repeatedly without inventing new infrastructure updates. What is the most appropriate Terraform mechanism?

  1. Idempotent convergence
  2. Environment parametrization
  3. Policy checks before provisioning
  4. Collaboration through remote state

Explanation

Correct Answer

A:

With no configuration or remote drift requiring action, a new plan normally proposes no infrastructure changes; this directly meets the requirement to run unchanged configuration repeatedly without inventing new infrastructure updates. By comparison, environment parametrization is intended to deploy similarly structured stacks with environment-specific settings, which is a different task from run unchanged configuration repeatedly without inventing new infrastructure updates.

Incorrect Answers

B:

Terraform input variables permit different values for capacity, names and endpoints without copying the entire resource definition; this mechanism is useful when the job is to deploy similarly structured stacks with environment-specific settings, whereas the current scenario requires the engineer to run unchanged configuration repeatedly without inventing new infrastructure updates. These operations have different effects in the stated Terraform workflow.

C:

A policy or governance stage can inspect proposed infrastructure changes before allowing an apply to proceed; this mechanism is useful when the job is to enforce organizational infrastructure constraints consistently, whereas the current scenario requires the engineer to run unchanged configuration repeatedly without inventing new infrastructure updates. These operations have different effects in the stated Terraform workflow.

D:

A backend supporting remote storage and locking can centralize state and prevent conflicting concurrent changes; this mechanism is useful when the job is to allow authorized operators to use one shared source of Terraform state, whereas the current scenario requires the engineer to run unchanged configuration repeatedly without inventing new infrastructure updates. These operations have different effects in the stated Terraform workflow.

Question 268

An engineer intends to update the provider source address recorded for affected state resources and is reviewing “terraform state replace-provider”. What consequence follows from using it as intended?

  1. State pull reads the current snapshot to standard output, including potentially sensitive provider attributes.
  2. Workspace list shows logical Terraform workspaces, which may correspond to separate state instances depending on backend support.
  3. State show presents one resource's stored attributes in human-readable form and may reveal secret values.
  4. The JSON representation supports automated inspection but must be protected because redacted display is not a security boundary.
  5. Replace-provider rewrites provider source references in state and creates a backup before the edit.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to update the provider source address recorded for affected state resources, so it produces the behavior described. In contrast, terraform state pull serves a different goal: export a state snapshot from the configured backend for careful examination, not update the provider source address recorded for affected state resources.

Incorrect Answers

A:

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 state replace-provider instead handles the requirement to update the provider source address recorded for affected state resources, so this behavior does not describe terraform state replace-provider in the situation named.

B:

The description applies to terraform workspace list when an engineer needs to list the workspaces available through the initialized backend; the named terraform state replace-provider instead handles the requirement to update the provider source address recorded for affected state resources, so this behavior does not describe terraform state replace-provider in the situation named.

C:

The description applies to terraform state show ADDRESS when an engineer needs to view attributes for a specified state-tracked resource instance; the named terraform state replace-provider instead handles the requirement to update the provider source address recorded for affected state resources, so this behavior does not describe terraform state replace-provider in the situation named.

D:

The description applies to terraform show -json when an engineer needs to read plan or state information in a structured representation; the named terraform state replace-provider instead handles the requirement to update the provider source address recorded for affected state resources, so this behavior does not describe terraform state replace-provider in the situation named.

Question 269

An engineer intends to review an all-destroy plan before approving resource deletion and is reviewing “terraform plan -destroy”. What consequence follows from using it as intended?

  1. Terraform generally reverses dependency order when destroying managed resources so dependent objects are removed first.
  2. Removing a state association, for example with terraform state rm, makes Terraform forget the object without asking the provider to delete it.
  3. Reviewing a destroy plan is essential because a command can remove every managed instance within the relevant state scope.
  4. Destroy planning shows the deletion proposal without carrying out the deletion until apply.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to review an all-destroy plan before approving resource deletion, so it produces the behavior described. In contrast, dependency-aware deletion serves a different goal: remove dependent resources before objects they rely on, not review an all-destroy plan before approving resource deletion.

Incorrect Answers

A:

The description applies to dependency-aware deletion when an engineer needs to remove dependent resources before objects they rely on; the named terraform plan -destroy instead handles the requirement to review an all-destroy plan before approving resource deletion, so this behavior does not describe terraform plan -destroy in the situation named.

B:

The description applies to remove from state without deletion when an engineer needs to stop managing an existing object while preserving the real remote infrastructure; the named terraform plan -destroy instead handles the requirement to review an all-destroy plan before approving resource deletion, so this behavior does not describe terraform plan -destroy in the situation named.

C:

The description applies to destroy plan risk review when an engineer needs to identify which root-module-managed resources will be affected before a cleanup; the named terraform plan -destroy instead handles the requirement to review an all-destroy plan before approving resource deletion, so this behavior does not describe terraform plan -destroy in the situation named.

Question 270

A maintenance engineer inspecting a deployment needs to produce draft HCL for resources named in import blocks without matching configuration. Which feature or operation is the most direct match?

  1. A matching resource declaration
  2. An import configuration review
  3. An import block's to argument
  4. terraform plan -generate-config-out

Explanation

Correct Answer

D:

The experimental config-generation flag can write suggested resource declarations for review and correction before apply; this directly meets the requirement to produce draft HCL for resources named in import blocks without matching configuration. By comparison, an import block's to argument is intended to specify which resource instance address should receive the imported object, which is a different task from produce draft HCL for resources named in import blocks without matching configuration.

Incorrect Answers

A:

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 produce draft HCL for resources named in import blocks without matching configuration. These operations have different effects in the stated Terraform workflow.

B:

Generated resource declarations are a starting point and can include computed or unsuitable attributes requiring manual cleanup; this mechanism is useful when the job is to correct provider-generated HCL rather than trusting every inferred argument, whereas the current scenario requires the engineer to produce draft HCL for resources named in import blocks without matching configuration. These operations have different effects in the stated Terraform workflow.

C:

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 produce draft HCL for resources named in import blocks without matching configuration. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests