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

Question 880

A team compares Terraform mechanisms for the goal to instantiate a fixed number of child module copies. Which stated consequence belongs specifically to “A module with count”?

  1. Reusable modules normally declare provider requirements while callers supply provider configurations and credentials.
  2. Parent configurations can pass one child module's outputs into another child's inputs to compose larger infrastructure systems.
  3. The count meta-argument creates numerically indexed module instances such as module.worker[0].
  4. An output-to-input reference establishes a natural dependency and avoids imposing broad depends_on edges unnecessarily.
  5. The module block's source points to child configuration and its other arguments supply input variables and relevant meta-arguments.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to instantiate a fixed number of child module copies, so it produces the behavior described. In contrast, a module call block serves a different goal: instantiate a reusable configuration unit under a distinct local name, not instantiate a fixed number of child module copies.

Incorrect Answers

A:

The description applies to avoiding hard-coded child credentials when an engineer needs to keep authentication and deployment-specific region choices outside a reusable child module; the named a module with count instead handles the requirement to instantiate a fixed number of child module copies, so this behavior does not describe A module with count in the situation named.

B:

The description applies to module composition when an engineer needs to combine small modules into a root configuration without producing one giant module; the named a module with count instead handles the requirement to instantiate a fixed number of child module copies, so this behavior does not describe A module with count in the situation named.

D:

The description applies to a module dependency interface when an engineer needs to connect two modules by declared output and input values; the named a module with count instead handles the requirement to instantiate a fixed number of child module copies, so this behavior does not describe A module with count in the situation named.

E:

The description applies to a module call block when an engineer needs to instantiate a reusable configuration unit under a distinct local name; the named a module with count instead handles the requirement to instantiate a fixed number of child module copies, so this behavior does not describe A module with count in the situation named.

Question 881

A Terraform reviewer encounters “terraform init after adding cloud integration” while assessing how to configure the local working directory to connect with the selected HCP workspace. Which statement correctly describes its actual behavior?

  1. The cloud hostname setting and login host identify the relevant service installation for organization operations.
  2. Running init processes the cloud block and configures workspace connectivity before plans or applies.
  3. The HCP service token controls platform API authentication and is distinct from provider credentials used to modify cloud infrastructure.
  4. Run tasks integrate external systems into workflow checkpoints without changing the Terraform resource graph directly.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to configure the local working directory to connect with the selected HCP workspace, so it produces the behavior described. In contrast, an API token for CLI connectivity serves a different goal: authorize a Terraform CLI workflow to access an HCP Terraform organization, not configure the local working directory to connect with the selected HCP workspace.

Incorrect Answers

A:

The description applies to Terraform Enterprise hostname selection when an engineer needs to connect the CLI to a privately deployed Terraform Enterprise service rather than app.terraform.io; the named terraform init after adding cloud integration instead handles the requirement to configure the local working directory to connect with the selected HCP workspace, so this behavior does not describe terraform init after adding cloud integration in the situation named.

C:

The description applies to an API token for CLI connectivity when an engineer needs to authorize a Terraform CLI workflow to access an HCP Terraform organization; the named terraform init after adding cloud integration instead handles the requirement to configure the local working directory to connect with the selected HCP workspace, so this behavior does not describe terraform init after adding cloud integration in the situation named.

D:

The description applies to HCP Terraform run tasks integration when an engineer needs to send proposed changes to a third-party quality or security check service; the named terraform init after adding cloud integration instead handles the requirement to configure the local working directory to connect with the selected HCP workspace, so this behavior does not describe terraform init after adding cloud integration in the situation named.

Question 882

A build job for a Terraform configuration needs to keep spacing and indentation consistent between developers. Which feature or operation is the most direct match?

  1. terraform fmt
  2. Formatting versus validation
  3. terraform fmt -diff
  4. Canonical HCL alignment

Explanation

Correct Answer

D:

The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls; this directly meets the requirement to keep spacing and indentation consistent between developers. By comparison, terraform fmt is intended to apply Terraform's canonical formatting to local .tf source files, which is a different task from keep spacing and indentation consistent between developers.

Incorrect Answers

A:

The fmt command rewrites HCL source according to Terraform's formatting conventions without provisioning resources; this mechanism is useful when the job is to apply Terraform's canonical formatting to local .tf source files, whereas the current scenario requires the engineer to keep spacing and indentation consistent between developers. These operations have different effects in the stated Terraform workflow.

B:

terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; this mechanism is useful when the job is to distinguish style-only issues from Terraform type and schema errors, whereas the current scenario requires the engineer to keep spacing and indentation consistent between developers. These operations have different effects in the stated Terraform workflow.

C:

The diff switch displays textual differences between current file formatting and the canonical formatting result; this mechanism is useful when the job is to show which HCL formatting edits Terraform would make, whereas the current scenario requires the engineer to keep spacing and indentation consistent between developers. These operations have different effects in the stated Terraform workflow.

Question 883

A Terraform change proposal names “Format before source review” to reduce whitespace-only churn in infrastructure pull requests. Which outcome can reviewers attribute to that particular mechanism?

  1. Applying formatter conventions consistently makes code review focus on meaningful resource and expression edits.
  2. The recursive switch extends formatting into subdirectories rather than limiting the operation to the current directory.
  3. Check mode verifies formatting and returns a failure when changes would be required instead of writing edited files.
  4. The fmt command rewrites HCL source according to Terraform's formatting conventions without provisioning resources.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to reduce whitespace-only churn in infrastructure pull requests, so it produces the behavior described. In contrast, terraform fmt -recursive serves a different goal: format Terraform files in nested directories under a module tree, not reduce whitespace-only churn in infrastructure pull requests.

Incorrect Answers

B:

The description applies to terraform fmt -recursive when an engineer needs to format Terraform files in nested directories under a module tree; the named format before source review instead handles the requirement to reduce whitespace-only churn in infrastructure pull requests, so this behavior does not describe Format before source review in the situation named.

C:

The description applies to terraform fmt -check when an engineer needs to make a CI formatting gate detect source files that need formatting; the named format before source review instead handles the requirement to reduce whitespace-only churn in infrastructure pull requests, so this behavior does not describe Format before source review in the situation named.

D:

The description applies to terraform fmt when an engineer needs to apply Terraform's canonical formatting to local .tf source files; the named format before source review instead handles the requirement to reduce whitespace-only churn in infrastructure pull requests, so this behavior does not describe Format before source review in the situation named.

Question 884

An organization integrating Terraform with source control requires a way to start downstream workspace runs after upstream workspace changes complete. Which Terraform approach most directly fulfills that request?

  1. Organization variable sets
  2. Drift detection in HCP Terraform
  3. HCP provider dynamic credentials
  4. Run triggers

Explanation

Correct Answer

D:

Run triggers coordinate dependent HCP Terraform workspaces through an event relationship without merging their states; this directly meets the requirement to start downstream workspace runs after upstream workspace changes complete. By comparison, HCP provider dynamic credentials is intended to replace standing cloud keys with short-lived run identities, which is a different task from start downstream workspace runs after upstream workspace changes complete.

Incorrect Answers

A:

Variable sets let administrators manage common workspace variables centrally and scope them to intended workspaces or projects; this mechanism is useful when the job is to supply shared environment or Terraform input values across several workspaces, whereas the current scenario requires the engineer to start downstream workspace runs after upstream workspace changes complete. These operations have different effects in the stated Terraform workflow.

B:

HCP Terraform health features can detect changes made outside the workspace's managed Terraform workflow; this mechanism is useful when the job is to identify remote infrastructure deviations through scheduled or managed health assessments, whereas the current scenario requires the engineer to start downstream workspace runs after upstream workspace changes complete. These operations have different effects in the stated Terraform workflow.

C:

HCP Terraform can use supported dynamic provider credentials that are generated for runs rather than stored as permanent workspace secrets; this mechanism is useful when the job is to replace standing cloud keys with short-lived run identities, whereas the current scenario requires the engineer to start downstream workspace runs after upstream workspace changes complete. These operations have different effects in the stated Terraform workflow.

Question 885

A Terraform reviewer encounters “Provider-mediated API operations” while assessing how to manage infrastructure services through a shared declarative workflow. Which statement correctly describes its actual behavior?

  1. Terraform Core evaluates configuration while provider plugins implement the provider-specific API operations.
  2. Infrastructure configuration can be committed and reviewed in version control so the intended change is traceable before a Terraform run.
  3. Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations.
  4. Terraform state records mappings and attributes needed to compare future plans without rediscovering every object's identity from scratch.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to manage infrastructure services through a shared declarative workflow, so it produces the behavior described. In contrast, state-backed object tracking serves a different goal: retain the association between a configuration address and its actual managed object, not manage infrastructure services through a shared declarative workflow.

Incorrect Answers

B:

This describes Version-controlled infrastructure definition and its job to review a proposed infrastructure change before team members deploy it, whereas the question asks about Provider-mediated API operations. The latter is the mechanism used to manage infrastructure services through a shared declarative workflow; the proposed effect belongs to a different Terraform feature.

C:

The description applies to a resource graph when an engineer needs to determine a safe sequence for creating objects with references between them; the named provider-mediated API operations instead handles the requirement to manage infrastructure services through a shared declarative workflow, so this behavior does not describe Provider-mediated API operations in the situation named.

D:

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 provider-mediated API operations instead handles the requirement to manage infrastructure services through a shared declarative workflow, so this behavior does not describe Provider-mediated API operations in the situation named.

Question 886

An infrastructure drift investigation requires a way to enforce read and write privileges on the state object. Which Terraform approach most directly fulfills that request?

  1. Remote state encryption at rest
  2. An HCP Terraform cloud block
  3. Init after changing state storage
  4. Remote backend access permissions

Explanation

Correct Answer

D:

Cloud storage policy and backend authorization decide who can obtain or mutate stored Terraform state; provider credentials alone are not sufficient; this directly meets the requirement to enforce read and write privileges on the state object. By comparison, remote state encryption at rest is intended to protect stored state contents from unauthorized storage-layer access, which is a different task from enforce read and write privileges on the state object.

Incorrect Answers

A:

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

B:

The terraform cloud block connects configuration to HCP Terraform, and cannot coexist with a standard backend block in the same configuration; this mechanism is useful when the job is to integrate Terraform CLI with an HCP organization and workspace, whereas the current scenario requires the engineer to enforce read and write privileges on the state object. These operations have different effects in the stated Terraform workflow.

C:

Terraform detects changed backend settings and requires initialization with an explicit migration or reconfiguration choice; this mechanism is useful when the job is to adopt a new remote state destination after editing configuration, whereas the current scenario requires the engineer to enforce read and write privileges on the state object. These operations have different effects in the stated Terraform workflow.

Question 887

A Terraform module author requires a way to remove repeated list values while keeping each value's first occurrence. Which Terraform approach most directly fulfills that request?

  1. The base64encode function
  2. The distinct function
  3. The cidrhost function
  4. The ternary conditional operator

Explanation

Correct Answer

B:

distinct returns a list with duplicates removed and retains the ordering of the first occurrence of each element; this directly meets the requirement to remove repeated list values while keeping each value's first occurrence. By comparison, the cidrhost function is intended to calculate an IP address at an offset within a CIDR range, which is a different task from remove repeated list values while keeping each value's first occurrence.

Incorrect Answers

A:

base64encode applies a reversible encoding and should not be mistaken for encryption of secrets; this mechanism is useful when the job is to turn ordinary string content into Base64 text, whereas the current scenario requires the engineer to remove repeated list values while keeping each value's first occurrence. These operations have different effects in the stated Terraform workflow.

C:

cidrhost computes a host address inside the given prefix from a numeric host index; this mechanism is useful when the job is to calculate an IP address at an offset within a CIDR range, whereas the current scenario requires the engineer to remove repeated list values while keeping each value's first occurrence. These operations have different effects in the stated Terraform workflow.

D:

The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks; this mechanism is useful when the job is to set a resource argument according to a boolean expression, whereas the current scenario requires the engineer to remove repeated list values while keeping each value's first occurrence. These operations have different effects in the stated Terraform workflow.

Question 888

An output block uses the value expression replace("web-dev", "dev", "prod"). Assuming only the literal data shown, which result should be expected?

  1. "prod-web"
  2. "web-prod" (single hyphen)
  3. "web--prod" (double hyphen)
  4. "web-dev"

Explanation

Correct Answer

B:

The expression replace("web-dev", "dev", "prod") evaluates to "web-prod" because replace substitutes the matching dev substring with prod and retains the web prefix. This is Terraform's direct evaluation of the supplied literal arguments in replace("web-dev", "dev", "prod"), not an external provider lookup.

Incorrect Answers

A:

Replace performs a substitution; it does not reverse token order. In this specific evaluation, replace substitutes the matching dev substring with prod and retains the web prefix, which rules out the proposed alternative.

C:

No extra hyphen is inserted beyond the original one. HCL evaluates replace("web-dev", "dev", "prod") using the supplied arguments: replace substitutes the matching dev substring with prod and retains the web prefix; the listed result is therefore incorrect.

D:

The matching substring is changed by replace. For replace("web-dev", "dev", "prod"), replace substitutes the matching dev substring with prod and retains the web prefix; consequently this candidate is not the value Terraform computes.

Question 889

A Terraform change proposal names “A compatible provider constraint” to accept patch updates within a chosen minor line. Which outcome can reviewers attribute to that particular mechanism?

  1. Initialization resolves provider requirements, installs plugins, and prepares modules and backend settings in the working directory.
  2. The pessimistic constraint ~> 5.3.0 admits versions at least 5.3.0 but below 5.4.0.
  3. The providers lock subcommand updates dependency lock information, including hashes for specified target operating-system platforms.
  4. A CLI provider_installation configuration can direct provider package discovery to a network or filesystem mirror.
  5. The -upgrade switch permits newer versions that satisfy constraints instead of preserving current installed or locked selections.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to accept patch updates within a chosen minor line, so it produces the behavior described. In contrast, terraform providers lock serves a different goal: populate provider package checksums for selected platforms, not accept patch updates within a chosen minor line.

Incorrect Answers

A:

The description applies to terraform init when an engineer needs to download missing required provider plugins before planning; the named a compatible provider constraint instead handles the requirement to accept patch updates within a chosen minor line, so this behavior does not describe A compatible provider constraint in the situation named.

C:

The description applies to terraform providers lock when an engineer needs to populate provider package checksums for selected platforms; the named a compatible provider constraint instead handles the requirement to accept patch updates within a chosen minor line, so this behavior does not describe A compatible provider constraint in the situation named.

D:

The description applies to a provider mirror when an engineer needs to install approved plugins from an internal distribution location; the named a compatible provider constraint instead handles the requirement to accept patch updates within a chosen minor line, so this behavior does not describe A compatible provider constraint in the situation named.

E:

The description applies to terraform init -upgrade when an engineer needs to intentionally reconsider previously locked provider and module selections; the named a compatible provider constraint instead handles the requirement to accept patch updates within a chosen minor line, so this behavior does not describe A compatible provider constraint in the situation named.

Question 890

A team compares Terraform mechanisms for the goal to reject an input value that violates an explicit business rule. Which stated consequence belongs specifically to “A variable validation block”?

  1. Validation uses a condition expression and error_message to provide a tailored error when the supplied input is unacceptable.
  2. Command-line -var assignments take high precedence and are useful for an explicit run-specific override.
  3. Marking an output sensitive redacts ordinary CLI presentation, but does not by itself prevent storage in state.
  4. Terraform automatically discovers terraform.tfvars and terraform.tfvars.json in the working directory.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to reject an input value that violates an explicit business rule, so it produces the behavior described. In contrast, the -var option serves a different goal: supply a single variable assignment when invoking plan or apply, not reject an input value that violates an explicit business rule.

Incorrect Answers

B:

The description applies to the -var option when an engineer needs to supply a single variable assignment when invoking plan or apply; the named a variable validation block instead handles the requirement to reject an input value that violates an explicit business rule, so this behavior does not describe A variable validation block in the situation named.

C:

The description applies to a sensitive output when an engineer needs to hide a secret-like output from Terraform's usual human-readable display; the named a variable validation block instead handles the requirement to reject an input value that violates an explicit business rule, so this behavior does not describe A variable validation block in the situation named.

D:

The description applies to a terraform.tfvars file when an engineer needs to load a conventional set of root-module variable assignments automatically; the named a variable validation block instead handles the requirement to reject an input value that violates an explicit business rule, so this behavior does not describe A variable validation block in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests