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

Question 440

A runbook lists “Repeatable initialization” for the task to run initialization again in an already prepared directory without unnecessary changes. Which technical effect should its description include?

  1. A modified provider requirement can trigger a need to rerun init to resolve the newly declared plugin dependency.
  2. The migrate-state flag attempts to copy prior state into the new backend and can prompt for migration confirmation.
  3. terraform init is designed to be safely rerun; when requirements are unchanged, it generally keeps existing setup.
  4. Initialization installs required providers and modules and establishes the working directory's backend configuration.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to run initialization again in an already prepared directory without unnecessary changes, so it produces the behavior described. In contrast, terraform init -migrate-state serves a different goal: move existing state to a newly configured backend, not run initialization again in an already prepared directory without unnecessary changes.

Incorrect Answers

A:

The description applies to provider source change reinitialization when an engineer needs to respond after changing the source address of a required provider; the named repeatable initialization instead handles the requirement to run initialization again in an already prepared directory without unnecessary changes, so this behavior does not describe Repeatable initialization in the situation named.

B:

The description applies to terraform init -migrate-state when an engineer needs to move existing state to a newly configured backend; the named repeatable initialization instead handles the requirement to run initialization again in an already prepared directory without unnecessary changes, so this behavior does not describe Repeatable initialization in the situation named.

D:

The description applies to terraform init for a new directory when an engineer needs to prepare a folder containing fresh .tf configuration files; the named repeatable initialization instead handles the requirement to run initialization again in an already prepared directory without unnecessary changes, so this behavior does not describe Repeatable initialization in the situation named.

Question 441

A Terraform reviewer encounters “A relative local module source” while assessing how to reuse a neighboring module directory in the same repository. Which statement correctly describes its actual behavior?

  1. Registry module sources use the namespace/name/provider address form and can support a separate version argument.
  2. A module source such as ./modules/network points to a local directory and requires no registry download or semantic version selection.
  3. The terraform get command updates downloaded module sources only; routine workflows generally prefer terraform init.
  4. Terraform can load a module from a local filesystem path, though absolute paths make configurations less portable.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to reuse a neighboring module directory in the same repository, so it produces the behavior described. In contrast, terraform get serves a different goal: retrieve child modules without running the complete backend and provider setup steps, not reuse a neighboring module directory in the same repository.

Incorrect Answers

A:

The description applies to a public registry module source when an engineer needs to download a community module published with an official registry address; the named a relative local module source instead handles the requirement to reuse a neighboring module directory in the same repository, so this behavior does not describe A relative local module source in the situation named.

C:

The description applies to terraform get when an engineer needs to retrieve child modules without running the complete backend and provider setup steps; the named a relative local module source instead handles the requirement to reuse a neighboring module directory in the same repository, so this behavior does not describe A relative local module source in the situation named.

D:

The description applies to an absolute local module source when an engineer needs to call a child module from an explicit filesystem path; the named a relative local module source instead handles the requirement to reuse a neighboring module directory in the same repository, so this behavior does not describe A relative local module source in the situation named.

Question 442

A Terraform change proposal names “The format function” to build formatted text using placeholders for typed values. Which outcome can reviewers attribute to that particular mechanism?

  1. concat joins lists end to end and preserves their element ordering, including duplicate values.
  2. format interpolates arguments into a printf-style string template for predictable names or identifiers.
  3. A for expression builds derived collection values, optionally filtering with an if clause and transforming keys or values.
  4. lower converts letters to lowercase and is often used in consistent name expressions.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to build formatted text using placeholders for typed values, so it produces the behavior described. In contrast, the lower function serves a different goal: normalize a string identifier to lowercase, not build formatted text using placeholders for typed values.

Incorrect Answers

A:

The description applies to the concat function when an engineer needs to append the elements of multiple lists into one sequence; the named the format function instead handles the requirement to build formatted text using placeholders for typed values, so this behavior does not describe The format function in the situation named.

C:

The description applies to the for expression when an engineer needs to transform a collection's elements into a new list or map; the named the format function instead handles the requirement to build formatted text using placeholders for typed values, so this behavior does not describe The format function in the situation named.

D:

The description applies to the lower function when an engineer needs to normalize a string identifier to lowercase; the named the format function instead handles the requirement to build formatted text using placeholders for typed values, so this behavior does not describe The format function in the situation named.

Question 443

A Terraform change proposal names “The can function” to test whether evaluating an expression would cause a dynamic error. Which outcome can reviewers attribute to that particular mechanism?

  1. replace searches a string for a matching substring or pattern and replaces matches with a new string.
  2. base64encode applies a reversible encoding and should not be mistaken for encryption of secrets.
  3. A for expression builds derived collection values, optionally filtering with an if clause and transforming keys or values.
  4. upper transforms the letters of a string into uppercase without changing its underlying Terraform type.
  5. can(expression) returns false when evaluation raises an error, which is useful in validation but not for general error swallowing.
  6. cidrhost computes a host address inside the given prefix from a numeric host index.

Explanation

Correct Answer

E:

The named mechanism is used when the objective is to test whether evaluating an expression would cause a dynamic error, so it produces the behavior described. In contrast, the cidrhost function serves a different goal: calculate an IP address at an offset within a CIDR range, not test whether evaluating an expression would cause a dynamic error.

Incorrect Answers

A:

The description applies to the replace function when an engineer needs to substitute matching substrings within a value; the named the can function instead handles the requirement to test whether evaluating an expression would cause a dynamic error, so this behavior does not describe The can function in the situation named.

B:

The description applies to the base64encode function when an engineer needs to turn ordinary string content into Base64 text; the named the can function instead handles the requirement to test whether evaluating an expression would cause a dynamic error, so this behavior does not describe The can function in the situation named.

C:

The description applies to the for expression when an engineer needs to transform a collection's elements into a new list or map; the named the can function instead handles the requirement to test whether evaluating an expression would cause a dynamic error, so this behavior does not describe The can function in the situation named.

D:

The description applies to the upper function when an engineer needs to convert an environment label to uppercase; the named the can function instead handles the requirement to test whether evaluating an expression would cause a dynamic error, so this behavior does not describe The can function in the situation named.

F:

The description applies to the cidrhost function when an engineer needs to calculate an IP address at an offset within a CIDR range; the named the can function instead handles the requirement to test whether evaluating an expression would cause a dynamic error, so this behavior does not describe The can function in the situation named.

Question 444

During a design review, the requirement is to fetch newer module releases permitted by version constraints. Which option should the engineer select?

  1. The .terraform.lock.hcl file
  2. The .terraform directory
  3. terraform init for a new directory
  4. Repeatable initialization
  5. terraform init -upgrade for modules

Explanation

Correct Answer

E:

Upgrade tells init to reconsider prior module selections instead of simply reusing previously installed versions; this directly meets the requirement to fetch newer module releases permitted by version constraints. By comparison, terraform init for a new directory is intended to prepare a folder containing fresh .tf configuration files, which is a different task from fetch newer module releases permitted by version constraints.

Incorrect Answers

A:

Terraform records provider version and checksum selections in its dependency lock file, which teams normally commit to source control; this mechanism is useful when the job is to identify which file should be checked in to preserve selected provider packages, whereas the current scenario requires the engineer to fetch newer module releases permitted by version constraints. These operations have different effects in the stated Terraform workflow.

B:

Terraform creates .terraform for module caches, provider installations and backend/workspace metadata; it is not a substitute for committed configuration; this mechanism is useful when the job is to identify where a working directory keeps installed modules and initialization metadata, whereas the current scenario requires the engineer to fetch newer module releases permitted by version constraints. These operations have different effects in the stated Terraform workflow.

C:

Initialization installs required providers and modules and establishes the working directory's backend configuration; this mechanism is useful when the job is to prepare a folder containing fresh .tf configuration files, whereas the current scenario requires the engineer to fetch newer module releases permitted by version constraints. These operations have different effects in the stated Terraform workflow.

D:

terraform init is designed to be safely rerun; when requirements are unchanged, it generally keeps existing setup; this mechanism is useful when the job is to run initialization again in an already prepared directory without unnecessary changes, whereas the current scenario requires the engineer to fetch newer module releases permitted by version constraints. These operations have different effects in the stated Terraform workflow.

Question 445

A release pipeline preparing provider access needs to allow provider releases no older than a tested minimum. Which feature or operation is the most direct match?

  1. A lower-bound provider constraint
  2. terraform providers lock
  3. terraform init -upgrade
  4. The required_providers block

Explanation

Correct Answer

A:

A version requirement such as >= 5.0.0 allows matching later versions but does not cap major-version upgrades; this directly meets the requirement to allow provider releases no older than a tested minimum. By comparison, the required_providers block is intended to declare where a provider plugin comes from and which versions are acceptable, which is a different task from allow provider releases no older than a tested minimum.

Incorrect Answers

B:

The providers lock subcommand updates dependency lock information, including hashes for specified target operating-system platforms; this mechanism is useful when the job is to populate provider package checksums for selected platforms, whereas the current scenario requires the engineer to allow provider releases no older than a tested minimum. These operations have different effects in the stated Terraform workflow.

C:

The -upgrade switch permits newer versions that satisfy constraints instead of preserving current installed or locked selections; this mechanism is useful when the job is to intentionally reconsider previously locked provider and module selections, whereas the current scenario requires the engineer to allow provider releases no older than a tested minimum. These operations have different effects in the stated Terraform workflow.

D:

A required_providers entry maps a local provider name to its source address and version constraint; it does not configure API credentials; this mechanism is useful when the job is to declare where a provider plugin comes from and which versions are acceptable, whereas the current scenario requires the engineer to allow provider releases no older than a tested minimum. These operations have different effects in the stated Terraform workflow.

Question 446

A change request asks an engineer to avoid concurrent writes from multiple operators on different machines. Which choice best implements the requested behavior?

  1. A local backend path setting
  2. The local backend's lack of team collaboration features
  3. State file confidentiality
  4. Local state in CI

Explanation

Correct Answer

B:

Local files do not provide an organization-wide shared state or distributed locking comparable to an appropriately configured remote backend; this directly meets the requirement to avoid concurrent writes from multiple operators on different machines. By comparison, a local backend path setting is intended to save the default workspace state to a nondefault local filename, which is a different task from avoid concurrent writes from multiple operators on different machines.

Incorrect Answers

A:

The local backend supports a path argument for where the state file is stored on disk; this mechanism is useful when the job is to save the default workspace state to a nondefault local filename, whereas the current scenario requires the engineer to avoid concurrent writes from multiple operators on different machines. These operations have different effects in the stated Terraform workflow.

C:

Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter; this mechanism is useful when the job is to protect a workstation's local state file even when output values are hidden, whereas the current scenario requires the engineer to avoid concurrent writes from multiple operators on different machines. These operations have different effects in the stated Terraform workflow.

D:

A temporary runner may lose its filesystem after a job, so durable shared state is usually needed for repeatable team automation; this mechanism is useful when the job is to recognize why ephemeral build agents should not rely on a machine-local state file, whereas the current scenario requires the engineer to avoid concurrent writes from multiple operators on different machines. These operations have different effects in the stated Terraform workflow.

Question 447

An engineering checklist calls for separate outcomes: (1) use a reviewed configuration revision across separate testing and production states; (2) evaluate a pull request's proposed changes without immediately applying them. Which TWO options implement the requested outcomes? Choose TWO.

  1. A run apply phase
  2. Workspace-specific variables
  3. Project membership changes
  4. A speculative HCP plan
  5. Environment promotion via workspaces
  6. Workspace outputs

Explanation

Correct Answers

D:

HCP Terraform can perform speculative plans for VCS changes to preview impact before merge or approval; this meets the requirement to evaluate a pull request's proposed changes without immediately applying them, while the other selected techniques address use a reviewed configuration revision across separate testing and production states, which require their own distinct Terraform mechanisms.

E:

Workspaces can reference separate branches or release controls while retaining isolated state for each environment; this meets the requirement to use a reviewed configuration revision across separate testing and production states, while the other selected techniques address evaluate a pull request's proposed changes without immediately applying them, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

HCP Terraform can run the apply stage after its configured approval, policy and workflow requirements are satisfied; it addresses execute approved resource changes within an HCP Terraform workspace, but this delivery instead requires use a reviewed configuration revision across separate testing and production states and evaluate a pull request's proposed changes without immediately applying them. The required combination involves A speculative HCP plan and Environment promotion via workspaces, not the behavior of A run apply phase.

B:

Workspace settings store variables for that workspace's execution; global sets should not replace environment-specific data blindly; it addresses override or tailor values used by one particular stack, but this delivery instead requires use a reviewed configuration revision across separate testing and production states and evaluate a pull request's proposed changes without immediately applying them. The required combination involves A speculative HCP plan and Environment promotion via workspaces, not the behavior of Workspace-specific variables.

C:

A project is a grouping and access construct; changing project assignment does not turn two workspaces into one state; it addresses move a workspace to a different organizational group without merging infrastructure state, but this delivery instead requires use a reviewed configuration revision across separate testing and production states and evaluate a pull request's proposed changes without immediately applying them. The required combination involves A speculative HCP plan and Environment promotion via workspaces, not the behavior of Project membership changes.

F:

Workspace output values come from root module output blocks and can be consumed through supported interfaces; it addresses publish selected values produced by an HCP Terraform run, but this delivery instead requires use a reviewed configuration revision across separate testing and production states and evaluate a pull request's proposed changes without immediately applying them. The required combination involves A speculative HCP plan and Environment promotion via workspaces, not the behavior of Workspace outputs.

Question 448

An engineer preparing an infrastructure rollout requires a way to avoid applying from stale remembered attributes after remote drift. Which Terraform approach most directly fulfills that request?

  1. terraform apply -auto-approve
  2. terraform apply -parallelism
  3. Noninteractive apply settings
  4. Refresh during apply planning
  5. Parallel graph execution

Explanation

Correct Answer

D:

For a normal fresh apply, Terraform plans with current provider observations unless refresh is explicitly disabled; saved plan behavior differs; this directly meets the requirement to avoid applying from stale remembered attributes after remote drift. By comparison, terraform apply -parallelism is intended to limit how many graph operations execute concurrently, which is a different task from avoid applying from stale remembered attributes after remote drift.

Incorrect Answers

A:

The auto-approve option allows the automatically created plan to proceed without interactive confirmation, so pipeline safeguards matter; this mechanism is useful when the job is to suppress Terraform's normal approval prompt in a controlled pipeline, whereas the current scenario requires the engineer to avoid applying from stale remembered attributes after remote drift. These operations have different effects in the stated Terraform workflow.

B:

The parallelism setting controls Terraform's concurrent resource operation count, which can mitigate API throttling; this mechanism is useful when the job is to limit how many graph operations execute concurrently, whereas the current scenario requires the engineer to avoid applying from stale remembered attributes after remote drift. These operations have different effects in the stated Terraform workflow.

C:

The -input=false option prevents prompts for missing input, requiring all necessary values and approvals to be handled by automation; this mechanism is useful when the job is to run Terraform in automation where prompting is not acceptable, whereas the current scenario requires the engineer to avoid applying from stale remembered attributes after remote drift. These operations have different effects in the stated Terraform workflow.

E:

Terraform executes actions in graph order and can operate on independent nodes in parallel subject to provider and CLI limits; this mechanism is useful when the job is to allow independent resources to be applied concurrently, whereas the current scenario requires the engineer to avoid applying from stale remembered attributes after remote drift. These operations have different effects in the stated Terraform workflow.

Question 449

A reusable infrastructure definition requires a way to prevent a module output from being considered ready before an additional side-effect resource. Which Terraform approach most directly fulfills that request?

  1. ignore_changes = all
  2. replace_triggered_by
  3. Resource targeting as an exception
  4. Output-level depends_on

Explanation

Correct Answer

D:

An output block can express an explicit dependency beyond references contained in its value expression; this directly meets the requirement to prevent a module output from being considered ready before an additional side-effect resource. By comparison, ignore_changes = all is intended to disable updates to all managed resource attributes after creation, which is a different task from prevent a module output from being considered ready before an additional side-effect resource.

Incorrect Answers

A:

With all attributes ignored during updates, Terraform can still create and destroy the resource but does not reconcile field-level changes; this mechanism is useful when the job is to disable updates to all managed resource attributes after creation, whereas the current scenario requires the engineer to prevent a module output from being considered ready before an additional side-effect resource. These operations have different effects in the stated Terraform workflow.

B:

This lifecycle rule uses planned resource actions as triggers for replacement and is not a general-purpose dependency selector; this mechanism is useful when the job is to replace one managed resource when another managed resource's attribute changes, whereas the current scenario requires the engineer to prevent a module output from being considered ready before an additional side-effect resource. These operations have different effects in the stated Terraform workflow.

C:

The -target option narrows an operation to selected objects and prerequisites; routine selective deployment is not its intended model; this mechanism is useful when the job is to repair an isolated broken dependency while acknowledging incomplete plan coverage, whereas the current scenario requires the engineer to prevent a module output from being considered ready before an additional side-effect resource. These operations have different effects in the stated Terraform workflow.

Question 450

A runbook lists “No secrets in version control” for the task to keep API keys out of committed terraform.tfvars and .tf files. Which technical effect should its description include?

  1. Saved plan files may contain sensitive values and must be handled as confidential artifacts rather than safe public summaries.
  2. Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL.
  3. Vault can centralize secret lifecycle, policies and auditability, but provider and state-handling choices still determine whether a retrieved value is persisted.
  4. Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to keep API keys out of committed terraform.tfvars and .tf files, so it produces the behavior described. In contrast, vault-backed secret retrieval serves a different goal: retrieve an operational credential from a dedicated secret manager rather than committing it, not keep API keys out of committed terraform.tfvars and .tf files.

Incorrect Answers

A:

The description applies to preventing credential leaks in plans when an engineer needs to avoid sharing a plan artifact publicly just because console values appear redacted; the named no secrets in version control instead handles the requirement to keep API keys out of committed terraform.tfvars and .tf files, so this behavior does not describe No secrets in version control in the situation named.

B:

The description applies to environment-based provider credentials when an engineer needs to avoid putting provider access tokens directly in configuration source; the named no secrets in version control instead handles the requirement to keep API keys out of committed terraform.tfvars and .tf files, so this behavior does not describe No secrets in version control in the situation named.

C:

The description applies to vault-backed secret retrieval when an engineer needs to retrieve an operational credential from a dedicated secret manager rather than committing it; the named no secrets in version control instead handles the requirement to keep API keys out of committed terraform.tfvars and .tf files, so this behavior does not describe No secrets in version control in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests