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

Question 300

In a Terraform configuration, what value does the HCL expression sum([2, 3, 5]) evaluate to?

  1. 3
  2. 5
  3. 10
  4. 30

Explanation

Correct Answer

C:

The expression sum([2, 3, 5]) evaluates to 10 because sum adds the three numeric list members to obtain ten. This is Terraform's direct evaluation of the supplied literal arguments in sum([2, 3, 5]), not an external provider lookup.

Incorrect Answers

A:

Sum does not return the count of list entries. In this specific evaluation, sum adds the three numeric list members to obtain ten, which rules out the proposed alternative.

B:

The final list element is not the entire aggregate. For sum([2, 3, 5]), sum adds the three numeric list members to obtain ten; consequently this candidate is not the value Terraform computes.

D:

Multiplying the inputs is not the operation performed by sum. HCL evaluates sum([2, 3, 5]) using the supplied arguments: sum adds the three numeric list members to obtain ten; the listed result is therefore incorrect.

Question 301

A Terraform change proposal names “Init after changing state storage” to adopt a new remote state destination after editing configuration. Which outcome can reviewers attribute to that particular mechanism?

  1. Terraform detects changed backend settings and requires initialization with an explicit migration or reconfiguration choice.
  2. Backend config arguments supplied at init time fill required values, but sensitive content can still be cached in local metadata or plans.
  3. The terraform cloud block connects configuration to HCP Terraform, and cannot coexist with a standard backend block in the same configuration.
  4. Backend configuration is processed at initialization, before ordinary input expressions are evaluated, so it cannot use regular variables or locals.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to adopt a new remote state destination after editing configuration, so it produces the behavior described. In contrast, no input variable interpolation in a backend block serves a different goal: avoid expecting var.region or local.name to populate backend settings, not adopt a new remote state destination after editing configuration.

Incorrect Answers

B:

The description applies to partial backend configuration when an engineer needs to provide environment-specific backend details at initialization rather than hard-coding them; the named init after changing state storage instead handles the requirement to adopt a new remote state destination after editing configuration, so this behavior does not describe Init after changing state storage in the situation named.

C:

The description applies to an HCP Terraform cloud block when an engineer needs to integrate Terraform CLI with an HCP organization and workspace; the named init after changing state storage instead handles the requirement to adopt a new remote state destination after editing configuration, so this behavior does not describe Init after changing state storage in the situation named.

D:

The description applies to no input variable interpolation in a backend block when an engineer needs to avoid expecting var.region or local.name to populate backend settings; the named init after changing state storage instead handles the requirement to adopt a new remote state destination after editing configuration, so this behavior does not describe Init after changing state storage in the situation named.

Question 302

A team sharing an infrastructure state has a concrete implementation goal: stop Terraform from overwriting a field delegated to an external controller. What is the most appropriate Terraform mechanism?

  1. Serial and lineage checks
  2. ignore_changes for shared ownership
  3. terraform plan -refresh-only
  4. A refreshed missing resource

Explanation

Correct Answer

B:

The lifecycle ignore_changes rule suppresses post-creation update plans for selected attributes while leaving other attributes managed; this directly meets the requirement to stop Terraform from overwriting a field delegated to an external controller. By comparison, a refreshed missing resource is intended to understand why Terraform proposes creating a managed object deleted outside the workflow, which is a different task from stop Terraform from overwriting a field delegated to an external controller.

Incorrect Answers

A:

State metadata such as lineage and serial helps protect against incompatible or stale state updates; this mechanism is useful when the job is to detect that a state snapshot belongs to a different history or older generation, whereas the current scenario requires the engineer to stop Terraform from overwriting a field delegated to an external controller. These operations have different effects in the stated Terraform workflow.

C:

Refresh-only planning previews proposed updates to state or root outputs without committing those updates; an apply is needed to persist them; this mechanism is useful when the job is to preview proposed state-only changes without changing remote objects or committing new state, whereas the current scenario requires the engineer to stop Terraform from overwriting a field delegated to an external controller. These operations have different effects in the stated Terraform workflow.

D:

If a provider reports a tracked object no longer exists, a normal plan generally proposes recreating it when its resource block remains; this mechanism is useful when the job is to understand why Terraform proposes creating a managed object deleted outside the workflow, whereas the current scenario requires the engineer to stop Terraform from overwriting a field delegated to an external controller. These operations have different effects in the stated Terraform workflow.

Question 303

A Terraform reviewer encounters “terraform state pull” while assessing how to obtain the current state snapshot for inspection or controlled backup. Which statement correctly describes its actual behavior?

  1. Providers refresh remote resource attributes, and planning can propose updates to bring changed objects back to declared configuration.
  2. Import commands require the provider-defined identity format, not an arbitrary local Terraform block label.
  3. The state pull command retrieves state from the configured backend and prints a snapshot that may contain secrets.
  4. A removed block can intentionally forget the previous resource address without a provider delete when lifecycle destroy is false.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to obtain the current state snapshot for inspection or controlled backup, so it produces the behavior described. In contrast, import IDs defined by providers serves a different goal: map an existing object's correct remote identifier to a Terraform address, not obtain the current state snapshot for inspection or controlled backup.

Incorrect Answers

A:

The description applies to a normal plan with drift when an engineer needs to detect and propose correction for changes made outside Terraform; the named terraform state pull instead handles the requirement to obtain the current state snapshot for inspection or controlled backup, so this behavior does not describe terraform state pull in the situation named.

B:

The description applies to import IDs defined by providers when an engineer needs to map an existing object's correct remote identifier to a Terraform address; the named terraform state pull instead handles the requirement to obtain the current state snapshot for inspection or controlled backup, so this behavior does not describe terraform state pull in the situation named.

D:

The description applies to a removed block with destroy=false when an engineer needs to declare that a resource should leave management while its actual object is retained; the named terraform state pull instead handles the requirement to obtain the current state snapshot for inspection or controlled backup, so this behavior does not describe terraform state pull in the situation named.

Question 304

A release pipeline preparing provider access needs to prevent staging changes from unintentionally sharing the production state mapping. Which feature or operation is the most direct match?

  1. State locking
  2. Separate state per environment
  3. State-backed dependency links
  4. State resource addresses
  5. State snapshots
  6. The state serial number

Explanation

Correct Answer

B:

Distinct backends, workspaces or root configurations can isolate state, but the configuration must target the intended instance set; this directly meets the requirement to prevent staging changes from unintentionally sharing the production state mapping. By comparison, state-backed dependency links is intended to maintain dependencies for resources that have been removed from configuration, which is a different task from prevent staging changes from unintentionally sharing the production state mapping.

Incorrect Answers

A:

A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes; this mechanism is useful when the job is to prevent concurrent state writers from overwriting each other's updates, whereas the current scenario requires the engineer to prevent staging changes from unintentionally sharing the production state mapping. These operations have different effects in the stated Terraform workflow.

C:

State can retain dependency information needed to correctly destroy objects no longer declared in configuration; this mechanism is useful when the job is to maintain dependencies for resources that have been removed from configuration, whereas the current scenario requires the engineer to prevent staging changes from unintentionally sharing the production state mapping. These operations have different effects in the stated Terraform workflow.

D:

State maps Terraform instance addresses to remote object identifiers and remembered attributes for subsequent comparisons; this mechanism is useful when the job is to identify which remote object corresponds to a particular configuration resource, whereas the current scenario requires the engineer to prevent staging changes from unintentionally sharing the production state mapping. These operations have different effects in the stated Terraform workflow.

E:

The state snapshot records managed instance data and metadata needed to plan future actions; this mechanism is useful when the job is to preserve Terraform's knowledge of managed infrastructure between CLI runs, whereas the current scenario requires the engineer to prevent staging changes from unintentionally sharing the production state mapping. These operations have different effects in the stated Terraform workflow.

F:

State metadata includes lineage and serial information that helps Terraform identify state history and updates; this mechanism is useful when the job is to understand how successive snapshots are ordered, whereas the current scenario requires the engineer to prevent staging changes from unintentionally sharing the production state mapping. These operations have different effects in the stated Terraform workflow.

Question 305

During an infrastructure design review about how to avoid concurrent writes from multiple operators on different machines, a maintainer asks what “The local backend's lack of team collaboration features” does. Which description is accurate?

  1. When local workspaces are used, nondefault state snapshots are placed under a terraform.tfstate.d directory structure.
  2. The default workspace's local state is kept as terraform.tfstate; this file may contain sensitive infrastructure details.
  3. Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state.
  4. Local files do not provide an organization-wide shared state or distributed locking comparable to an appropriately configured remote backend.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to avoid concurrent writes from multiple operators on different machines, so it produces the behavior described. In contrast, local workspace state directories serves a different goal: identify how the local backend stores nondefault workspaces, not avoid concurrent writes from multiple operators on different machines.

Incorrect Answers

A:

The description applies to local workspace state directories when an engineer needs to identify how the local backend stores nondefault workspaces; the named the local backend's lack of team collaboration features instead handles the requirement to avoid concurrent writes from multiple operators on different machines, so this behavior does not describe The local backend's lack of team collaboration features in the situation named.

B:

The description applies to the terraform.tfstate file when an engineer needs to identify Terraform's default local state artifact; the named the local backend's lack of team collaboration features instead handles the requirement to avoid concurrent writes from multiple operators on different machines, so this behavior does not describe The local backend's lack of team collaboration features in the situation named.

C:

The description applies to backend configuration only in a root module when an engineer needs to choose where a root deployment's state will be stored; the named the local backend's lack of team collaboration features instead handles the requirement to avoid concurrent writes from multiple operators on different machines, so this behavior does not describe The local backend's lack of team collaboration features in the situation named.

Question 306

A platform team separating infrastructure deployments has a concrete implementation goal: move a workspace to a different organizational group without merging infrastructure state. What is the most appropriate Terraform mechanism?

  1. Project membership changes
  2. A tagged cloud workspaces block
  3. Project-level variable sets
  4. Distinct production and staging workspaces

Explanation

Correct Answer

A:

A project is a grouping and access construct; changing project assignment does not turn two workspaces into one state; this directly meets the requirement to move a workspace to a different organizational group without merging infrastructure state. By comparison, project-level variable sets is intended to assign common environment values to a group of workspaces, which is a different task from move a workspace to a different organizational group without merging infrastructure state.

Incorrect Answers

B:

The cloud block can select a workspace set by supported tags, which differs from specifying one workspace name; this mechanism is useful when the job is to select workspaces using Terraform cloud configuration rather than a single explicit name, whereas the current scenario requires the engineer to move a workspace to a different organizational group without merging infrastructure state. These operations have different effects in the stated Terraform workflow.

C:

Variable sets can be scoped to projects to share configuration while avoiding repetitive per-workspace assignments; this mechanism is useful when the job is to assign common environment values to a group of workspaces, whereas the current scenario requires the engineer to move a workspace to a different organizational group without merging infrastructure state. These operations have different effects in the stated Terraform workflow.

D:

Each HCP Terraform workspace has its own state and run configuration so changes in one do not automatically update the other; this mechanism is useful when the job is to isolate state and runs for two deployment environments, whereas the current scenario requires the engineer to move a workspace to a different organizational group without merging infrastructure state. These operations have different effects in the stated Terraform workflow.

Question 307

During an infrastructure design review about how to delegate administration of one team's project without granting universal organization access, a maintainer asks what “Project-scoped team access” does. Which description is accurate?

  1. Separate workspaces allow independent state lifecycles for services that are changed and approved separately.
  2. Workspaces can reference separate branches or release controls while retaining isolated state for each environment.
  3. Project-level access scopes workspace capabilities for teams based on organizational boundaries.
  4. A run trigger can initiate a downstream plan when its designated upstream workspace completes the relevant run.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to delegate administration of one team's project without granting universal organization access, so it produces the behavior described. In contrast, HCP Terraform run triggers between workspaces serves a different goal: coordinate a dependent app deployment following an upstream network workspace apply, not delegate administration of one team's project without granting universal organization access.

Incorrect Answers

A:

The description applies to one state per independently owned system when an engineer needs to avoid coupling different teams' deploys into a single state and blast radius; the named project-scoped team access instead handles the requirement to delegate administration of one team's project without granting universal organization access, so this behavior does not describe Project-scoped team access in the situation named.

B:

The description applies to environment promotion via workspaces when an engineer needs to use a reviewed configuration revision across separate testing and production states; the named project-scoped team access instead handles the requirement to delegate administration of one team's project without granting universal organization access, so this behavior does not describe Project-scoped team access in the situation named.

D:

The description applies to HCP Terraform run triggers between workspaces when an engineer needs to coordinate a dependent app deployment following an upstream network workspace apply; the named project-scoped team access instead handles the requirement to delegate administration of one team's project without granting universal organization access, so this behavior does not describe Project-scoped team access in the situation named.

Question 308

A runbook lists “A run apply phase” for the task to execute approved resource changes within an HCP Terraform workspace. Which technical effect should its description include?

  1. HCP Terraform APIs can upload configuration versions and orchestrate runs programmatically.
  2. HCP Terraform can run the apply stage after its configured approval, policy and workflow requirements are satisfied.
  3. A CLI workflow can send configuration from the Terraform CLI to HCP Terraform for workspace runs.
  4. An HCP Terraform workspace organizes its own state and runs, providing a collaboration boundary for Terraform execution.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to execute approved resource changes within an HCP Terraform workspace, so it produces the behavior described. In contrast, a CLI-driven workspace serves a different goal: upload local configuration for execution through HCP Terraform rather than relying on Git webhooks, not execute approved resource changes within an HCP Terraform workspace.

Incorrect Answers

A:

The description applies to an API-driven workspace when an engineer needs to start Terraform runs through an external automation integration; the named a run apply phase instead handles the requirement to execute approved resource changes within an HCP Terraform workspace, so this behavior does not describe A run apply phase in the situation named.

C:

The description applies to a CLI-driven workspace when an engineer needs to upload local configuration for execution through HCP Terraform rather than relying on Git webhooks; the named a run apply phase instead handles the requirement to execute approved resource changes within an HCP Terraform workspace, so this behavior does not describe A run apply phase in the situation named.

D:

The description applies to an HCP Terraform workspace when an engineer needs to associate configuration, variables, state and runs for one managed infrastructure scope; the named a run apply phase instead handles the requirement to execute approved resource changes within an HCP Terraform workspace, so this behavior does not describe A run apply phase in the situation named.

Question 309

An organization integrating Terraform with source control has a concrete implementation goal: let approved teams discover modules while controlling publication rights. What is the most appropriate Terraform mechanism?

  1. Cost estimation
  2. Sentinel policy enforcement
  3. Policy sets
  4. A restricted private registry

Explanation

Correct Answer

D:

Registry access and publishing permissions help centralize reusable module governance across teams; this directly meets the requirement to let approved teams discover modules while controlling publication rights. By comparison, cost estimation is intended to preview an estimated cost impact of planned infrastructure changes when available, which is a different task from let approved teams discover modules while controlling publication rights.

Incorrect Answers

A:

HCP Terraform can estimate resource costs for supported providers and resources before apply; estimates are not invoices; this mechanism is useful when the job is to preview an estimated cost impact of planned infrastructure changes when available, whereas the current scenario requires the engineer to let approved teams discover modules while controlling publication rights. These operations have different effects in the stated Terraform workflow.

B:

Sentinel policies can assess planned infrastructure and produce policy check outcomes before a run can apply when enforcement requires it; this mechanism is useful when the job is to evaluate organizational infrastructure rules during HCP Terraform runs, whereas the current scenario requires the engineer to let approved teams discover modules while controlling publication rights. These operations have different effects in the stated Terraform workflow.

C:

Policy sets organize policy rules and their workspace or project applicability rather than modifying provider schemas directly; this mechanism is useful when the job is to attach a shared governance policy collection to selected workspace scopes, whereas the current scenario requires the engineer to let approved teams discover modules while controlling publication rights. These operations have different effects in the stated Terraform workflow.

Question 310

A declarative resource and expression design requires a way to distinguish static configuration checks from conditions requiring actual resource values. Which Terraform approach most directly fulfills that request?

  1. Data source postcondition
  2. Postconditions for exported IDs
  3. terraform validate versus runtime assertions
  4. Input variable validation

Explanation

Correct Answer

C:

Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply; this directly meets the requirement to distinguish static configuration checks from conditions requiring actual resource values. By comparison, data source postcondition is intended to reject use of queried data when it violates a required invariant, which is a different task from distinguish static configuration checks from conditions requiring actual resource values.

Incorrect Answers

A:

A postcondition on a data block can validate attributes returned from a provider before downstream resources rely on them; this mechanism is useful when the job is to reject use of queried data when it violates a required invariant, whereas the current scenario requires the engineer to distinguish static configuration checks from conditions requiring actual resource values. These operations have different effects in the stated Terraform workflow.

B:

Postconditions validate resultant resource or data-source attributes and prevent dependents from relying on invalid results; this mechanism is useful when the job is to guard a dependent consumer against a provider result that violates an invariant, whereas the current scenario requires the engineer to distinguish static configuration checks from conditions requiring actual resource values. These operations have different effects in the stated Terraform workflow.

D:

The validation block uses a condition and a custom error_message to enforce rules on caller-supplied values; this mechanism is useful when the job is to reject malformed module inputs before provisioning resources, whereas the current scenario requires the engineer to distinguish static configuration checks from conditions requiring actual resource values. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests