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

Question 410

The implementation must both retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. HCP Terraform variable sets
  2. HCP Terraform teams and permissions
  3. HCP Terraform auditability
  4. HCP Terraform policy sets
  5. HCP Terraform private module registry

Explanation

Correct Answers

C:

Among the paired tasks to retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, HCP Terraform auditability serves the requirement to retain run and change history for collaboration and review: Workspace run histories help teams trace proposed and executed infrastructure operations. The other task must be covered by a separate mechanism.

D:

Among the paired tasks to retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, HCP Terraform policy sets serves the requirement to enforce organizational rules during infrastructure runs: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. The other task must be covered by a separate mechanism.

Incorrect Answers

A:

The requirements are retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, while HCP Terraform variable sets supports the different task to share reusable variables across selected workspaces: Variable sets can provide common Terraform or environment variables to applicable workspaces. That capability is outside the two selected responsibilities.

B:

The requirements are retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, while HCP Terraform teams and permissions supports the different task to grant workspace access based on collaboration responsibilities: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. That capability is outside the two selected responsibilities.

E:

The requirements are retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, while HCP Terraform private module registry supports the different task to share approved reusable modules within an organization: A private registry distributes versioned modules to organization workspaces and teams. That capability is outside the two selected responsibilities.

Question 411

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

  1. define the supported arguments and attributes for one resource type
  2. associate a resource with the default provider for its type prefix
  3. resolve all referenced provider plugins before planning
  4. authorize API operations requested by a Terraform provider

Explanation

Correct Answer

D:

The practical result of Provider authentication, used to authorize API operations requested by a Terraform provider, is: Providers use supported credentials and authentication mechanisms to talk to their services. A qualification for this effect is: Successful terraform validate does not guarantee those credentials can reach an API.

Incorrect Answers

A:

That outcome applies to Provider resource schema, intended to define the supported arguments and attributes for one resource type, rather than the question's feature Provider authentication: The provider schema specifies which settings users can configure and which values are computed. Unlike Provider resource schema, Provider authentication is intended to authorize API operations requested by a Terraform provider, not to define the supported arguments and attributes for one resource type.

B:

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 authentication: Without a provider meta-argument Terraform normally selects the matching local provider configuration. Unlike Provider selection for resource prefix, Provider authentication is intended to authorize API operations requested by a Terraform provider, not to associate a resource with the default provider for its type prefix.

C:

That outcome applies to Plugin dependency installation, intended to resolve all referenced provider plugins before planning, rather than the question's feature Provider authentication: An initialized working directory has the plugins required for its configured resources and data sources. Unlike Plugin dependency installation, Provider authentication is intended to authorize API operations requested by a Terraform provider, not to resolve all referenced provider plugins before planning.

Question 412

A Terraform rollout has two separate requirements: first, expose a selected Terraform expression to the caller or CLI; second, override environment or tfvars values with an explicit CLI variable flag. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Variable type constraint; then use Variable source precedence.
  2. First use Output block; then use Variable source precedence.
  3. First use Variable source precedence; then use Output block.
  4. First use Output block; then use Required input variable.
  5. First use Required input variable; then use Variable type constraint.

Explanation

Correct Answer

B:

The first requirement, to expose a selected Terraform expression to the caller or CLI, is handled by Output block: An output block publishes a value from its module, such as an endpoint or resource identifier. The second requirement, to override environment or tfvars values with an explicit CLI variable flag, is handled by Variable source precedence: Direct -var and -var-file command-line assignments have precedence over automatically loaded values. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to expose a selected Terraform expression to the caller or CLI and override environment or tfvars values with an explicit CLI variable flag, the first candidate Variable type constraint addresses restrict an input to an expected Terraform type; the second candidate Variable source precedence addresses override environment or tfvars values with an explicit CLI variable flag. This mapping fails because the first mechanism primarily supports the task to restrict an input to an expected Terraform type; the actual requirements are expose a selected Terraform expression to the caller or CLI first and override environment or tfvars values with an explicit CLI variable flag second.

C:

For the requested tasks to expose a selected Terraform expression to the caller or CLI and override environment or tfvars values with an explicit CLI variable flag, the first candidate Variable source precedence addresses override environment or tfvars values with an explicit CLI variable flag; the second candidate Output block addresses expose a selected Terraform expression to the caller or CLI. This mapping fails because the first mechanism primarily supports the task to override environment or tfvars values with an explicit CLI variable flag and the second mechanism primarily supports the task to expose a selected Terraform expression to the caller or CLI; the actual requirements are expose a selected Terraform expression to the caller or CLI first and override environment or tfvars values with an explicit CLI variable flag second.

D:

For the requested tasks to expose a selected Terraform expression to the caller or CLI and override environment or tfvars values with an explicit CLI variable flag, the first candidate Output block addresses expose a selected Terraform expression to the caller or CLI; the second candidate Required input variable addresses prompt for or provide a root-module value when no default exists. This mapping fails because the second mechanism primarily supports the task to prompt for or provide a root-module value when no default exists; the actual requirements are expose a selected Terraform expression to the caller or CLI first and override environment or tfvars values with an explicit CLI variable flag second.

E:

For the requested tasks to expose a selected Terraform expression to the caller or CLI and override environment or tfvars values with an explicit CLI variable flag, the first candidate Required input variable addresses prompt for or provide a root-module value when no default exists; the second candidate Variable type constraint addresses restrict an input to an expected Terraform type. This mapping fails because the first mechanism primarily supports the task to prompt for or provide a root-module value when no default exists and the second mechanism primarily supports the task to restrict an input to an expected Terraform type; the actual requirements are expose a selected Terraform expression to the caller or CLI first and override environment or tfvars values with an explicit CLI variable flag second.

Question 413

A deployment design calls for a supported way to check configuration syntax and internal consistency without proposing resource changes. Which mechanism most directly meets this particular need?

  1. Static checking before a run
  2. Validate after initializing
  3. terraform validate command
  4. Formatting versus validation
  5. Validation of module inputs

Explanation

Correct Answer

C:

The task is to check configuration syntax and internal consistency without proposing resource changes; terraform validate command directly supports that requirement: terraform validate checks the configuration's structural validity in an initialized directory. Its relevant boundary is: It does not verify remote credentials or guarantee an apply succeeds.

Incorrect Answers

A:

Static checking before a run is designed to add a low-risk validation stage to a pull request workflow, whereas this task is to check configuration syntax and internal consistency without proposing resource changes: Running validate early detects many language and schema problems before planning or applying. Against terraform validate command, its limitation is: It cannot evaluate every computed value that requires a remote read.

B:

Validate after initializing is designed to avoid plugin-schema errors when checking a newly cloned configuration, whereas this task is to check configuration syntax and internal consistency without proposing resource changes: An initialized directory provides modules and provider schemas needed for full configuration validation. Against terraform validate command, its limitation is: Validation does not download missing plugins for itself.

D:

Formatting versus validation is designed to distinguish syntactically valid code from canonical HCL formatting, whereas this task is to check configuration syntax and internal consistency without proposing resource changes: terraform fmt changes layout and spacing; terraform validate checks configuration correctness. Against terraform validate command, its limitation is: A configuration may validate even when its style differs from fmt output.

E:

Validation of module inputs is designed to catch an unsupported or missing required module argument early, whereas this task is to check configuration syntax and internal consistency without proposing resource changes: terraform validate can report module call errors that violate input or schema requirements. Against terraform validate command, its limitation is: Input values can still fail runtime preconditions or provider API constraints later.

Question 414

An engineer must update an existing Terraform workflow to configure where a root module stores and accesses its state. Which mechanism most directly meets this particular need?

  1. Remote state centralization
  2. Backend partial configuration
  3. Backend migration workflow
  4. terraform backend block
  5. Data source for remote state outputs
  6. Backend configuration is root-only

Explanation

Correct Answer

D:

The task is to configure where a root module stores and accesses its state; terraform backend block directly supports that requirement: A backend block inside terraform settings specifies a supported state storage backend and its arguments. Its relevant boundary is: Backend setup occurs during init, before normal resource planning.

Incorrect Answers

A:

Remote state centralization is designed to keep a team deployment's current state in a shared backend, whereas this task is to configure where a root module stores and accesses its state: Remote state gives authorized runners a common state location rather than separate laptop snapshots. Against terraform backend block, its limitation is: It still requires strict access controls and backend-specific locking checks.

B:

Backend partial configuration is designed to supply backend settings during init rather than hardcoding all values, whereas this task is to configure where a root module stores and accesses its state: terraform init -backend-config can fill supported backend settings supplied outside checked-in files. Against terraform backend block, its limitation is: Credentials may still leak if stored in a plan or command history; prefer secure credential flows.

C:

Backend migration workflow is designed to move an existing state history when switching remote storage, whereas this task is to configure where a root module stores and accesses its state: terraform init -migrate-state supports moving state during an intentional backend change. Against terraform backend block, its limitation is: The migration should be confirmed and tested to avoid splitting state histories.

E:

Data source for remote state outputs is designed to consume published output values from another Terraform state where supported, whereas this task is to configure where a root module stores and accesses its state: terraform_remote_state exposes root output values from a compatible existing state snapshot. Against terraform backend block, its limitation is: Access to state metadata may expose more than the specific outputs, so permissions matter.

F:

Backend configuration is root-only is designed to set backend storage for a root execution rather than independently in each child module, whereas this task is to configure where a root module stores and accesses its state: The active root module configures the backend used by that Terraform working directory. Against terraform backend block, its limitation is: Child module blocks do not create independent backend state files.

Question 415

During an implementation review, a Terraform team encounters "Peer review for infrastructure". Which purpose is associated with that mechanism?

  1. replace repetitive click-by-click resource deployment with a pipeline
  2. trace why infrastructure definitions changed
  3. reduce configuration drift across environments using shared modules
  4. require approval before risky infrastructure changes

Explanation

Correct Answer

D:

The practical result of Peer review for infrastructure, used to require approval before risky infrastructure changes, is: Text configuration can be reviewed through a normal code review before an approved apply. A qualification for this effect is: Source approval does not replace inspecting the execution plan.

Incorrect Answers

A:

That outcome applies to Automated provisioning pipeline, intended to replace repetitive click-by-click resource deployment with a pipeline, rather than the question's feature Peer review for infrastructure: A CI pipeline can run validation and planning before an authorized apply, reducing procedural inconsistency. Unlike Automated provisioning pipeline, Peer review for infrastructure is intended to require approval before risky infrastructure changes, not to replace repetitive click-by-click resource deployment with a pipeline.

B:

That outcome applies to Version-controlled configuration history, intended to trace why infrastructure definitions changed, rather than the question's feature Peer review for infrastructure: Git commits and pull requests make configuration edits auditable before the next Terraform run. Unlike Version-controlled configuration history, Peer review for infrastructure is intended to require approval before risky infrastructure changes, not to trace why infrastructure definitions changed.

C:

The outcome in this option belongs to Consistent development and production patterns: Reusing modules with explicit inputs aligns infrastructure design while allowing intentional environment differences; by contrast, the feature actually named in the stem, Peer review for infrastructure, has a distinct purpose: to require approval before risky infrastructure changes.

Question 416

During a Terraform 1.12 implementation, the immediate requirement is to compose a reusable infrastructure component into a root configuration. Which mechanism most directly meets this particular need?

  1. Module block invocation
  2. Module provider passing
  3. Module encapsulation
  4. Module refactor with moved block

Explanation

Correct Answer

A:

The task is to compose a reusable infrastructure component into a root configuration; Module block invocation directly supports that requirement: A module block points at a source and supplies declared input arguments to a child module. Its relevant boundary is: The child module must be installed before a complete plan can be evaluated.

Incorrect Answers

B:

Module provider passing is designed to attach an explicitly selected provider configuration to child module resources, whereas this task is to compose a reusable infrastructure component into a root configuration: The providers map lets a module receive the provider instance the caller intends. Against Module block invocation, its limitation is: Each child must declare compatible provider requirements in its own module code.

C:

Module encapsulation is designed to keep implementation resources private while exposing a stable input and output interface, whereas this task is to compose a reusable infrastructure component into a root configuration: Modules promote reuse by letting callers depend on documented variables and outputs rather than every internal block. Against Module block invocation, its limitation is: Changing a module's public interface still requires managing compatibility for callers.

D:

Module refactor with moved block is designed to preserve resource identity when a configuration resource is moved into a module, whereas this task is to compose a reusable infrastructure component into a root configuration: A moved block can map an old resource address to a new module resource address for state-aware refactoring. Against Module block invocation, its limitation is: Move mappings need compatible resource types and valid source/destination addresses.

Question 417

For a new infrastructure repository, the team wants to organize related workspaces and manage project-level access controls. Which mechanism most directly meets this particular need?

  1. Project-level team access
  2. Workspace placement within a project
  3. HCP Terraform project grouping
  4. Workspace variable isolation

Explanation

Correct Answer

C:

The task is to organize related workspaces and manage project-level access controls; HCP Terraform project grouping directly supports that requirement: Projects group HCP Terraform workspaces so teams can delegate organization and access by project. Its relevant boundary is: Project grouping is broadly available, but assigning project-level permissions requires an Essentials, Standard, or Premium plan; each workspace has its own state.

Incorrect Answers

A:

Project-level team access is designed to delegate a set of workspaces without granting broad organization-wide rights, whereas this task is to organize related workspaces and manage project-level access controls: Project-scoped team permissions help control who can manage associated workspaces. Against HCP Terraform project grouping, its limitation is: Project permission management needs Essentials, Standard, or Premium; provider cloud permissions remain independent of HCP roles.

B:

Workspace placement within a project is designed to associate one infrastructure workspace with the correct organizational project, whereas this task is to organize related workspaces and manage project-level access controls: A workspace can be assigned to a project representing its team or platform boundary. Against HCP Terraform project grouping, its limitation is: Moving the workspace between projects does not merge its state with neighbors.

D:

Workspace variable isolation is designed to give development and production separate credentials and deployment values, whereas this task is to organize related workspaces and manage project-level access controls: Distinct workspaces separate their state and input variables even when they use similar configuration. Against HCP Terraform project grouping, its limitation is: Shared variable sets need appropriate scoping to avoid accidental cross-environment access.

Question 418

During an implementation review, a Terraform team encounters "terraform show". Which purpose is associated with that mechanism?

  1. enumerate Terraform resource addresses currently tracked in a state snapshot
  2. export state or saved plan information in machine-readable form
  3. inspect the latest state or a saved execution plan in readable form
  4. retrieve the current backend state snapshot as serialized JSON

Explanation

Correct Answer

C:

The practical result of terraform show, used to inspect the latest state or a saved execution plan in readable form, is: terraform show can display an existing state snapshot or a named plan file. A qualification for this effect is: It is not the same as running a fresh plan against current infrastructure.

Incorrect Answers

A:

That outcome applies to terraform state list, intended to enumerate Terraform resource addresses currently tracked in a state snapshot, rather than the question's feature terraform show: state list displays managed addresses and can be narrowed with address filters. Unlike terraform state list, terraform show is intended to inspect the latest state or a saved execution plan in readable form, not to enumerate Terraform resource addresses currently tracked in a state snapshot.

B:

That outcome applies to terraform show -json, intended to export state or saved plan information in machine-readable form, rather than the question's feature terraform show: show -json emits detailed JSON for supported state and plan representations. Unlike terraform show -json, terraform show is intended to inspect the latest state or a saved execution plan in readable form, not to export state or saved plan information in machine-readable form.

D:

The outcome in this option belongs to terraform state pull: state pull reads state from the configured backend for inspection or backup handling; by contrast, the feature actually named in the stem, terraform show, has a distinct purpose: to inspect the latest state or a saved execution plan in readable form.

Question 419

A Terraform operator is specifically tasked to load multiple variable assignments from a chosen tfvars file. Which mechanism most directly meets this particular need?

  1. Variable type constraint
  2. Variable default value
  3. Required input variable
  4. Variable file input
  5. Output block

Explanation

Correct Answer

D:

The task is to load multiple variable assignments from a chosen tfvars file; Variable file input directly supports that requirement: The -var-file flag passes root-module input values from a named variable definitions file. Its relevant boundary is: The file supplies values but does not declare variable types.

Incorrect Answers

A:

Variable type constraint is designed to restrict an input to an expected Terraform type, whereas this task is to load multiple variable assignments from a chosen tfvars file: A type declaration such as number or object(...) lets Terraform validate and convert compatible inputs. Against Variable file input, its limitation is: Type declarations are different from custom semantic validation rules.

B:

Variable default value is designed to give a module input a fallback when callers omit it, whereas this task is to load multiple variable assignments from a chosen tfvars file: A variable default supplies a value without requiring each caller to pass that argument. Against Variable file input, its limitation is: Explicit callers can override the default with their own value.

C:

Required input variable is designed to prompt for or provide a root-module value when no default exists, whereas this task is to load multiple variable assignments from a chosen tfvars file: A variable block without a default requires a value supplied through a supported input channel. Against Variable file input, its limitation is: Declaring a variable does not itself fetch a remote API value.

E:

Output block addresses the different requirement to expose a selected Terraform expression to the caller or CLI: An output block publishes a value from its module, such as an endpoint or resource identifier; this does not by itself satisfy the requested task to load multiple variable assignments from a chosen tfvars file. For the stated need, Variable file input is the more direct mechanism.

Question 420

During an implementation review, a Terraform team encounters "terraform validate command". Which purpose is associated with that mechanism?

  1. catch an unsupported or missing required module argument early
  2. check configuration syntax and internal consistency without proposing resource changes
  3. avoid plugin-schema errors when checking a newly cloned configuration
  4. distinguish syntactically valid code from canonical HCL formatting

Explanation

Correct Answer

B:

The practical result of terraform validate command, used to check configuration syntax and internal consistency without proposing resource changes, is: terraform validate checks the configuration's structural validity in an initialized directory. A qualification for this effect is: It does not verify remote credentials or guarantee an apply succeeds.

Incorrect Answers

A:

That outcome applies to Validation of module inputs, intended to catch an unsupported or missing required module argument early, rather than the question's feature terraform validate command: terraform validate can report module call errors that violate input or schema requirements. Unlike Validation of module inputs, terraform validate command is intended to check configuration syntax and internal consistency without proposing resource changes, not to catch an unsupported or missing required module argument early.

C:

That outcome applies to Validate after initializing, intended to avoid plugin-schema errors when checking a newly cloned configuration, rather than the question's feature terraform validate command: An initialized directory provides modules and provider schemas needed for full configuration validation. Unlike Validate after initializing, terraform validate command is intended to check configuration syntax and internal consistency without proposing resource changes, not to avoid plugin-schema errors when checking a newly cloned configuration.

D:

That outcome applies to Formatting versus validation, intended to distinguish syntactically valid code from canonical HCL formatting, rather than the question's feature terraform validate command: terraform fmt changes layout and spacing; terraform validate checks configuration correctness. Unlike Formatting versus validation, terraform validate command is intended to check configuration syntax and internal consistency without proposing resource changes, not to distinguish syntactically valid code from canonical HCL formatting.

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