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

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.

Question 271

A Terraform runbook prescribes “terraform plan -refresh-only -out=refresh.tfplan” to understand why Terraform proposes creating a managed object deleted outside the workflow, but it does not meet the requirement. What does that step actually accomplish?

  1. The state mv command reassigns a managed resource's address without contacting the provider to destroy the object.
  2. A refresh-only plan saved with -out previews state and root-output corrections for later apply; the plan command itself does not commit those changes.
  3. If a provider reports a tracked object no longer exists, a normal plan generally proposes recreating it when its resource block remains.
  4. A removed block can intentionally forget the previous resource address without a provider delete when lifecycle destroy is false.

Explanation

Correct Answer

B:

terraform plan -refresh-only -out=refresh.tfplan is used when an operator needs to save a state-only refresh plan for review and later controlled application. Consequently, this choice cannot meet the separate requirement to understand why Terraform proposes creating a managed object deleted outside the workflow. The intended action would instead require A refreshed missing resource.

Incorrect Answers

A:

This behavior belongs to terraform state mv, which helps engineers change the address of a tracked object directly within state rather than satisfying the separate requirement to understand why Terraform proposes creating a managed object deleted outside the workflow. The attempted technique was terraform plan -refresh-only -out=refresh.tfplan; it would instead be used to save a state-only refresh plan for review and later controlled application, not to produce the effect associated with terraform state mv.

C:

That outcome belongs to A refreshed missing resource, the mechanism that can understand why Terraform proposes creating a managed object deleted outside the workflow. The question concerns the engineer’s actual proposal, terraform plan -refresh-only -out=refresh.tfplan; it is directed at save a state-only refresh plan for review and later controlled application, not that result.

D:

This behavior belongs to A removed block with destroy=false, which helps engineers declare that a resource should leave management while its actual object is retained rather than satisfying the separate requirement to understand why Terraform proposes creating a managed object deleted outside the workflow. The attempted technique was terraform plan -refresh-only -out=refresh.tfplan; it would instead be used to save a state-only refresh plan for review and later controlled application, not to produce the effect associated with A removed block with destroy=false.

Question 272

During a design review, the requirement is to identify a resource instance by its type and local name. Which option should the engineer select?

  1. The resource address format
  2. A local value reference
  3. Avoiding dependency cycles
  4. An implicit attribute dependency
  5. A variable reference

Explanation

Correct Answer

A:

A resource address inside a module ordinarily uses TYPE.NAME, with optional instance indexing when count or for_each is used; this directly meets the requirement to identify a resource instance by its type and local name. By comparison, a variable reference is intended to inject a caller-supplied input into a resource argument, which is a different task from identify a resource instance by its type and local name.

Incorrect Answers

B:

The syntax local.NAME accesses a locally defined expression evaluated in the current module; this mechanism is useful when the job is to share one calculated expression among multiple resources in a module, whereas the current scenario requires the engineer to identify a resource instance by its type and local name. These operations have different effects in the stated Terraform workflow.

C:

Terraform cannot order a cycle of dependencies; restructure references or resource design to remove the circular edge; this mechanism is useful when the job is to resolve a graph where two resources each depend on the other, whereas the current scenario requires the engineer to identify a resource instance by its type and local name. These operations have different effects in the stated Terraform workflow.

D:

Referencing another managed resource's attribute creates an implicit dependency in Terraform's graph; this mechanism is useful when the job is to ensure a dependent resource waits for the object whose ID it needs, whereas the current scenario requires the engineer to identify a resource instance by its type and local name. These operations have different effects in the stated Terraform workflow.

E:

var.NAME reads a declared input variable in the module where the variable block is defined; this mechanism is useful when the job is to inject a caller-supplied input into a resource argument, whereas the current scenario requires the engineer to identify a resource instance by its type and local name. These operations have different effects in the stated Terraform workflow.

Question 273

A Terraform deployment has independent requirements: (1) correct provider-generated HCL rather than trusting every inferred argument; (2) isolate provider-related diagnostic output during API troubleshooting. Which TWO mechanisms directly address these needs? Choose TWO.

  1. TF_LOG_PATH
  2. Disabling TF_LOG
  3. TF_LOG_PROVIDER
  4. An import configuration review
  5. A matching resource declaration
  6. Verbose logging only during diagnosis

Explanation

Correct Answers

C:

The TF_LOG_PROVIDER setting controls provider log verbosity and can help locate failures involving provider communication; this meets the requirement to isolate provider-related diagnostic output during API troubleshooting, while the other selected techniques address correct provider-generated HCL rather than trusting every inferred argument, which require their own distinct Terraform mechanisms.

D:

Generated resource declarations are a starting point and can include computed or unsuitable attributes requiring manual cleanup; this meets the requirement to correct provider-generated HCL rather than trusting every inferred argument, while the other selected techniques address isolate provider-related diagnostic output during API troubleshooting, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

TF_LOG_PATH directs log output to a file and should be combined with an enabled TF_LOG level; it addresses save enabled Terraform diagnostic logs to a designated file, but this delivery instead requires correct provider-generated HCL rather than trusting every inferred argument and isolate provider-related diagnostic output during API troubleshooting. The required combination involves An import configuration review and TF_LOG_PROVIDER, not the behavior of TF_LOG_PATH.

B:

Unsetting or disabling Terraform's TF_LOG environment setting removes extra diagnostic verbosity from later commands; it addresses return a shell session to ordinary Terraform logging after investigation, but this delivery instead requires correct provider-generated HCL rather than trusting every inferred argument and isolate provider-related diagnostic output during API troubleshooting. The required combination involves An import configuration review and TF_LOG_PROVIDER, not the behavior of Disabling TF_LOG.

E:

Imported infrastructure should have a corresponding resource block with configuration matching the desired attributes so the next plan is safe; it addresses avoid unintended changes immediately after importing a remote object, but this delivery instead requires correct provider-generated HCL rather than trusting every inferred argument and isolate provider-related diagnostic output during API troubleshooting. The required combination involves An import configuration review and TF_LOG_PROVIDER, not the behavior of A matching resource declaration.

F:

High verbosity creates large logs and greater secret-exposure risk; enable it for a specific incident and disable it afterward; it addresses avoid permanent trace logs in normal automated runs, but this delivery instead requires correct provider-generated HCL rather than trusting every inferred argument and isolate provider-related diagnostic output during API troubleshooting. The required combination involves An import configuration review and TF_LOG_PROVIDER, not the behavior of Verbose logging only during diagnosis.

Question 274

A Terraform deployment has independent requirements: (1) create resources in a second region using the same provider type; (2) reproduce previously selected provider package versions on other machines. Which TWO mechanisms directly address these needs? Choose TWO.

  1. An aliased provider instance
  2. Provider configuration at the root
  3. The dependency lock file
  4. A provider mirror
  5. Explicit provider selection on data blocks
  6. A provider source address

Explanation

Correct Answers

A:

Declare an aliased provider configuration and assign provider = provider_name.alias on resources that need the alternate region; this meets the requirement to create resources in a second region using the same provider type, while the other selected techniques address reproduce previously selected provider package versions on other machines, which require their own distinct Terraform mechanisms.

C:

The .terraform.lock.hcl file records selected provider versions and checksums to constrain subsequent installations; this meets the requirement to reproduce previously selected provider package versions on other machines, while the other selected techniques address create resources in a second region using the same provider type, which require their own distinct Terraform mechanisms.

Incorrect Answers

B:

Reusable child modules should primarily declare provider requirements and receive configurations from callers rather than embedding fixed credentials; it addresses supply provider configurations from the root module to reusable child modules, but this delivery instead requires create resources in a second region using the same provider type and reproduce previously selected provider package versions on other machines. The required combination involves The dependency lock file and An aliased provider instance, not the behavior of Provider configuration at the root.

D:

A CLI provider_installation configuration can direct provider package discovery to a network or filesystem mirror; it addresses install approved plugins from an internal distribution location, but this delivery instead requires create resources in a second region using the same provider type and reproduce previously selected provider package versions on other machines. The required combination involves The dependency lock file and An aliased provider instance, not the behavior of A provider mirror.

E:

A data block can set provider = aws.secondary to query through an alternate provider configuration; it addresses read an object from a secondary account rather than the default account, but this delivery instead requires create resources in a second region using the same provider type and reproduce previously selected provider package versions on other machines. The required combination involves The dependency lock file and An aliased provider instance, not the behavior of Explicit provider selection on data blocks.

F:

The source address identifies a provider by registry hostname, namespace and type; local names alone are insufficient to distinguish publishers; it addresses distinguish a community plugin from the HashiCorp-maintained plugin with the same local name, but this delivery instead requires create resources in a second region using the same provider type and reproduce previously selected provider package versions on other machines. The required combination involves The dependency lock file and An aliased provider instance, not the behavior of A provider source address.

Question 275

A team proposes “terraform state list” to avoid exposing full state when another stack only needs a published identifier. If they proceed with that technique, which result should they anticipate instead?

  1. The state list command enumerates Terraform resource addresses without creating or deleting infrastructure.
  2. A normal plan attempts to refresh state from providers before comparing objects to the current configuration.
  3. Reading a remote state output still requires access to the underlying snapshot; exporting data through a narrower interface can reduce exposure.
  4. State maps Terraform instance addresses to remote object identifiers and remembered attributes for subsequent comparisons.

Explanation

Correct Answer

A:

terraform state list is used when an operator needs to inspect the addresses of instances currently tracked in state. Consequently, this choice cannot meet the separate requirement to avoid exposing full state when another stack only needs a published identifier. The intended action would instead require Remote state sharing boundaries.

Incorrect Answers

B:

This behavior belongs to Terraform refresh during planning, which helps engineers detect actual resource attributes rather than relying only on historical saved values rather than satisfying the separate requirement to avoid exposing full state when another stack only needs a published identifier. The attempted technique was terraform state list; it would instead be used to inspect the addresses of instances currently tracked in state, not to produce the effect associated with Terraform refresh during planning.

C:

That outcome belongs to Remote state sharing boundaries, the mechanism that can avoid exposing full state when another stack only needs a published identifier. The question concerns the engineer’s actual proposal, terraform state list; it is directed at inspect the addresses of instances currently tracked in state, not that result.

D:

This behavior belongs to State resource addresses, which helps engineers identify which remote object corresponds to a particular configuration resource rather than satisfying the separate requirement to avoid exposing full state when another stack only needs a published identifier. The attempted technique was terraform state list; it would instead be used to inspect the addresses of instances currently tracked in state, not to produce the effect associated with State resource addresses.

Question 276

A Terraform deployment has independent requirements: (1) keep spacing and indentation consistent between developers; (2) modify and re-plan after a change request is rejected. Which TWO mechanisms directly address these needs? Choose TWO.

  1. Review a plan before apply
  2. Formatting versus validation
  3. terraform fmt -diff
  4. Iterate after feedback
  5. terraform fmt
  6. Canonical HCL alignment

Explanation

Correct Answers

D:

A revised configuration must be planned again because a prior plan does not automatically incorporate later edits; this meets the requirement to modify and re-plan after a change request is rejected, while the other selected techniques address keep spacing and indentation consistent between developers, which require their own distinct Terraform mechanisms.

F:

The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls; this meets the requirement to keep spacing and indentation consistent between developers, while the other selected techniques address modify and re-plan after a change request is rejected, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

The plan stage compares desired configuration with observed resource state and shows the proposed operations for review; it addresses inspect predicted create, update and delete actions prior to making changes, but this delivery instead requires keep spacing and indentation consistent between developers and modify and re-plan after a change request is rejected. The required combination involves Iterate after feedback and Canonical HCL alignment, not the behavior of Review a plan before apply.

B:

terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; it addresses distinguish style-only issues from Terraform type and schema errors, but this delivery instead requires keep spacing and indentation consistent between developers and modify and re-plan after a change request is rejected. The required combination involves Iterate after feedback and Canonical HCL alignment, not the behavior of Formatting versus validation.

C:

The diff switch displays textual differences between current file formatting and the canonical formatting result; it addresses show which HCL formatting edits Terraform would make, but this delivery instead requires keep spacing and indentation consistent between developers and modify and re-plan after a change request is rejected. The required combination involves Iterate after feedback and Canonical HCL alignment, not the behavior of terraform fmt -diff.

E:

The fmt command rewrites HCL source according to Terraform's formatting conventions without provisioning resources; it addresses apply Terraform's canonical formatting to local .tf source files, but this delivery instead requires keep spacing and indentation consistent between developers and modify and re-plan after a change request is rejected. The required combination involves Iterate after feedback and Canonical HCL alignment, not the behavior of terraform fmt.

Question 277

A Terraform reviewer encounters “Data source postcondition” while assessing how to reject use of queried data when it violates a required invariant. Which statement correctly describes its actual behavior?

  1. Validation, precondition and postcondition definitions use error_message to tell the operator why a rule failed.
  2. Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion.
  3. A precondition inside lifecycle requires a true predicate before Terraform can continue the relevant resource operation.
  4. A postcondition on a data block can validate attributes returned from a provider before downstream resources rely on them.
  5. The validation block uses a condition and a custom error_message to enforce rules on caller-supplied values.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to reject use of queried data when it violates a required invariant, so it produces the behavior described. In contrast, resource precondition serves a different goal: fail a plan or apply when a prerequisite property is unacceptable, not reject use of queried data when it violates a required invariant.

Incorrect Answers

A:

The description applies to the error_message field when an engineer needs to present a meaningful explanation when a custom condition evaluates false; the named data source postcondition instead handles the requirement to reject use of queried data when it violates a required invariant, so this behavior does not describe Data source postcondition in the situation named.

B:

The description applies to an assert block inside check when an engineer needs to define a specific boolean statement for a nonblocking Terraform health check; the named data source postcondition instead handles the requirement to reject use of queried data when it violates a required invariant, so this behavior does not describe Data source postcondition in the situation named.

C:

The description applies to resource precondition when an engineer needs to fail a plan or apply when a prerequisite property is unacceptable; the named data source postcondition instead handles the requirement to reject use of queried data when it violates a required invariant, so this behavior does not describe Data source postcondition in the situation named.

E:

The description applies to input variable validation when an engineer needs to reject malformed module inputs before provisioning resources; the named data source postcondition instead handles the requirement to reject use of queried data when it violates a required invariant, so this behavior does not describe Data source postcondition in the situation named.

Question 278

A cloud engineering team using managed Terraform runs needs to isolate state and runs for two deployment environments. Which feature or operation is the most direct match?

  1. Distinct production and staging workspaces
  2. Project-scoped team access
  3. HCP Terraform organization separation
  4. An HCP Terraform project

Explanation

Correct Answer

A:

Each HCP Terraform workspace has its own state and run configuration so changes in one do not automatically update the other; this directly meets the requirement to isolate state and runs for two deployment environments. By comparison, an HCP Terraform project is intended to group related workspaces under one organizational and permissions boundary, which is a different task from isolate state and runs for two deployment environments.

Incorrect Answers

B:

Project-level access scopes workspace capabilities for teams based on organizational boundaries; this mechanism is useful when the job is to delegate administration of one team's project without granting universal organization access, whereas the current scenario requires the engineer to isolate state and runs for two deployment environments. These operations have different effects in the stated Terraform workflow.

C:

Organizations provide a broader boundary containing projects, workspaces, teams and policy configuration; this mechanism is useful when the job is to separate independent business units with different governance needs, whereas the current scenario requires the engineer to isolate state and runs for two deployment environments. These operations have different effects in the stated Terraform workflow.

D:

Projects organize workspaces by application, team or environment, simplifying scope and access administration; this mechanism is useful when the job is to group related workspaces under one organizational and permissions boundary, whereas the current scenario requires the engineer to isolate state and runs for two deployment environments. These operations have different effects in the stated Terraform workflow.

Question 279

An output block uses the value expression values({b=2, a=1}). Assuming only the literal data shown, which result should be expected?

  1. [2, 1]
  2. ["a", "b"]
  3. [1, 2]
  4. [1, 2, 3]

Explanation

Correct Answer

C:

The expression values({b=2, a=1}) evaluates to [1, 2] because values returns map values in the lexical ordering of keys a then b. This is Terraform's direct evaluation of the supplied literal arguments in values({b=2, a=1}), not an external provider lookup.

Incorrect Answers

A:

This follows insertion order rather than sorted key order. For values({b=2, a=1}), values returns map values in the lexical ordering of keys a then b; consequently this candidate is not the value Terraform computes.

B:

Those are the keys, not their associated values. In this specific evaluation, values returns map values in the lexical ordering of keys a then b, which rules out the proposed alternative.

D:

There are only two map entries and no third value. HCL evaluates values({b=2, a=1}) using the supplied arguments: values returns map values in the lexical ordering of keys a then b; the listed result is therefore incorrect.

Question 280

An engineer intends to store Terraform state in a file in the working directory by default and is reviewing “The default local backend”. What consequence follows from using it as intended?

  1. Without another backend, Terraform uses the local backend and writes its default workspace state to terraform.tfstate.
  2. The local backend supports a path argument for where the state file is stored on disk.
  3. Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination.
  4. Local files do not provide an organization-wide shared state or distributed locking comparable to an appropriately configured remote backend.
  5. Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to store Terraform state in a file in the working directory by default, so it produces the behavior described. In contrast, state file confidentiality serves a different goal: protect a workstation's local state file even when output values are hidden, not store Terraform state in a file in the working directory by default.

Incorrect Answers

B:

The description applies to a local backend path setting when an engineer needs to save the default workspace state to a nondefault local filename; the named the default local backend instead handles the requirement to store Terraform state in a file in the working directory by default, so this behavior does not describe The default local backend in the situation named.

C:

The description applies to state migration from local storage when an engineer needs to move an established project to remote state without abandoning resource identity; the named the default local backend instead handles the requirement to store Terraform state in a file in the working directory by default, so this behavior does not describe The default local backend in the situation named.

D:

The description applies to the local backend's lack of team collaboration features when an engineer needs to avoid concurrent writes from multiple operators on different machines; the named the default local backend instead handles the requirement to store Terraform state in a file in the working directory by default, so this behavior does not describe The default local backend in the situation named.

E:

The description applies to state file confidentiality when an engineer needs to protect a workstation's local state file even when output values are hidden; the named the default local backend instead handles the requirement to store Terraform state in a file in the working directory by default, so this behavior does not describe The default local backend in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests