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

Question 250

A team compares Terraform mechanisms for the goal to catch a resource block lacking a mandatory argument. Which stated consequence belongs specifically to “Missing required argument detection”?

  1. Variable validation conditions evaluate against actual values when Terraform processes inputs, which is different from only checking syntax.
  2. Validation compares configuration with provider schemas and reports missing required fields.
  3. The validate command checks syntax and schema consistency in an initialized configuration without obtaining a full execution plan.
  4. Because validate consults provider and module definitions, run init first to install referenced dependencies.
  5. terraform validate runs offline-oriented configuration checks and does not deploy managed resources.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to catch a resource block lacking a mandatory argument, so it produces the behavior described. In contrast, validate after init serves a different goal: resolve missing provider schemas before checking configuration, not catch a resource block lacking a mandatory argument.

Incorrect Answers

A:

The description applies to variable validation during planning when an engineer needs to reject a supplied input value that violates a custom validation rule; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

C:

The description applies to terraform validate when an engineer needs to check that Terraform configuration is structurally valid without planning resource changes; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

D:

The description applies to validate after init when an engineer needs to resolve missing provider schemas before checking configuration; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

E:

The description applies to validate without live deployment when an engineer needs to detect invalid configuration even when no cloud changes should occur; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

Question 251

The team evaluates “terraform show -json” for a requirement to read plan or state information in a structured representation. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. State rm deletes the state association, not the object in the external system.
  2. Replace-provider rewrites provider source references in state and creates a backup before the edit.
  3. State pull reads the current snapshot to standard output, including potentially sensitive provider attributes.
  4. The JSON representation supports automated inspection but must be protected because redacted display is not a security boundary.
  5. Workspace list shows logical Terraform workspaces, which may correspond to separate state instances depending on backend support.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to read plan or state information in a structured representation, so it produces the behavior described. In contrast, terraform workspace list serves a different goal: list the workspaces available through the initialized backend, not read plan or state information in a structured representation.

Incorrect Answers

A:

The description applies to terraform state rm when an engineer needs to stop tracking a resource without telling its provider to delete the remote object; the named terraform show -json instead handles the requirement to read plan or state information in a structured representation, so this behavior does not describe terraform show -json in the situation named.

B:

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

C:

The description applies to terraform state pull when an engineer needs to export a state snapshot from the configured backend for careful examination; the named terraform show -json instead handles the requirement to read plan or state information in a structured representation, so this behavior does not describe terraform show -json in the situation named.

E:

The description applies to terraform workspace list when an engineer needs to list the workspaces available through the initialized backend; the named terraform show -json instead handles the requirement to read plan or state information in a structured representation, so this behavior does not describe terraform show -json in the situation named.

Question 252

The team evaluates “Output dependency metadata” for a requirement to delay the visibility of an output until additional required operations finish. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. The depends_on meta-argument adds dependency edges for a known relationship that Terraform cannot otherwise infer.
  2. An output block can use depends_on for dependencies that are not evident from its value expression.
  3. In a for_each resource block, each.key identifies the current map key or set element for that instance.
  4. Resources using count can refer to the current instance number through count.index, a zero-based integer.
  5. Count instances have numeric indexes such as aws_instance.web[1] for the second instance.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to delay the visibility of an output until additional required operations finish, so it produces the behavior described. In contrast, each.key serves a different goal: refer to the stable key of a for_each resource instance, not delay the visibility of an output until additional required operations finish.

Incorrect Answers

A:

The description applies to explicit depends_on when an engineer needs to order resources when there is a dependency not expressed by attribute references; the named output dependency metadata instead handles the requirement to delay the visibility of an output until additional required operations finish, so this behavior does not describe Output dependency metadata in the situation named.

C:

The description applies to each.key when an engineer needs to refer to the stable key of a for_each resource instance; the named output dependency metadata instead handles the requirement to delay the visibility of an output until additional required operations finish, so this behavior does not describe Output dependency metadata in the situation named.

D:

The description applies to count.index when an engineer needs to build a numbered name for each instance created using count; the named output dependency metadata instead handles the requirement to delay the visibility of an output until additional required operations finish, so this behavior does not describe Output dependency metadata in the situation named.

E:

The description applies to an instance address with count when an engineer needs to refer specifically to the second object of a count-created resource; the named output dependency metadata instead handles the requirement to delay the visibility of an output until additional required operations finish, so this behavior does not describe Output dependency metadata in the situation named.

Question 253

A change request asks an engineer to avoid hard-coding a provider's API credential into .tf files. Which choice best implements the requested behavior?

  1. Implicit provider selection
  2. Provider version compatibility
  3. Provider authentication environment variables
  4. Provider-defined data sources

Explanation

Correct Answer

C:

Many provider plugins can read credentials from provider-specific environment variables or identity mechanisms, reducing secret exposure in configuration; this directly meets the requirement to avoid hard-coding a provider's API credential into .tf files. By comparison, implicit provider selection is intended to use the default provider configuration for a resource type, which is a different task from avoid hard-coding a provider's API credential into .tf files.

Incorrect Answers

A:

Terraform generally selects the default provider matching a resource's type prefix unless an alternate configuration is specified; this mechanism is useful when the job is to use the default provider configuration for a resource type, whereas the current scenario requires the engineer to avoid hard-coding a provider's API credential into .tf files. These operations have different effects in the stated Terraform workflow.

B:

Version constraints and a shared lock file reduce unintended schema and behavior changes between deployments; this mechanism is useful when the job is to prevent incompatible provider upgrades from affecting resource handling, whereas the current scenario requires the engineer to avoid hard-coding a provider's API credential into .tf files. These operations have different effects in the stated Terraform workflow.

D:

A provider's data source reads existing data and exposes attributes without creating or destroying the queried object; this mechanism is useful when the job is to read information from an external service without owning its lifecycle, whereas the current scenario requires the engineer to avoid hard-coding a provider's API credential into .tf files. These operations have different effects in the stated Terraform workflow.

Question 254

A team consuming shared Terraform modules requires a way to consider newer published module releases already allowed by a version constraint. Which Terraform approach most directly fulfills that request?

  1. A strict registry module pin
  2. A Git tag pin for a module
  3. Init -upgrade for registry modules
  4. Reviewing module upgrade changes

Explanation

Correct Answer

C:

The upgrade mode reselects module versions subject to constraints instead of automatically keeping the previously installed copy; this directly meets the requirement to consider newer published module releases already allowed by a version constraint. By comparison, a Git tag pin for a module is intended to select a specific VCS module release without using a registry version argument, which is a different task from consider newer published module releases already allowed by a version constraint.

Incorrect Answers

A:

A module version constraint such as = 2.1.3 selects only that published version until the requirement changes; this mechanism is useful when the job is to reproduce a vetted module release without automatically selecting a newer one, whereas the current scenario requires the engineer to consider newer published module releases already allowed by a version constraint. These operations have different effects in the stated Terraform workflow.

B:

A Git module's ?ref= tag or commit selects a repository revision instead of a registry module version constraint; this mechanism is useful when the job is to select a specific VCS module release without using a registry version argument, whereas the current scenario requires the engineer to consider newer published module releases already allowed by a version constraint. These operations have different effects in the stated Terraform workflow.

D:

A module upgrade can change resource definitions and outputs, so the consumer should inspect the new source and resulting Terraform plan; this mechanism is useful when the job is to control behavioral changes after moving to a new module release, whereas the current scenario requires the engineer to consider newer published module releases already allowed by a version constraint. These operations have different effects in the stated Terraform workflow.

Question 255

An engineer intends to represent managed infrastructure using Terraform's native declarative language and is reviewing “HCL configuration files”. What consequence follows from using it as intended?

  1. Terraform reads .tf files written in HCL, including blocks, arguments, expressions and references that describe the intended objects.
  2. Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations.
  3. Terraform state records mappings and attributes needed to compare future plans without rediscovering every object's identity from scratch.
  4. IaC configuration provides repeatable definitions; variables and isolated state allow environments to differ without independently hand-building each object.
  5. Infrastructure configuration can be committed and reviewed in version control so the intended change is traceable before a Terraform run.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to represent managed infrastructure using Terraform's native declarative language, so it produces the behavior described. In contrast, repeatable environment definition serves a different goal: recreate the same logical infrastructure design across test and production, not represent managed infrastructure using Terraform's native declarative language.

Incorrect Answers

B:

This describes A resource graph and its job to determine a safe sequence for creating objects with references between them, whereas the question asks about HCL configuration files. The latter is the mechanism used to represent managed infrastructure using Terraform's native declarative language; the proposed effect belongs to a different Terraform feature.

C:

The description applies to state-backed object tracking when an engineer needs to retain the association between a configuration address and its actual managed object; the named HCL configuration files instead handles the requirement to represent managed infrastructure using Terraform's native declarative language, so this behavior does not describe HCL configuration files in the situation named.

D:

The description applies to repeatable environment definition when an engineer needs to recreate the same logical infrastructure design across test and production; the named HCL configuration files instead handles the requirement to represent managed infrastructure using Terraform's native declarative language, so this behavior does not describe HCL configuration files in the situation named.

E:

The description applies to version-controlled infrastructure definition when an engineer needs to review a proposed infrastructure change before team members deploy it; the named HCL configuration files instead handles the requirement to represent managed infrastructure using Terraform's native declarative language, so this behavior does not describe HCL configuration files in the situation named.

Question 256

An operations runbook for tracked objects needs to update the provider source address recorded for affected state resources. Which feature or operation is the most direct match?

  1. terraform state replace-provider
  2. terraform workspace list
  3. terraform output
  4. terraform show -json

Explanation

Correct Answer

A:

Replace-provider rewrites provider source references in state and creates a backup before the edit; this directly meets the requirement to update the provider source address recorded for affected state resources. By comparison, terraform show -json is intended to read plan or state information in a structured representation, which is a different task from update the provider source address recorded for affected state resources.

Incorrect Answers

B:

Workspace list shows logical Terraform workspaces, which may correspond to separate state instances depending on backend support; this mechanism is useful when the job is to list the workspaces available through the initialized backend, whereas the current scenario requires the engineer to update the provider source address recorded for affected state resources. These operations have different effects in the stated Terraform workflow.

C:

The output command reports root output values rather than listing every raw attribute from state; this mechanism is useful when the job is to read values explicitly declared as root outputs of the configuration, whereas the current scenario requires the engineer to update the provider source address recorded for affected state resources. These operations have different effects in the stated Terraform workflow.

D:

The JSON representation supports automated inspection but must be protected because redacted display is not a security boundary; this mechanism is useful when the job is to read plan or state information in a structured representation, whereas the current scenario requires the engineer to update the provider source address recorded for affected state resources. These operations have different effects in the stated Terraform workflow.

Question 257

An engineer intends to identify Terraform's default local state artifact and is reviewing “The terraform.tfstate file”. What consequence follows from using it as intended?

  1. A temporary runner may lose its filesystem after a job, so durable shared state is usually needed for repeatable team automation.
  2. Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state.
  3. When local workspaces are used, nondefault state snapshots are placed under a terraform.tfstate.d directory structure.
  4. The default workspace's local state is kept as terraform.tfstate; this file may contain sensitive infrastructure details.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to identify Terraform's default local state artifact, so it produces the behavior described. In contrast, a local state backup file serves a different goal: recover from a state change without relying solely on an unversioned primary file, not identify Terraform's default local state artifact.

Incorrect Answers

A:

The description applies to local state in CI when an engineer needs to recognize why ephemeral build agents should not rely on a machine-local state file; the named the terraform.tfstate file instead handles the requirement to identify Terraform's default local state artifact, so this behavior does not describe The terraform.tfstate file in the situation named.

B:

The description applies to a local state backup file when an engineer needs to recover from a state change without relying solely on an unversioned primary file; the named the terraform.tfstate file instead handles the requirement to identify Terraform's default local state artifact, so this behavior does not describe The terraform.tfstate file in the situation named.

C:

The description applies to local workspace state directories when an engineer needs to identify how the local backend stores nondefault workspaces; the named the terraform.tfstate file instead handles the requirement to identify Terraform's default local state artifact, so this behavior does not describe The terraform.tfstate file in the situation named.

Question 258

During an infrastructure design review about how to read information from an external service without owning its lifecycle, a maintainer asks what “Provider-defined data sources” does. Which description is accurate?

  1. A provider block can configure an endpoint, region or authentication parameters but should not carry the provider's version constraint.
  2. Terraform checks downloaded provider package checksums against lock information where hashes are available.
  3. A provider's data source reads existing data and exposes attributes without creating or destroying the queried object.
  4. The namespace portion of a source address separates provider publishers in the registry.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to read information from an external service without owning its lifecycle, so it produces the behavior described. In contrast, the provider registry namespace serves a different goal: identify the publisher when providers share a type name, not read information from an external service without owning its lifecycle.

Incorrect Answers

A:

The description applies to the provider block when an engineer needs to configure API connection settings for an already required provider; the named provider-defined data sources instead handles the requirement to read information from an external service without owning its lifecycle, so this behavior does not describe Provider-defined data sources in the situation named.

B:

The description applies to provider integrity hashes when an engineer needs to detect a mismatched plugin distribution package; the named provider-defined data sources instead handles the requirement to read information from an external service without owning its lifecycle, so this behavior does not describe Provider-defined data sources in the situation named.

D:

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-defined data sources instead handles the requirement to read information from an external service without owning its lifecycle, so this behavior does not describe Provider-defined data sources in the situation named.

Question 259

A declarative resource and expression design has a concrete implementation goal: extract a primitive output without the surrounding formatted representation. What is the most appropriate Terraform mechanism?

  1. The variable type argument
  2. The -var option
  3. terraform output -raw
  4. An environment variable prefixed TF_VAR_

Explanation

Correct Answer

C:

The -raw output mode prints a single string, number or boolean value in a script-friendly form and may reveal sensitive data; this directly meets the requirement to extract a primitive output without the surrounding formatted representation. By comparison, the -var option is intended to supply a single variable assignment when invoking plan or apply, which is a different task from extract a primitive output without the surrounding formatted representation.

Incorrect Answers

A:

A variable's type constraint enforces the intended structure and allows appropriate Terraform type conversions; this mechanism is useful when the job is to reject caller values that cannot satisfy the declared input type, whereas the current scenario requires the engineer to extract a primitive output without the surrounding formatted representation. These operations have different effects in the stated Terraform workflow.

B:

Command-line -var assignments take high precedence and are useful for an explicit run-specific override; this mechanism is useful when the job is to supply a single variable assignment when invoking plan or apply, whereas the current scenario requires the engineer to extract a primitive output without the surrounding formatted representation. These operations have different effects in the stated Terraform workflow.

D:

Terraform reads variables named TF_VAR_name as a source of input assignments, subject to input precedence rules; this mechanism is useful when the job is to provide root-module input values from an automated execution environment, whereas the current scenario requires the engineer to extract a primitive output without the surrounding formatted representation. These operations have different effects in the stated Terraform workflow.

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.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests