HashiCorp Terraform Associate 004 (HashiCorp Certified: Terraform Associate (004)) Practice Test 50

Question 490

Before adopting Workspace variable isolation to give development and production separate credentials and deployment values, which statement sets an accurate boundary?

  1. Project permission management needs Essentials, Standard, or Premium; provider cloud permissions remain independent of HCP roles.
  2. Project grouping is broadly available, but assigning project-level permissions requires an Essentials, Standard, or Premium plan; each workspace has its own state.
  3. Moving the workspace between projects does not merge its state with neighbors.
  4. Shared variable sets need appropriate scoping to avoid accidental cross-environment access.

Explanation

Correct Answer

D:

For Workspace variable isolation in the task to give development and production separate credentials and deployment values, the important caution is: Shared variable sets need appropriate scoping to avoid accidental cross-environment access. The reason this matters is its actual behavior: Distinct workspaces separate their state and input variables even when they use similar configuration.

Incorrect Answers

A:

The proposed warning belongs to Project-level team access, which serves the different goal to delegate a set of workspaces without granting broad organization-wide rights, rather than to Workspace variable isolation: Project-scoped team permissions help control who can manage associated workspaces. The question concerns Workspace variable isolation acting to give development and production separate credentials and deployment values, not a limit of Project-level team access.

B:

The proposed warning belongs to HCP Terraform project grouping, which serves the different goal to organize related workspaces and manage project-level access controls, rather than to Workspace variable isolation: Projects group HCP Terraform workspaces so teams can delegate organization and access by project. The question concerns Workspace variable isolation acting to give development and production separate credentials and deployment values, not a limit of HCP Terraform project grouping.

C:

The proposed warning belongs to Workspace placement within a project, which serves the different goal to associate one infrastructure workspace with the correct organizational project, rather than to Workspace variable isolation: A workspace can be assigned to a project representing its team or platform boundary. The question concerns Workspace variable isolation acting to give development and production separate credentials and deployment values, not a limit of Workspace placement within a project.

Question 491

A team reviews the use of Set type in Terraform 1.12. Which purpose matches its actual behavior?

  1. represent unique elements where ordering does not matter
  2. allow an object input to omit a field with an optional type specification
  3. convert a collection into a set before using for_each
  4. describe a fixed sequence with independently typed positions

Explanation

Correct Answer

A:

The practical result of Set type, used to represent unique elements where ordering does not matter, is: A set(T) deduplicates members and does not guarantee a stable positional order. A qualification for this effect is: Do not rely on numeric indexing into a set like a list.

Incorrect Answers

B:

That outcome applies to Optional object attribute, intended to allow an object input to omit a field with an optional type specification, rather than the question's feature Set type: optional(TYPE, DEFAULT) supports an omitted object attribute and can supply a default value. Unlike Optional object attribute, Set type is intended to represent unique elements where ordering does not matter, not to allow an object input to omit a field with an optional type specification.

C:

That outcome applies to Type conversion function, intended to convert a collection into a set before using for_each, rather than the question's feature Set type: toset(...) converts suitable values into a set, removing duplicates from a list input. Unlike Type conversion function, Set type is intended to represent unique elements where ordering does not matter, not to convert a collection into a set before using for_each.

D:

That outcome applies to Tuple type, intended to describe a fixed sequence with independently typed positions, rather than the question's feature Set type: tuple([...]) declares the expected type at each list position. Unlike Tuple type, Set type is intended to represent unique elements where ordering does not matter, not to describe a fixed sequence with independently typed positions.

Question 492

A platform engineering group needs to reduce configuration drift across environments using shared modules. Which mechanism most directly meets this particular need?

  1. Repeatable environment provisioning
  2. Consistent development and production patterns
  3. Peer review for infrastructure
  4. Version-controlled configuration history

Explanation

Correct Answer

B:

The task is to reduce configuration drift across environments using shared modules; Consistent development and production patterns directly supports that requirement: Reusing modules with explicit inputs aligns infrastructure design while allowing intentional environment differences. Its relevant boundary is: Sharing a module does not force all environments to use identical values.

Incorrect Answers

A:

Repeatable environment provisioning is designed to recreate equivalent infrastructure patterns from one codebase, whereas this task is to reduce configuration drift across environments using shared modules: Parameterizing reusable Terraform modules can provision consistent environment patterns repeatedly. Against Consistent development and production patterns, its limitation is: Differences in inputs and provider versions can still alter actual results.

C:

Peer review for infrastructure is designed to require approval before risky infrastructure changes, whereas this task is to reduce configuration drift across environments using shared modules: Text configuration can be reviewed through a normal code review before an approved apply. Against Consistent development and production patterns, its limitation is: Source approval does not replace inspecting the execution plan.

D:

Version-controlled configuration history is designed to trace why infrastructure definitions changed, whereas this task is to reduce configuration drift across environments using shared modules: Git commits and pull requests make configuration edits auditable before the next Terraform run. Against Consistent development and production patterns, its limitation is: A Git diff tracks source files rather than proving the exact live infrastructure state.

Question 493

For a new infrastructure repository, the team wants to retrieve the current backend state snapshot as serialized JSON. Which mechanism most directly meets this particular need?

  1. terraform state pull
  2. terraform state show ADDRESS
  3. terraform show
  4. terraform state list

Explanation

Correct Answer

A:

The task is to retrieve the current backend state snapshot as serialized JSON; terraform state pull directly supports that requirement: state pull reads state from the configured backend for inspection or backup handling. Its relevant boundary is: Editing and pushing the JSON should not be treated as a routine management workflow.

Incorrect Answers

B:

terraform state show ADDRESS is designed to inspect stored attributes for one tracked resource instance, whereas this task is to retrieve the current backend state snapshot as serialized JSON: state show presents the state representation of an addressed resource. Against terraform state pull, its limitation is: It does not perform an infrastructure change or show another resource automatically.

C:

terraform show is designed to inspect the latest state or a saved execution plan in readable form, whereas this task is to retrieve the current backend state snapshot as serialized JSON: terraform show can display an existing state snapshot or a named plan file. Against terraform state pull, its limitation is: It is not the same as running a fresh plan against current infrastructure.

D:

terraform state list is designed to enumerate Terraform resource addresses currently tracked in a state snapshot, whereas this task is to retrieve the current backend state snapshot as serialized JSON: state list displays managed addresses and can be narrowed with address filters. Against terraform state pull, its limitation is: It does not enumerate every object in the cloud account.

Question 494

A Terraform rollout has two separate requirements: first, catch an unsupported or missing required module argument early; second, add a low-risk validation stage to a pull request workflow. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Static checking before a run; then use Validation of module inputs.
  2. First use Validation of module inputs; then use Static checking before a run.
  3. First use terraform validate -json; then use Validation versus plan authorization.
  4. First use Validation versus plan authorization; then use Static checking before a run.
  5. First use Validation of module inputs; then use terraform validate -json.

Explanation

Correct Answer

B:

The first requirement, to catch an unsupported or missing required module argument early, is handled by Validation of module inputs: terraform validate can report module call errors that violate input or schema requirements. The second requirement, to add a low-risk validation stage to a pull request workflow, is handled by Static checking before a run: Running validate early detects many language and schema problems before planning or applying. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to catch an unsupported or missing required module argument early and add a low-risk validation stage to a pull request workflow, the first candidate Static checking before a run addresses add a low-risk validation stage to a pull request workflow; the second candidate Validation of module inputs addresses catch an unsupported or missing required module argument early. This mapping fails because the first mechanism primarily supports the task to add a low-risk validation stage to a pull request workflow and the second mechanism primarily supports the task to catch an unsupported or missing required module argument early; the actual requirements are catch an unsupported or missing required module argument early first and add a low-risk validation stage to a pull request workflow second.

C:

For the requested tasks to catch an unsupported or missing required module argument early and add a low-risk validation stage to a pull request workflow, the first candidate terraform validate -json addresses emit machine-readable diagnostics for CI processing; the second candidate Validation versus plan authorization addresses reject a proposed change whose behavior is unsafe even when HCL is valid. This mapping fails because the first mechanism primarily supports the task to emit machine-readable diagnostics for CI processing and the second mechanism primarily supports the task to reject a proposed change whose behavior is unsafe even when HCL is valid; the actual requirements are catch an unsupported or missing required module argument early first and add a low-risk validation stage to a pull request workflow second.

D:

For the requested tasks to catch an unsupported or missing required module argument early and add a low-risk validation stage to a pull request workflow, the first candidate Validation versus plan authorization addresses reject a proposed change whose behavior is unsafe even when HCL is valid; the second candidate Static checking before a run addresses add a low-risk validation stage to a pull request workflow. This mapping fails because the first mechanism primarily supports the task to reject a proposed change whose behavior is unsafe even when HCL is valid; the actual requirements are catch an unsupported or missing required module argument early first and add a low-risk validation stage to a pull request workflow second.

E:

For the requested tasks to catch an unsupported or missing required module argument early and add a low-risk validation stage to a pull request workflow, the first candidate Validation of module inputs addresses catch an unsupported or missing required module argument early; the second candidate terraform validate -json addresses emit machine-readable diagnostics for CI processing. This mapping fails because the second mechanism primarily supports the task to emit machine-readable diagnostics for CI processing; the actual requirements are catch an unsupported or missing required module argument early first and add a low-risk validation stage to a pull request workflow second.

Question 495

A Terraform rollout has two separate requirements: first, supply backend settings during init rather than hardcoding all values; second, move an existing state history when switching remote storage. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Backend partial configuration; then use Backend migration workflow.
  2. First use Backend migration workflow; then use Backend partial configuration.
  3. First use Backend configuration is root-only; then use Data source for remote state outputs.
  4. First use Backend partial configuration; then use Backend configuration is root-only.
  5. First use Data source for remote state outputs; then use Backend migration workflow.

Explanation

Correct Answer

A:

The first requirement, to supply backend settings during init rather than hardcoding all values, is handled by Backend partial configuration: terraform init -backend-config can fill supported backend settings supplied outside checked-in files. The second requirement, to move an existing state history when switching remote storage, is handled by Backend migration workflow: terraform init -migrate-state supports moving state during an intentional backend change. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to supply backend settings during init rather than hardcoding all values and move an existing state history when switching remote storage, the first candidate Backend migration workflow addresses move an existing state history when switching remote storage; the second candidate Backend partial configuration addresses supply backend settings during init rather than hardcoding all values. This mapping fails because the first mechanism primarily supports the task to move an existing state history when switching remote storage and the second mechanism primarily supports the task to supply backend settings during init rather than hardcoding all values; the actual requirements are supply backend settings during init rather than hardcoding all values first and move an existing state history when switching remote storage second.

C:

For the requested tasks to supply backend settings during init rather than hardcoding all values and move an existing state history when switching remote storage, the first candidate Backend configuration is root-only addresses set backend storage for a root execution rather than independently in each child module; the second candidate Data source for remote state outputs addresses consume published output values from another Terraform state where supported. This mapping fails because the first mechanism primarily supports the task to set backend storage for a root execution rather than independently in each child module and the second mechanism primarily supports the task to consume published output values from another Terraform state where supported; the actual requirements are supply backend settings during init rather than hardcoding all values first and move an existing state history when switching remote storage second.

D:

For the requested tasks to supply backend settings during init rather than hardcoding all values and move an existing state history when switching remote storage, the first candidate Backend partial configuration addresses supply backend settings during init rather than hardcoding all values; the second candidate Backend configuration is root-only addresses set backend storage for a root execution rather than independently in each child module. This mapping fails because the second mechanism primarily supports the task to set backend storage for a root execution rather than independently in each child module; the actual requirements are supply backend settings during init rather than hardcoding all values first and move an existing state history when switching remote storage second.

E:

For the requested tasks to supply backend settings during init rather than hardcoding all values and move an existing state history when switching remote storage, the first candidate Data source for remote state outputs addresses consume published output values from another Terraform state where supported; the second candidate Backend migration workflow addresses move an existing state history when switching remote storage. This mapping fails because the first mechanism primarily supports the task to consume published output values from another Terraform state where supported; the actual requirements are supply backend settings during init rather than hardcoding all values first and move an existing state history when switching remote storage second.

Question 496

A change proposal relies on Set type for the task to represent unique elements where ordering does not matter. Which limitation specifically applies to it?

  1. The resulting collection should not be treated as positionally indexed.
  2. An optional attribute is not the same as an entirely optional module input variable.
  3. Do not rely on numeric indexing into a set like a list.
  4. Its schema is positional, unlike named fields of an object.

Explanation

Correct Answer

C:

For Set type in the task to represent unique elements where ordering does not matter, the important caution is: Do not rely on numeric indexing into a set like a list. The reason this matters is its actual behavior: A set(T) deduplicates members and does not guarantee a stable positional order.

Incorrect Answers

A:

The proposed warning belongs to Type conversion function, which serves the different goal to convert a collection into a set before using for_each, rather than to Set type: toset(...) converts suitable values into a set, removing duplicates from a list input. The question concerns Set type acting to represent unique elements where ordering does not matter, not a limit of Type conversion function.

B:

The proposed warning belongs to Optional object attribute, which serves the different goal to allow an object input to omit a field with an optional type specification, rather than to Set type: optional(TYPE, DEFAULT) supports an omitted object attribute and can supply a default value. The question concerns Set type acting to represent unique elements where ordering does not matter, not a limit of Optional object attribute.

D:

The proposed warning belongs to Tuple type, which serves the different goal to describe a fixed sequence with independently typed positions, rather than to Set type: tuple([...]) declares the expected type at each list position. The question concerns Set type acting to represent unique elements where ordering does not matter, not a limit of Tuple type.

Question 497

A technical review has three distinct objectives: optionally instantiate a module based on a count expression; attach an explicitly selected provider configuration to child module resources; and preserve resource identity when a configuration resource is moved into a module. Which THREE mechanisms should the team identify for these respective needs? Choose THREE.

  1. Multiple instances of one module
  2. Module block invocation
  3. Module count meta-argument
  4. Module refactor with moved block
  5. Module provider passing

Explanation

Correct Answers

C:

In the workflow combining optionally instantiate a module based on a count expression, attach an explicitly selected provider configuration to child module resources, and preserve resource identity when a configuration resource is moved into a module, Module count meta-argument correctly addresses the individual goal to optionally instantiate a module based on a count expression: count on a module block creates zero or more indexed module instances. It is one of three separately required capabilities.

D:

In the workflow combining optionally instantiate a module based on a count expression, attach an explicitly selected provider configuration to child module resources, and preserve resource identity when a configuration resource is moved into a module, Module refactor with moved block correctly addresses the individual goal to preserve resource identity when a configuration resource is moved into a module: A moved block can map an old resource address to a new module resource address for state-aware refactoring. It is one of three separately required capabilities.

E:

In the workflow combining optionally instantiate a module based on a count expression, attach an explicitly selected provider configuration to child module resources, and preserve resource identity when a configuration resource is moved into a module, Module provider passing correctly addresses the individual goal to attach an explicitly selected provider configuration to child module resources: The providers map lets a module receive the provider instance the caller intends. It is one of three separately required capabilities.

Incorrect Answers

A:

Compared with the three tasks to optionally instantiate a module based on a count expression, attach an explicitly selected provider configuration to child module resources, and preserve resource identity when a configuration resource is moved into a module, Multiple instances of one module primarily supports an unrelated request to deploy a common module separately for several named environments: for_each on a module block can create a keyed child module instance per entry. Therefore this option is not among the three specified mechanisms.

B:

Compared with the three tasks to optionally instantiate a module based on a count expression, attach an explicitly selected provider configuration to child module resources, and preserve resource identity when a configuration resource is moved into a module, Module block invocation primarily supports an unrelated request to compose a reusable infrastructure component into a root configuration: A module block points at a source and supplies declared input arguments to a child module. Therefore this option is not among the three specified mechanisms.

Question 498

A Terraform rollout has two separate requirements: first, give development and production separate credentials and deployment values; second, queue a downstream workspace run when an upstream workspace completes a successful apply. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Workspace variable isolation; then use HCP Terraform run triggers.
  2. First use Project organization versus module reuse; then use HCP Terraform run triggers.
  3. First use Workspace naming and ownership boundaries; then use Project organization versus module reuse.
  4. First use Workspace variable isolation; then use Workspace naming and ownership boundaries.
  5. First use HCP Terraform run triggers; then use Workspace variable isolation.

Explanation

Correct Answer

A:

The first requirement, to give development and production separate credentials and deployment values, is handled by Workspace variable isolation: Distinct workspaces separate their state and input variables even when they use similar configuration. The second requirement, to queue a downstream workspace run when an upstream workspace completes a successful apply, is handled by HCP Terraform run triggers: Run triggers support a controlled dependency workflow between HCP Terraform workspaces. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to give development and production separate credentials and deployment values and queue a downstream workspace run when an upstream workspace completes a successful apply, the first candidate Project organization versus module reuse addresses separate administrative grouping from reusable Terraform code; the second candidate HCP Terraform run triggers addresses queue a downstream workspace run when an upstream workspace completes a successful apply. This mapping fails because the first mechanism primarily supports the task to separate administrative grouping from reusable Terraform code; the actual requirements are give development and production separate credentials and deployment values first and queue a downstream workspace run when an upstream workspace completes a successful apply second.

C:

For the requested tasks to give development and production separate credentials and deployment values and queue a downstream workspace run when an upstream workspace completes a successful apply, the first candidate Workspace naming and ownership boundaries addresses align state ownership with a clearly defined infrastructure component; the second candidate Project organization versus module reuse addresses separate administrative grouping from reusable Terraform code. This mapping fails because the first mechanism primarily supports the task to align state ownership with a clearly defined infrastructure component and the second mechanism primarily supports the task to separate administrative grouping from reusable Terraform code; the actual requirements are give development and production separate credentials and deployment values first and queue a downstream workspace run when an upstream workspace completes a successful apply second.

D:

For the requested tasks to give development and production separate credentials and deployment values and queue a downstream workspace run when an upstream workspace completes a successful apply, the first candidate Workspace variable isolation addresses give development and production separate credentials and deployment values; the second candidate Workspace naming and ownership boundaries addresses align state ownership with a clearly defined infrastructure component. This mapping fails because the second mechanism primarily supports the task to align state ownership with a clearly defined infrastructure component; the actual requirements are give development and production separate credentials and deployment values first and queue a downstream workspace run when an upstream workspace completes a successful apply second.

E:

For the requested tasks to give development and production separate credentials and deployment values and queue a downstream workspace run when an upstream workspace completes a successful apply, the first candidate HCP Terraform run triggers addresses queue a downstream workspace run when an upstream workspace completes a successful apply; the second candidate Workspace variable isolation addresses give development and production separate credentials and deployment values. This mapping fails because the first mechanism primarily supports the task to queue a downstream workspace run when an upstream workspace completes a successful apply and the second mechanism primarily supports the task to give development and production separate credentials and deployment values; the actual requirements are give development and production separate credentials and deployment values first and queue a downstream workspace run when an upstream workspace completes a successful apply second.

Question 499

A Terraform runbook describes the mechanism "Provider resource schema". Which responsibility should a reviewer associate with it?

  1. resolve all referenced provider plugins before planning
  2. define the supported arguments and attributes for one resource type
  3. translate a Terraform resource operation into remote service API calls
  4. read remote information without declaring ownership of its lifecycle
  5. associate a resource with the default provider for its type prefix

Explanation

Correct Answer

B:

The practical result of Provider resource schema, used to define the supported arguments and attributes for one resource type, is: The provider schema specifies which settings users can configure and which values are computed. A qualification for this effect is: A generic Terraform language feature cannot invent unsupported provider arguments.

Incorrect Answers

A:

That outcome applies to Plugin dependency installation, intended to resolve all referenced provider plugins before planning, rather than the question's feature Provider resource schema: An initialized working directory has the plugins required for its configured resources and data sources. Unlike Plugin dependency installation, Provider resource schema is intended to define the supported arguments and attributes for one resource type, not to resolve all referenced provider plugins before planning.

C:

That outcome applies to Provider plugin responsibility, intended to translate a Terraform resource operation into remote service API calls, rather than the question's feature Provider resource schema: The provider implements resource types and performs create, read, update, and delete operations when supported. Unlike Provider plugin responsibility, Provider resource schema is intended to define the supported arguments and attributes for one resource type, not to translate a Terraform resource operation into remote service API calls.

D:

That outcome applies to Provider data sources, intended to read remote information without declaring ownership of its lifecycle, rather than the question's feature Provider resource schema: A provider data source queries external information that configuration can reference. Unlike Provider data sources, Provider resource schema is intended to define the supported arguments and attributes for one resource type, not to read remote information without declaring ownership of its lifecycle.

E:

That outcome applies to Provider selection for resource prefix, intended to associate a resource with the default provider for its type prefix, rather than the question's feature Provider resource schema: Without a provider meta-argument Terraform normally selects the matching local provider configuration. Unlike Provider selection for resource prefix, Provider resource schema is intended to define the supported arguments and attributes for one resource type, not to associate a resource with the default provider for its type prefix.

Question 500

A Terraform rollout has two separate requirements: first, represent unique elements where ordering does not matter; second, define a fixed schema of named attributes with declared types. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Object type; then use Set type.
  2. First use Set type; then use Tuple type.
  3. First use Tuple type; then use Optional object attribute.
  4. First use Optional object attribute; then use Object type.
  5. First use Set type; then use Object type.

Explanation

Correct Answer

E:

The first requirement, to represent unique elements where ordering does not matter, is handled by Set type: A set(T) deduplicates members and does not guarantee a stable positional order. The second requirement, to define a fixed schema of named attributes with declared types, is handled by Object type: object({...}) gives each named property a type, allowing heterogeneous fields. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to represent unique elements where ordering does not matter and define a fixed schema of named attributes with declared types, the first candidate Object type addresses define a fixed schema of named attributes with declared types; the second candidate Set type addresses represent unique elements where ordering does not matter. This mapping fails because the first mechanism primarily supports the task to define a fixed schema of named attributes with declared types and the second mechanism primarily supports the task to represent unique elements where ordering does not matter; the actual requirements are represent unique elements where ordering does not matter first and define a fixed schema of named attributes with declared types second.

B:

For the requested tasks to represent unique elements where ordering does not matter and define a fixed schema of named attributes with declared types, the first candidate Set type addresses represent unique elements where ordering does not matter; the second candidate Tuple type addresses describe a fixed sequence with independently typed positions. This mapping fails because the second mechanism primarily supports the task to describe a fixed sequence with independently typed positions; the actual requirements are represent unique elements where ordering does not matter first and define a fixed schema of named attributes with declared types second.

C:

For the requested tasks to represent unique elements where ordering does not matter and define a fixed schema of named attributes with declared types, the first candidate Tuple type addresses describe a fixed sequence with independently typed positions; the second candidate Optional object attribute addresses allow an object input to omit a field with an optional type specification. This mapping fails because the first mechanism primarily supports the task to describe a fixed sequence with independently typed positions and the second mechanism primarily supports the task to allow an object input to omit a field with an optional type specification; the actual requirements are represent unique elements where ordering does not matter first and define a fixed schema of named attributes with declared types second.

D:

For the requested tasks to represent unique elements where ordering does not matter and define a fixed schema of named attributes with declared types, the first candidate Optional object attribute addresses allow an object input to omit a field with an optional type specification; the second candidate Object type addresses define a fixed schema of named attributes with declared types. This mapping fails because the first mechanism primarily supports the task to allow an object input to omit a field with an optional type specification; the actual requirements are represent unique elements where ordering does not matter first and define a fixed schema of named attributes with declared types second.

HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests