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

Question 270

During a Terraform 1.12 implementation, the immediate requirement is to grant workspace access based on collaboration responsibilities. Which mechanism most directly meets this particular need?

  1. HCP Terraform dynamic provider credentials
  2. HCP Terraform teams and permissions
  3. HCP Terraform private module registry
  4. HCP Terraform auditability
  5. HCP Terraform drift detection
  6. HCP Terraform policy sets

Explanation

Correct Answer

B:

The task is to grant workspace access based on collaboration responsibilities; HCP Terraform teams and permissions directly supports that requirement: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. Its relevant boundary is: Team permission management requires a supported paid HCP Terraform edition; these roles do not replace cloud-provider permissions.

Incorrect Answers

A:

HCP Terraform dynamic provider credentials is designed to avoid long-lived static cloud credentials in workspace variables, whereas this task is to grant workspace access based on collaboration responsibilities: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. Against HCP Terraform teams and permissions, its limitation is: The target provider and cloud identity federation must be configured correctly.

C:

HCP Terraform private module registry is designed to share approved reusable modules within an organization, whereas this task is to grant workspace access based on collaboration responsibilities: A private registry distributes versioned modules to organization workspaces and teams. Against HCP Terraform teams and permissions, its limitation is: Publishing a module is different from executing a workspace run.

D:

HCP Terraform auditability is designed to retain run and change history for collaboration and review, whereas this task is to grant workspace access based on collaboration responsibilities: Workspace run histories help teams trace proposed and executed infrastructure operations. Against HCP Terraform teams and permissions, its limitation is: A recorded run history is not the same as versioned source code approval.

E:

HCP Terraform drift detection is designed to monitor for resources that have diverged from workspace configuration, whereas this task is to grant workspace access based on collaboration responsibilities: Health assessments can identify drift between tracked resources and desired configuration. Against HCP Terraform teams and permissions, its limitation is: HCP Terraform health assessments require Standard or Premium edition and an eligible workspace; detection itself does not automatically correct drift.

F:

HCP Terraform policy sets is designed to enforce organizational rules during infrastructure runs, whereas this task is to grant workspace access based on collaboration responsibilities: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. Against HCP Terraform teams and permissions, its limitation is: Policies assess plans or configuration; they are not Terraform resource providers.

Question 271

A Terraform runbook describes the mechanism "Self reference in provisioners". Which responsibility should a reviewer associate with it?

  1. use a value explicitly exported by a child module
  2. refer to the current managed object in its own provisioner context
  3. avoid assuming files or block order determines operations
  4. ensure a dependent resource waits for a referenced upstream attribute
  5. refer to an instance selected by its map or set key
  6. pass the generated ID of one resource into a dependent resource

Explanation

Correct Answer

B:

The practical result of Self reference in provisioners, used to refer to the current managed object in its own provisioner context, is: The self object is available in supported provisioner and connection contexts for the containing resource. A qualification for this effect is: It is not a general replacement for cross-resource references.

Incorrect Answers

A:

That outcome applies to Module output reference, intended to use a value explicitly exported by a child module, rather than the question's feature Self reference in provisioners: The parent reads a child output through module.name.output_name rather than reaching into child internals. Unlike Module output reference, Self reference in provisioners is intended to refer to the current managed object in its own provisioner context, not to use a value explicitly exported by a child module.

C:

That outcome applies to Reference-based evaluation order, intended to avoid assuming files or block order determines operations, rather than the question's feature Self reference in provisioners: Terraform's graph follows expression dependencies, not the physical line order of configuration blocks. Unlike Reference-based evaluation order, Self reference in provisioners is intended to refer to the current managed object in its own provisioner context, not to avoid assuming files or block order determines operations.

D:

That outcome applies to Implicit resource dependency, intended to ensure a dependent resource waits for a referenced upstream attribute, rather than the question's feature Self reference in provisioners: Terraform infers dependencies when expressions reference other resources. Unlike Implicit resource dependency, Self reference in provisioners is intended to refer to the current managed object in its own provisioner context, not to ensure a dependent resource waits for a referenced upstream attribute.

E:

That outcome applies to Resource address for for_each instance, intended to refer to an instance selected by its map or set key, rather than the question's feature Self reference in provisioners: A for_each resource uses keyed addressing such as example["prod"] and exposes a key-specific object. Unlike Resource address for for_each instance, Self reference in provisioners is intended to refer to the current managed object in its own provisioner context, not to refer to an instance selected by its map or set key.

F:

That outcome applies to Direct attribute reference, intended to pass the generated ID of one resource into a dependent resource, rather than the question's feature Self reference in provisioners: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. Unlike Direct attribute reference, Self reference in provisioners is intended to refer to the current managed object in its own provisioner context, not to pass the generated ID of one resource into a dependent resource.

Question 272

A configuration review identifies the need to translate declarative resources into operations on a platform. Which mechanism most directly meets this particular need?

  1. Idempotent reconciliation
  2. Infrastructure execution plan
  3. Desired configuration
  4. Infrastructure as code definition
  5. Infrastructure provider API

Explanation

Correct Answer

E:

The task is to translate declarative resources into operations on a platform; Infrastructure provider API directly supports that requirement: Provider plugins supply resource implementations and call remote APIs when Terraform reconciles infrastructure. Its relevant boundary is: Terraform Core does not hard-code each cloud service API.

Incorrect Answers

A:

Idempotent reconciliation is designed to repeat an apply without recreating already matching resources, whereas this task is to translate declarative resources into operations on a platform: Terraform compares desired configuration with prior state and refreshed remote information and normally plans no change when they agree. Against Infrastructure provider API, its limitation is: An external drift or changed input can still cause a nonempty plan.

B:

Infrastructure execution plan is designed to preview the proposed actions before changing real resources, whereas this task is to translate declarative resources into operations on a platform: A Terraform plan calculates proposed actions from configuration, state, providers, and current observations. Against Infrastructure provider API, its limitation is: Reviewing a plan is different from committing its effects to the remote system.

C:

Desired configuration is designed to record intended infrastructure settings under version control, whereas this task is to translate declarative resources into operations on a platform: Configuration expresses the operator's intended infrastructure and is the starting point for planning. Against Infrastructure provider API, its limitation is: The file alone does not reveal every live change made outside Terraform.

D:

Infrastructure as code definition is designed to represent desired infrastructure in reviewable configuration files, whereas this task is to translate declarative resources into operations on a platform: Infrastructure as code describes infrastructure through machine-readable files instead of relying only on manual console operations. Against Infrastructure provider API, its limitation is: The configuration still needs a tool and credentials to change actual systems.

Question 273

During a Terraform 1.12 implementation, the immediate requirement is to run a plan after importing an object to check unexpected updates. Which mechanism most directly meets this particular need?

  1. Import without recreation
  2. terraform import CLI
  3. Import validation follow-up
  4. Import under aliased provider
  5. Generate import configuration where supported

Explanation

Correct Answer

C:

The task is to run a plan after importing an object to check unexpected updates; Import validation follow-up directly supports that requirement: A post-import plan reveals whether declared settings match the newly adopted remote object. Its relevant boundary is: Import success alone does not prove the next apply is a no-op.

Incorrect Answers

A:

Import without recreation is designed to adopt an existing object rather than creating a new duplicate, whereas this task is to run a plan after importing an object to check unexpected updates: Import connects an existing provider object to the Terraform state mapping. Against Import validation follow-up, its limitation is: A post-import plan must still be checked for configuration differences.

B:

terraform import CLI is designed to bring a pre-existing remote object under a resource address in Terraform state, whereas this task is to run a plan after importing an object to check unexpected updates: terraform import ADDRESS ID binds the specified remote object to a declared resource instance. Against Import validation follow-up, its limitation is: The import command alone does not generate a complete root configuration.

D:

Import under aliased provider is designed to adopt a remote object from the correct account or region, whereas this task is to run a plan after importing an object to check unexpected updates: The target resource's selected provider configuration determines how Terraform locates and reads the imported object. Against Import validation follow-up, its limitation is: The wrong account's credentials may fail even if an ID format looks valid.

E:

Generate import configuration where supported is designed to use import planning support to help write resource HCL for an existing object, whereas this task is to run a plan after importing an object to check unexpected updates: Terraform supports generating configuration with appropriate import workflows for certain imported resources. Against Import validation follow-up, its limitation is: Generated HCL requires review and may include attributes needing cleanup.

Question 274

A colleague recommends the Terraform concept "Backend migration during init". Which use case best matches it?

  1. move existing state to a newly selected backend when changing its storage
  2. work on configuration validation while deliberately skipping backend initialization
  3. preserve locked provider selections in routine CI initialization
  4. rerun initialization after adding a provider or changing module sources

Explanation

Correct Answer

A:

The practical result of Backend migration during init, used to move existing state to a newly selected backend when changing its storage, is: terraform init -migrate-state offers state migration when a backend configuration changes. A qualification for this effect is: Operators should safeguard and verify state before a migration.

Incorrect Answers

B:

That outcome applies to Init without backend setup, intended to work on configuration validation while deliberately skipping backend initialization, rather than the question's feature Backend migration during init: terraform init -backend=false skips the backend initialization step where appropriate. Unlike Init without backend setup, Backend migration during init is intended to move existing state to a newly selected backend when changing its storage, not to work on configuration validation while deliberately skipping backend initialization.

C:

That outcome applies to Init provider plugin upgrade control, intended to preserve locked provider selections in routine CI initialization, rather than the question's feature Backend migration during init: A normal terraform init honors the existing dependency lock selections unless update is requested. Unlike Init provider plugin upgrade control, Backend migration during init is intended to move existing state to a newly selected backend when changing its storage, not to preserve locked provider selections in routine CI initialization.

D:

That outcome applies to Initialization as safe repeated step, intended to rerun initialization after adding a provider or changing module sources, rather than the question's feature Backend migration during init: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. Unlike Initialization as safe repeated step, Backend migration during init is intended to move existing state to a newly selected backend when changing its storage, not to rerun initialization after adding a provider or changing module sources.

Question 275

An operator chooses the mechanism "terraform force-unlock" for a Terraform project. Which outcome should this choice support?

  1. avoid racing state mutations when several operators run Terraform
  2. prevent two concurrent runs from writing the same state snapshot
  3. remove a stale lock only after confirming that no valid run owns it
  4. protect shared state rather than using -lock=false as a routine workaround

Explanation

Correct Answer

C:

The practical result of terraform force-unlock, used to remove a stale lock only after confirming that no valid run owns it, is: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. A qualification for this effect is: Incorrectly breaking an active lock risks competing state modifications.

Incorrect Answers

A:

That outcome applies to Lock acquisition before writes, intended to avoid racing state mutations when several operators run Terraform, rather than the question's feature terraform force-unlock: Terraform tries to obtain a state lock when the chosen backend supports it. Unlike Lock acquisition before writes, terraform force-unlock is intended to remove a stale lock only after confirming that no valid run owns it, not to avoid racing state mutations when several operators run Terraform.

B:

That outcome applies to Terraform state locking, intended to prevent two concurrent runs from writing the same state snapshot, rather than the question's feature terraform force-unlock: A backend with locking support serializes operations that could corrupt shared state. Unlike Terraform state locking, terraform force-unlock is intended to remove a stale lock only after confirming that no valid run owns it, not to prevent two concurrent runs from writing the same state snapshot.

D:

The outcome in this option belongs to Avoid disabling state locks: Using a lock-capable backend with normal locking reduces state races; by contrast, the feature actually named in the stem, terraform force-unlock, has a distinct purpose: to remove a stale lock only after confirming that no valid run owns it.

Question 276

A change proposal relies on Self reference in provisioners for the task to refer to the current managed object in its own provisioner context. Which limitation specifically applies to it?

  1. Unexported child resource attributes are not directly available to the caller.
  2. It is not a general replacement for cross-resource references.
  3. References can still form invalid cycles if dependencies point back to each other.
  4. Using a plain string ID loses that implicit graph dependency.

Explanation

Correct Answer

B:

For Self reference in provisioners in the task to refer to the current managed object in its own provisioner context, the important caution is: It is not a general replacement for cross-resource references. The reason this matters is its actual behavior: The self object is available in supported provisioner and connection contexts for the containing resource.

Incorrect Answers

A:

The proposed warning belongs to Module output reference, which serves the different goal to use a value explicitly exported by a child module, rather than to Self reference in provisioners: The parent reads a child output through module.name.output_name rather than reaching into child internals. The question concerns Self reference in provisioners acting to refer to the current managed object in its own provisioner context, not a limit of Module output reference.

C:

The proposed warning belongs to Reference-based evaluation order, which serves the different goal to avoid assuming files or block order determines operations, rather than to Self reference in provisioners: Terraform's graph follows expression dependencies, not the physical line order of configuration blocks. The question concerns Self reference in provisioners acting to refer to the current managed object in its own provisioner context, not a limit of Reference-based evaluation order.

D:

The listed caution belongs specifically to Direct attribute reference, used to pass the generated ID of one resource into a dependent resource: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute; the feature under review is instead Self reference in provisioners, so this answer attaches another feature's qualification to the wrong mechanism.

Question 277

A configuration walkthrough identifies "Root variable namespace". Which task is it principally intended to support?

  1. distinguish CLI-supplied root inputs from child inputs
  2. compute module-specific intermediate values without exporting them
  3. pass a caller-defined value into a reusable child module
  4. keep provider instances configured in the root and pass them to child modules

Explanation

Correct Answer

A:

The practical result of Root variable namespace, used to distinguish CLI-supplied root inputs from child inputs, is: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. A qualification for this effect is: A variable with the same name in two modules is a separate declaration.

Incorrect Answers

B:

That outcome applies to Module local values, intended to compute module-specific intermediate values without exporting them, rather than the question's feature Root variable namespace: Local values belong to the defining module and are referenced through local.name in that scope. Unlike Module local values, Root variable namespace is intended to distinguish CLI-supplied root inputs from child inputs, not to compute module-specific intermediate values without exporting them.

C:

That outcome applies to Child module input variable, intended to pass a caller-defined value into a reusable child module, rather than the question's feature Root variable namespace: The child declares a variable and the parent's module block assigns a value to that argument. Unlike Child module input variable, Root variable namespace is intended to distinguish CLI-supplied root inputs from child inputs, not to pass a caller-defined value into a reusable child module.

D:

The outcome in this option belongs to Provider configuration scope: A root module can explicitly map provider configurations into child module calls; by contrast, the feature actually named in the stem, Root variable namespace, has a distinct purpose: to distinguish CLI-supplied root inputs from child inputs.

Question 278

A team reviews the use of HCP Terraform teams and permissions in Terraform 1.12. Which purpose matches its actual behavior?

  1. monitor for resources that have diverged from workspace configuration
  2. retain run and change history for collaboration and review
  3. avoid long-lived static cloud credentials in workspace variables
  4. grant workspace access based on collaboration responsibilities

Explanation

Correct Answer

D:

The practical result of HCP Terraform teams and permissions, used to grant workspace access based on collaboration responsibilities, is: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. A qualification for this effect is: Team permission management requires a supported paid HCP Terraform edition; these roles do not replace cloud-provider permissions.

Incorrect Answers

A:

That outcome applies to HCP Terraform drift detection, intended to monitor for resources that have diverged from workspace configuration, rather than the question's feature HCP Terraform teams and permissions: Health assessments can identify drift between tracked resources and desired configuration. Unlike HCP Terraform drift detection, HCP Terraform teams and permissions is intended to grant workspace access based on collaboration responsibilities, not to monitor for resources that have diverged from workspace configuration.

B:

That outcome applies to HCP Terraform auditability, intended to retain run and change history for collaboration and review, rather than the question's feature HCP Terraform teams and permissions: Workspace run histories help teams trace proposed and executed infrastructure operations. Unlike HCP Terraform auditability, HCP Terraform teams and permissions is intended to grant workspace access based on collaboration responsibilities, not to retain run and change history for collaboration and review.

C:

That outcome applies to HCP Terraform dynamic provider credentials, intended to avoid long-lived static cloud credentials in workspace variables, rather than the question's feature HCP Terraform teams and permissions: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. Unlike HCP Terraform dynamic provider credentials, HCP Terraform teams and permissions is intended to grant workspace access based on collaboration responsibilities, not to avoid long-lived static cloud credentials in workspace variables.

Question 279

During an implementation review, a Terraform team encounters "Provider version compatibility operator". Which purpose is associated with that mechanism?

  1. identify the namespace and provider plugin that Terraform should install
  2. restrict acceptable versions of an infrastructure provider
  3. keep selected provider versions reproducible between runs
  4. allow only nonbreaking versions in a specified range

Explanation

Correct Answer

D:

The practical result of Provider version compatibility operator, used to allow only nonbreaking versions in a specified range, is: A constraint like ~> 5.2 permits compatible versions within that bound while excluding the next incompatible major range. A qualification for this effect is: It is a permitted range, not proof of the installed provider's actual version.

Incorrect Answers

A:

That outcome applies to required_providers source, intended to identify the namespace and provider plugin that Terraform should install, rather than the question's feature Provider version compatibility operator: The required_providers map supplies a provider source address such as hashicorp/aws for dependency resolution. Unlike required_providers source, Provider version compatibility operator is intended to allow only nonbreaking versions in a specified range, not to identify the namespace and provider plugin that Terraform should install.

B:

That outcome applies to Provider version constraint, intended to restrict acceptable versions of an infrastructure provider, rather than the question's feature Provider version compatibility operator: The version argument in required_providers expresses allowed provider versions, such as a compatible release series. Unlike Provider version constraint, Provider version compatibility operator is intended to allow only nonbreaking versions in a specified range, not to restrict acceptable versions of an infrastructure provider.

C:

That outcome applies to Terraform dependency lock file, intended to keep selected provider versions reproducible between runs, rather than the question's feature Provider version compatibility operator: The .terraform.lock.hcl file records resolved provider versions and checksums for repeatable installation. Unlike Terraform dependency lock file, Provider version compatibility operator is intended to allow only nonbreaking versions in a specified range, not to keep selected provider versions reproducible between runs.

Question 280

A Terraform rollout has two separate requirements: first, refer to the current managed object in its own provisioner context; second, pass the generated ID of one resource into a dependent resource. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Self reference in provisioners; then use Implicit resource dependency.
  2. First use Resource address for count instance; then use Direct attribute reference.
  3. First use Implicit resource dependency; then use Resource address for count instance.
  4. First use Self reference in provisioners; then use Direct attribute reference.
  5. First use Direct attribute reference; then use Self reference in provisioners.

Explanation

Correct Answer

D:

The first requirement, to refer to the current managed object in its own provisioner context, is handled by Self reference in provisioners: The self object is available in supported provisioner and connection contexts for the containing resource. The second requirement, to pass the generated ID of one resource into a dependent resource, is handled by Direct attribute reference: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to refer to the current managed object in its own provisioner context and pass the generated ID of one resource into a dependent resource, the first candidate Self reference in provisioners addresses refer to the current managed object in its own provisioner context; the second candidate Implicit resource dependency addresses ensure a dependent resource waits for a referenced upstream attribute. This mapping fails because the second mechanism primarily supports the task to ensure a dependent resource waits for a referenced upstream attribute; the actual requirements are refer to the current managed object in its own provisioner context first and pass the generated ID of one resource into a dependent resource second.

B:

For the requested tasks to refer to the current managed object in its own provisioner context and pass the generated ID of one resource into a dependent resource, the first candidate Resource address for count instance addresses select the exact indexed instance from count-created resources; the second candidate Direct attribute reference addresses pass the generated ID of one resource into a dependent resource. This mapping fails because the first mechanism primarily supports the task to select the exact indexed instance from count-created resources; the actual requirements are refer to the current managed object in its own provisioner context first and pass the generated ID of one resource into a dependent resource second.

C:

For the requested tasks to refer to the current managed object in its own provisioner context and pass the generated ID of one resource into a dependent resource, the first candidate Implicit resource dependency addresses ensure a dependent resource waits for a referenced upstream attribute; the second candidate Resource address for count instance addresses select the exact indexed instance from count-created resources. This mapping fails because the first mechanism primarily supports the task to ensure a dependent resource waits for a referenced upstream attribute and the second mechanism primarily supports the task to select the exact indexed instance from count-created resources; the actual requirements are refer to the current managed object in its own provisioner context first and pass the generated ID of one resource into a dependent resource second.

E:

For the requested tasks to refer to the current managed object in its own provisioner context and pass the generated ID of one resource into a dependent resource, the first candidate Direct attribute reference addresses pass the generated ID of one resource into a dependent resource; the second candidate Self reference in provisioners addresses refer to the current managed object in its own provisioner context. This mapping fails because the first mechanism primarily supports the task to pass the generated ID of one resource into a dependent resource and the second mechanism primarily supports the task to refer to the current managed object in its own provisioner context; the actual requirements are refer to the current managed object in its own provisioner context first and pass the generated ID of one resource into a dependent resource second.

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