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

Question 930

A team compares Terraform mechanisms for the goal to avoid hard-coding a provider's API credential into .tf files. Which stated consequence belongs specifically to “Provider authentication environment variables”?

  1. Providers retrieve object details so Terraform can compare observed infrastructure against desired configuration and prior state.
  2. Terraform generally selects the default provider matching a resource's type prefix unless an alternate configuration is specified.
  3. A provider's data source reads existing data and exposes attributes without creating or destroying the queried object.
  4. Many provider plugins can read credentials from provider-specific environment variables or identity mechanisms, reducing secret exposure in configuration.
  5. Version constraints and a shared lock file reduce unintended schema and behavior changes between deployments.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to avoid hard-coding a provider's API credential into .tf files, so it produces the behavior described. In contrast, provider-defined data sources serves a different goal: read information from an external service without owning its lifecycle, not avoid hard-coding a provider's API credential into .tf files.

Incorrect Answers

A:

The description applies to provider data refresh when an engineer needs to read current attributes of managed remote objects during planning; the named provider authentication environment variables instead handles the requirement to avoid hard-coding a provider's API credential into .tf files, so this behavior does not describe Provider authentication environment variables in the situation named.

B:

The description applies to implicit provider selection when an engineer needs to use the default provider configuration for a resource type; the named provider authentication environment variables instead handles the requirement to avoid hard-coding a provider's API credential into .tf files, so this behavior does not describe Provider authentication environment variables in the situation named.

C:

The description applies to provider-defined data sources when an engineer needs to read information from an external service without owning its lifecycle; the named provider authentication environment variables instead handles the requirement to avoid hard-coding a provider's API credential into .tf files, so this behavior does not describe Provider authentication environment variables in the situation named.

E:

The description applies to provider version compatibility when an engineer needs to prevent incompatible provider upgrades from affecting resource handling; the named provider authentication environment variables instead handles the requirement to avoid hard-coding a provider's API credential into .tf files, so this behavior does not describe Provider authentication environment variables in the situation named.

Question 931

A configuration review for an application stack has a concrete implementation goal: calculate an IP address at an offset within a CIDR range. What is the most appropriate Terraform mechanism?

  1. The upper function
  2. The for expression
  3. The lookup function
  4. The cidrhost function

Explanation

Correct Answer

D:

cidrhost computes a host address inside the given prefix from a numeric host index; this directly meets the requirement to calculate an IP address at an offset within a CIDR range. By comparison, the for expression is intended to transform a collection's elements into a new list or map, which is a different task from calculate an IP address at an offset within a CIDR range.

Incorrect Answers

A:

upper transforms the letters of a string into uppercase without changing its underlying Terraform type; this mechanism is useful when the job is to convert an environment label to uppercase, whereas the current scenario requires the engineer to calculate an IP address at an offset within a CIDR range. These operations have different effects in the stated Terraform workflow.

B:

A for expression builds derived collection values, optionally filtering with an if clause and transforming keys or values; this mechanism is useful when the job is to transform a collection's elements into a new list or map, whereas the current scenario requires the engineer to calculate an IP address at an offset within a CIDR range. These operations have different effects in the stated Terraform workflow.

C:

lookup(map, key, default) retrieves the selected key's value or the supplied default if the key does not exist; this mechanism is useful when the job is to read a map element and provide a fallback when the key is absent, whereas the current scenario requires the engineer to calculate an IP address at an offset within a CIDR range. These operations have different effects in the stated Terraform workflow.

Question 932

During an infrastructure design review about how to read an existing cloud object so Terraform can associate it with state, a maintainer asks what “Provider permissions during import” does. Which description is accurate?

  1. After import, planning reveals mismatches between the declared resource arguments and the discovered remote object's attributes.
  2. A top-level import block identifies a target resource address and import identity so the operation participates in plan and apply.
  3. Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID.
  4. Imported infrastructure should have a corresponding resource block with configuration matching the desired attributes so the next plan is safe.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to read an existing cloud object so Terraform can associate it with state, so it produces the behavior described. In contrast, a matching resource declaration serves a different goal: avoid unintended changes immediately after importing a remote object, not read an existing cloud object so Terraform can associate it with state.

Incorrect Answers

A:

The description applies to a post-import plan when an engineer needs to review whether Terraform intends to change imported infrastructure unexpectedly; the named provider permissions during import instead handles the requirement to read an existing cloud object so Terraform can associate it with state, so this behavior does not describe Provider permissions during import in the situation named.

B:

The description applies to the import block when an engineer needs to declare a managed import operation in configuration for planning and applying; the named provider permissions during import instead handles the requirement to read an existing cloud object so Terraform can associate it with state, so this behavior does not describe Provider permissions during import in the situation named.

D:

The description applies to a matching resource declaration when an engineer needs to avoid unintended changes immediately after importing a remote object; the named provider permissions during import instead handles the requirement to read an existing cloud object so Terraform can associate it with state, so this behavior does not describe Provider permissions during import in the situation named.

Question 933

During a design review, the requirement is to authorize Terraform separately for two different infrastructure APIs. Which option should the engineer select?

  1. Multi-cloud state visibility
  2. Provider authentication per service
  3. Hybrid infrastructure provisioning
  4. Integrating platform and DNS configuration
  5. Service-agnostic resource modeling

Explanation

Correct Answer

B:

Each provider configuration supplies or discovers credentials appropriate to the API it calls, rather than sharing a universal Terraform credential; this directly meets the requirement to authorize Terraform separately for two different infrastructure APIs. By comparison, multi-cloud state visibility is intended to track resources in distinct providers together within the chosen state scope, which is a different task from authorize Terraform separately for two different infrastructure APIs.

Incorrect Answers

A:

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

C:

Providers can represent both on-premises platforms and cloud services as Terraform-managed resources in one workflow; this mechanism is useful when the job is to coordinate an on-premises platform with public-cloud resources, whereas the current scenario requires the engineer to authorize Terraform separately for two different infrastructure APIs. These operations have different effects in the stated Terraform workflow.

D:

Distinct providers can manage compute and DNS resources while references communicate values such as an assigned endpoint; this mechanism is useful when the job is to manage a cloud-hosted service and its DNS records declaratively, whereas the current scenario requires the engineer to authorize Terraform separately for two different infrastructure APIs. These operations have different effects in the stated Terraform workflow.

E:

Terraform Core offers common configuration and state mechanisms while provider schemas capture each platform's API differences; this mechanism is useful when the job is to use a common configuration workflow across distinct vendors, whereas the current scenario requires the engineer to authorize Terraform separately for two different infrastructure APIs. These operations have different effects in the stated Terraform workflow.

Question 934

A Terraform runbook prescribes “The state serial number” to treat a Terraform state file as potentially sensitive data, but it does not meet the requirement. What does that step actually accomplish?

  1. The state snapshot records managed instance data and metadata needed to plan future actions.
  2. Distinct backends, workspaces or root configurations can isolate state, but the configuration must target the intended instance set.
  3. State metadata includes lineage and serial information that helps Terraform identify state history and updates.
  4. State may contain secret values even when CLI output is redacted, so storage encryption and access controls matter.

Explanation

Correct Answer

C:

The state serial number is used when an operator needs to understand how successive snapshots are ordered. Consequently, this choice cannot meet the separate requirement to treat a Terraform state file as potentially sensitive data. The intended action would instead require State access protection.

Incorrect Answers

A:

This behavior belongs to State snapshots, which helps engineers preserve Terraform's knowledge of managed infrastructure between CLI runs rather than satisfying the separate requirement to treat a Terraform state file as potentially sensitive data. The attempted technique was The state serial number; it would instead be used to understand how successive snapshots are ordered, not to produce the effect associated with State snapshots.

B:

This behavior belongs to Separate state per environment, which helps engineers prevent staging changes from unintentionally sharing the production state mapping rather than satisfying the separate requirement to treat a Terraform state file as potentially sensitive data. The attempted technique was The state serial number; it would instead be used to understand how successive snapshots are ordered, not to produce the effect associated with Separate state per environment.

D:

That outcome belongs to State access protection, the mechanism that can treat a Terraform state file as potentially sensitive data. The question concerns the engineer’s actual proposal, The state serial number; it is directed at understand how successive snapshots are ordered, not that result.

Question 935

A team sharing an infrastructure state has a concrete implementation goal: forget a managed object without destroying the corresponding real infrastructure. What is the most appropriate Terraform mechanism?

  1. terraform state rm
  2. Avoid direct state JSON editing
  3. A normal plan with drift
  4. Serial and lineage checks

Explanation

Correct Answer

A:

The state rm command removes the association so the remote object remains but is no longer tracked by that state; this directly meets the requirement to forget a managed object without destroying the corresponding real infrastructure. By comparison, a normal plan with drift is intended to detect and propose correction for changes made outside Terraform, which is a different task from forget a managed object without destroying the corresponding real infrastructure.

Incorrect Answers

B:

Manual state-file changes can break address mappings or serial consistency; commands such as state mv and moved blocks are safer; this mechanism is useful when the job is to make state changes through supported Terraform commands and declarative refactors, whereas the current scenario requires the engineer to forget a managed object without destroying the corresponding real infrastructure. These operations have different effects in the stated Terraform workflow.

C:

Providers refresh remote resource attributes, and planning can propose updates to bring changed objects back to declared configuration; this mechanism is useful when the job is to detect and propose correction for changes made outside Terraform, whereas the current scenario requires the engineer to forget a managed object without destroying the corresponding real infrastructure. These operations have different effects in the stated Terraform workflow.

D:

State metadata such as lineage and serial helps protect against incompatible or stale state updates; this mechanism is useful when the job is to detect that a state snapshot belongs to a different history or older generation, whereas the current scenario requires the engineer to forget a managed object without destroying the corresponding real infrastructure. These operations have different effects in the stated Terraform workflow.

Question 936

A Terraform change proposal names “Integrating platform and DNS configuration” to manage a cloud-hosted service and its DNS records declaratively. Which outcome can reviewers attribute to that particular mechanism?

  1. An attribute reference between resource instances can create a dependency across provider boundaries.
  2. Distinct providers can manage compute and DNS resources while references communicate values such as an assigned endpoint.
  3. One Terraform state can map managed resources from multiple providers, although separate configurations may improve blast-radius isolation.
  4. Terraform Core offers common configuration and state mechanisms while provider schemas capture each platform's API differences.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to manage a cloud-hosted service and its DNS records declaratively, so it produces the behavior described. In contrast, multi-cloud state visibility serves a different goal: track resources in distinct providers together within the chosen state scope, not manage a cloud-hosted service and its DNS records declaratively.

Incorrect Answers

A:

The description applies to cross-provider references when an engineer needs to link an output from one service to a dependent resource on another service; the named integrating platform and DNS configuration instead handles the requirement to manage a cloud-hosted service and its DNS records declaratively, so this behavior does not describe Integrating platform and DNS configuration in the situation named.

C:

The description applies to multi-cloud state visibility when an engineer needs to track resources in distinct providers together within the chosen state scope; the named integrating platform and DNS configuration instead handles the requirement to manage a cloud-hosted service and its DNS records declaratively, so this behavior does not describe Integrating platform and DNS configuration in the situation named.

D:

The description applies to service-agnostic resource modeling when an engineer needs to use a common configuration workflow across distinct vendors; the named integrating platform and DNS configuration instead handles the requirement to manage a cloud-hosted service and its DNS records declaratively, so this behavior does not describe Integrating platform and DNS configuration in the situation named.

Question 937

A Terraform change proposal names “Dynamic provider credential integration” to grant HCP runs temporary cloud authorization instead of long-lived static secrets. Which outcome can reviewers attribute to that particular mechanism?

  1. The cloud block's workspaces name attribute identifies one workspace, rather than selecting an arbitrary state path.
  2. The cloud hostname setting and login host identify the relevant service installation for organization operations.
  3. Dynamic credentials integrate HCP Terraform with supported identity federation to obtain scoped run credentials.
  4. The login command stores a CLI API token for the selected service host so CLI-driven workflows can authenticate.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to grant HCP runs temporary cloud authorization instead of long-lived static secrets, so it produces the behavior described. In contrast, a cloud workspaces name setting serves a different goal: target a particular HCP Terraform workspace from a root configuration, not grant HCP runs temporary cloud authorization instead of long-lived static secrets.

Incorrect Answers

A:

The description applies to a cloud workspaces name setting when an engineer needs to target a particular HCP Terraform workspace from a root configuration; the named dynamic provider credential integration instead handles the requirement to grant HCP runs temporary cloud authorization instead of long-lived static secrets, so this behavior does not describe Dynamic provider credential integration in the situation named.

B:

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 dynamic provider credential integration instead handles the requirement to grant HCP runs temporary cloud authorization instead of long-lived static secrets, so this behavior does not describe Dynamic provider credential integration in the situation named.

D:

The description applies to terraform login when an engineer needs to authenticate the local Terraform CLI to an HCP Terraform or Terraform Enterprise hostname; the named dynamic provider credential integration instead handles the requirement to grant HCP runs temporary cloud authorization instead of long-lived static secrets, so this behavior does not describe Dynamic provider credential integration in the situation named.

Question 938

During a design review, the requirement is to keep two pipelines from changing the same infrastructure state simultaneously. Which option should the engineer select?

  1. terraform force-unlock
  2. State consistency during CI
  3. terraform plan -lock-timeout
  4. A backend state lock

Explanation

Correct Answer

B:

A state backend with locking helps serialize competing changes, complemented by pipeline approval and run coordination; this directly meets the requirement to keep two pipelines from changing the same infrastructure state simultaneously. By comparison, a backend state lock is intended to serialize operations that write the same Terraform state, which is a different task from keep two pipelines from changing the same infrastructure state simultaneously.

Incorrect Answers

A:

The force-unlock command removes a lock by its identifier; using it during an active operation can cause state corruption; this mechanism is useful when the job is to release a stale lock when the original process is definitively gone, whereas the current scenario requires the engineer to keep two pipelines from changing the same infrastructure state simultaneously. These operations have different effects in the stated Terraform workflow.

C:

The lock-timeout option lets Terraform retry lock acquisition for a specified duration before returning an error; this mechanism is useful when the job is to wait for a temporary state lock instead of failing immediately, whereas the current scenario requires the engineer to keep two pipelines from changing the same infrastructure state simultaneously. These operations have different effects in the stated Terraform workflow.

D:

Supported backends acquire a state lock so simultaneous writers cannot corrupt or overwrite each other's state changes; this mechanism is useful when the job is to serialize operations that write the same Terraform state, whereas the current scenario requires the engineer to keep two pipelines from changing the same infrastructure state simultaneously. These operations have different effects in the stated Terraform workflow.

Question 939

During a design review, the requirement is to instantiate a fixed number of child module copies. Which option should the engineer select?

  1. A module with count
  2. Module-level depends_on
  3. Multiple calls to one module
  4. Using a module registry version

Explanation

Correct Answer

A:

The count meta-argument creates numerically indexed module instances such as module.worker[0]; this directly meets the requirement to instantiate a fixed number of child module copies. By comparison, multiple calls to one module is intended to deploy two independently managed stacks from the same module definition, which is a different task from instantiate a fixed number of child module copies.

Incorrect Answers

B:

depends_on on a module call affects all resources and data sources inside that module and can constrain concurrency; this mechanism is useful when the job is to create an explicit ordering edge for module resources that have a real hidden dependency, whereas the current scenario requires the engineer to instantiate a fixed number of child module copies. These operations have different effects in the stated Terraform workflow.

C:

Two module blocks that use the same source create separate module instances and separate resource addresses; this mechanism is useful when the job is to deploy two independently managed stacks from the same module definition, whereas the current scenario requires the engineer to instantiate a fixed number of child module copies. These operations have different effects in the stated Terraform workflow.

D:

The module block's version argument can constrain registry modules and is separate from Terraform CLI and provider version settings; this mechanism is useful when the job is to control which published module release a root configuration consumes, whereas the current scenario requires the engineer to instantiate a fixed number of child module copies. These operations have different effects in the stated Terraform workflow.

Question 940

A Terraform reviewer encounters “Local workspace state directories” while assessing how to identify how the local backend stores nondefault workspaces. Which statement correctly describes its actual behavior?

  1. Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state.
  2. Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state.
  3. Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter.
  4. When local workspaces are used, nondefault state snapshots are placed under a terraform.tfstate.d directory structure.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to identify how the local backend stores nondefault workspaces, 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 how the local backend stores nondefault workspaces.

Incorrect Answers

A:

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 local workspace state directories instead handles the requirement to identify how the local backend stores nondefault workspaces, so this behavior does not describe Local workspace state directories in the situation named.

B:

The description applies to backend configuration only in a root module when an engineer needs to choose where a root deployment's state will be stored; the named local workspace state directories instead handles the requirement to identify how the local backend stores nondefault workspaces, so this behavior does not describe Local workspace state directories in the situation named.

C:

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 local workspace state directories instead handles the requirement to identify how the local backend stores nondefault workspaces, so this behavior does not describe Local workspace state directories in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests