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

Question 240

A state migration and recovery exercise needs to declare that a resource should leave management while its actual object is retained. Which feature or operation is the most direct match?

  1. A removed block with destroy=false
  2. Serial and lineage checks
  3. ignore_changes for shared ownership
  4. A state import workflow
  5. terraform apply -refresh-only

Explanation

Correct Answer

A:

A removed block can intentionally forget the previous resource address without a provider delete when lifecycle destroy is false; this directly meets the requirement to declare that a resource should leave management while its actual object is retained. By comparison, terraform apply -refresh-only is intended to accept current remote readings into Terraform's state through an apply operation, which is a different task from declare that a resource should leave management while its actual object is retained.

Incorrect Answers

B:

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 declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.

C:

The lifecycle ignore_changes rule suppresses post-creation update plans for selected attributes while leaving other attributes managed; this mechanism is useful when the job is to stop Terraform from overwriting a field delegated to an external controller, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.

D:

Importing attaches the remote object's identity to state; compatible configuration is still needed to avoid unwanted changes afterward; this mechanism is useful when the job is to associate existing infrastructure with a newly declared Terraform resource address, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.

E:

Refresh-only apply can update the recorded state to match observed remote attributes without modifying cloud resources; this mechanism is useful when the job is to accept current remote readings into Terraform's state through an apply operation, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.

Question 241

A configuration review for an application stack has a concrete implementation goal: guard a dependent consumer against a provider result that violates an invariant. What is the most appropriate Terraform mechanism?

  1. Postconditions for exported IDs
  2. Custom conditions with unknown values
  3. Resource precondition
  4. The check block

Explanation

Correct Answer

A:

Postconditions validate resultant resource or data-source attributes and prevent dependents from relying on invalid results; this directly meets the requirement to guard a dependent consumer against a provider result that violates an invariant. By comparison, the check block is intended to report a failed ongoing infrastructure assertion without ordinarily blocking the apply, which is a different task from guard a dependent consumer against a provider result that violates an invariant.

Incorrect Answers

B:

Terraform may defer condition evaluation to apply when required expression values are unknown during planning; this mechanism is useful when the job is to understand when a validation cannot yet be decided at planning time, whereas the current scenario requires the engineer to guard a dependent consumer against a provider result that violates an invariant. These operations have different effects in the stated Terraform workflow.

C:

A precondition inside lifecycle requires a true predicate before Terraform can continue the relevant resource operation; this mechanism is useful when the job is to fail a plan or apply when a prerequisite property is unacceptable, whereas the current scenario requires the engineer to guard a dependent consumer against a provider result that violates an invariant. These operations have different effects in the stated Terraform workflow.

D:

Check assertions evaluate health expectations and normally report warning diagnostics rather than blocking deployment on a false condition; this mechanism is useful when the job is to report a failed ongoing infrastructure assertion without ordinarily blocking the apply, whereas the current scenario requires the engineer to guard a dependent consumer against a provider result that violates an invariant. These operations have different effects in the stated Terraform workflow.

Question 242

A reusable infrastructure definition requires a way to represent the absence of an optional argument value. Which Terraform approach most directly fulfills that request?

  1. A set of strings type
  2. The any type constraint
  3. tolist conversion
  4. The null value

Explanation

Correct Answer

D:

In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset; this directly meets the requirement to represent the absence of an optional argument value. By comparison, tolist conversion is intended to coerce a suitable collection into a list for ordered operations, which is a different task from represent the absence of an optional argument value.

Incorrect Answers

A:

The set(string) type deduplicates values and does not preserve a meaningful input element order; this mechanism is useful when the job is to store a collection with no duplicate members and no guaranteed order, whereas the current scenario requires the engineer to represent the absence of an optional argument value. These operations have different effects in the stated Terraform workflow.

B:

The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts; this mechanism is useful when the job is to accept values without imposing a specific static input shape, whereas the current scenario requires the engineer to represent the absence of an optional argument value. These operations have different effects in the stated Terraform workflow.

C:

tolist converts compatible values to a list, but a source set's original order is not inherently meaningful; this mechanism is useful when the job is to coerce a suitable collection into a list for ordered operations, whereas the current scenario requires the engineer to represent the absence of an optional argument value. These operations have different effects in the stated Terraform workflow.

Question 243

A configuration review for an application stack requires a way to pass a newly managed object's computed identifier to a dependent resource. Which Terraform approach most directly fulfills that request?

  1. Resource removal without deletion
  2. A resource attribute reference
  3. Resource local names
  4. Data sources as external lookups

Explanation

Correct Answer

B:

References like aws_vpc.main.id use a managed resource's attributes and create an implicit dependency; this directly meets the requirement to pass a newly managed object's computed identifier to a dependent resource. By comparison, resource removal without deletion is intended to retain a remote object but stop Terraform from managing it, which is a different task from pass a newly managed object's computed identifier to a dependent resource.

Incorrect Answers

A:

A removed block with destroy = false can express a configuration-driven removal from state while leaving the infrastructure object intact; this mechanism is useful when the job is to retain a remote object but stop Terraform from managing it, whereas the current scenario requires the engineer to pass a newly managed object's computed identifier to a dependent resource. These operations have different effects in the stated Terraform workflow.

C:

A resource block has a type and a local label; together they form its address within the module; this mechanism is useful when the job is to distinguish two managed instances of the same provider-defined resource type, whereas the current scenario requires the engineer to pass a newly managed object's computed identifier to a dependent resource. These operations have different effects in the stated Terraform workflow.

D:

A provider data source can resolve the zone ID for use in managed records while the zone itself remains outside that configuration's resource lifecycle; this mechanism is useful when the job is to use an existing DNS zone from a provider without taking ownership of the zone, whereas the current scenario requires the engineer to pass a newly managed object's computed identifier to a dependent resource. These operations have different effects in the stated Terraform workflow.

Question 244

A team compares Terraform mechanisms for the goal to use a common configuration workflow across distinct vendors. Which stated consequence belongs specifically to “Service-agnostic resource modeling”?

  1. Providers can represent both on-premises platforms and cloud services as Terraform-managed resources in one workflow.
  2. Terraform's core workflow works across providers even though their individual resources and authentication methods differ.
  3. Terraform Core offers common configuration and state mechanisms while provider schemas capture each platform's API differences.
  4. One Terraform state can map managed resources from multiple providers, although separate configurations may improve blast-radius isolation.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to use a common configuration workflow across distinct vendors, so it produces the behavior described. In contrast, consistent automation pipeline serves a different goal: apply the same validate-plan-apply lifecycle to more than one cloud, not use a common configuration workflow across distinct vendors.

Incorrect Answers

A:

The description applies to hybrid infrastructure provisioning when an engineer needs to coordinate an on-premises platform with public-cloud resources; the named service-agnostic resource modeling instead handles the requirement to use a common configuration workflow across distinct vendors, so this behavior does not describe Service-agnostic resource modeling in the situation named.

B:

The description applies to consistent automation pipeline when an engineer needs to apply the same validate-plan-apply lifecycle to more than one cloud; the named service-agnostic resource modeling instead handles the requirement to use a common configuration workflow across distinct vendors, so this behavior does not describe Service-agnostic resource modeling in the situation named.

D:

The description applies to multi-cloud state visibility when an engineer needs to track resources in distinct providers together within the chosen state scope; the named service-agnostic resource modeling instead handles the requirement to use a common configuration workflow across distinct vendors, so this behavior does not describe Service-agnostic resource modeling in the situation named.

Question 245

A team proposes “A Git HTTPS module source” to retrieve child modules without running the complete backend and provider setup steps. If they proceed with that technique, which result should they anticipate instead?

  1. A git::https:// source can retrieve a Terraform module from version control rather than from the module registry.
  2. The terraform get command updates downloaded module sources only; routine workflows generally prefer terraform init.
  3. Published module documentation and metadata describe the module interface and help consumers understand required arguments.
  4. Terraform can load a module from a local filesystem path, though absolute paths make configurations less portable.

Explanation

Correct Answer

A:

A Git HTTPS module source is used when an operator needs to fetch module code directly from a remote Git repository. Consequently, this choice cannot meet the separate requirement to retrieve child modules without running the complete backend and provider setup steps. The intended action would instead require terraform get.

Incorrect Answers

B:

That outcome belongs to terraform get, the mechanism that can retrieve child modules without running the complete backend and provider setup steps. The question concerns the engineer’s actual proposal, A Git HTTPS module source; it is directed at fetch module code directly from a remote Git repository, not that result.

C:

This behavior belongs to Registry module documentation, which helps engineers determine a module's declared inputs, outputs, providers and usage examples rather than satisfying the separate requirement to retrieve child modules without running the complete backend and provider setup steps. The attempted technique was A Git HTTPS module source; it would instead be used to fetch module code directly from a remote Git repository, not to produce the effect associated with Registry module documentation.

D:

This behavior belongs to An absolute local module source, which helps engineers call a child module from an explicit filesystem path rather than satisfying the separate requirement to retrieve child modules without running the complete backend and provider setup steps. The attempted technique was A Git HTTPS module source; it would instead be used to fetch module code directly from a remote Git repository, not to produce the effect associated with An absolute local module source.

Question 246

In a Terraform configuration, what value does the HCL expression flatten([["a", "b"], ["c"]]) evaluate to?

  1. ["a", "b", "c"] (flattened list)
  2. ["a", "c"]
  3. ["c", "a", "b"]
  4. [["a", "b"], ["c"]] (still-nested list)

Explanation

Correct Answer

A:

The expression flatten([["a", "b"], ["c"]]) evaluates to ["a", "b", "c"] because flatten removes the inner list nesting and preserves the sequence of all three strings. This is Terraform's direct evaluation of the supplied literal arguments in flatten([["a", "b"], ["c"]]), not an external provider lookup.

Incorrect Answers

B:

Flatten does not discard b from the first inner list. In this specific evaluation, flatten removes the inner list nesting and preserves the sequence of all three strings, which rules out the proposed alternative.

C:

Flatten traverses nested lists in their input order. HCL evaluates flatten([["a", "b"], ["c"]]) using the supplied arguments: flatten removes the inner list nesting and preserves the sequence of all three strings; the listed result is therefore incorrect.

D:

This is the original nested value before applying flatten. For flatten([["a", "b"], ["c"]]), flatten removes the inner list nesting and preserves the sequence of all three strings; consequently this candidate is not the value Terraform computes.

Question 247

An engineering checklist calls for separate outcomes: (1) confirm deployed outputs and state match the expected result; (2) distinguish style-only issues from Terraform type and schema errors; (3) avoid downloading child modules during a narrowly scoped initialization. Which THREE options implement the requested outcomes? Choose THREE.

  1. Separate plan and apply privileges
  2. Check infrastructure after apply
  3. terraform init -upgrade for modules
  4. terraform init -get=false
  5. Formatting versus validation
  6. Canonical HCL alignment

Explanation

Correct Answers

B:

Following apply, output values and state inspection can reveal created identifiers while a new plan can test for remaining drift; this meets the requirement to confirm deployed outputs and state match the expected result, while the other selected techniques address distinguish style-only issues from Terraform type and schema errors and avoid downloading child modules during a narrowly scoped initialization, which require their own distinct Terraform mechanisms.

D:

The get=false switch skips child module installation, which is generally safe only if module dependencies are already present; this meets the requirement to avoid downloading child modules during a narrowly scoped initialization, while the other selected techniques address confirm deployed outputs and state match the expected result and distinguish style-only issues from Terraform type and schema errors, which require their own distinct Terraform mechanisms.

E:

terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; this meets the requirement to distinguish style-only issues from Terraform type and schema errors, while the other selected techniques address confirm deployed outputs and state match the expected result and avoid downloading child modules during a narrowly scoped initialization, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

Teams can make planning a review step and reserve apply execution for an authorized operator or HCP Terraform run; it addresses require approval before an infrastructure change executes, but this delivery instead requires confirm deployed outputs and state match the expected result and distinguish style-only issues from Terraform type and schema errors and avoid downloading child modules during a narrowly scoped initialization. The required combination involves Check infrastructure after apply and terraform init -get=false and Formatting versus validation, not the behavior of Separate plan and apply privileges.

C:

Upgrade tells init to reconsider prior module selections instead of simply reusing previously installed versions; it addresses fetch newer module releases permitted by version constraints, but this delivery instead requires confirm deployed outputs and state match the expected result and distinguish style-only issues from Terraform type and schema errors and avoid downloading child modules during a narrowly scoped initialization. The required combination involves Check infrastructure after apply and terraform init -get=false and Formatting versus validation, not the behavior of terraform init -upgrade for modules.

F:

The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls; it addresses keep spacing and indentation consistent between developers, but this delivery instead requires confirm deployed outputs and state match the expected result and distinguish style-only issues from Terraform type and schema errors and avoid downloading child modules during a narrowly scoped initialization. The required combination involves Check infrastructure after apply and terraform init -get=false and Formatting versus validation, not the behavior of Canonical HCL alignment.

Question 248

A change request asks an engineer to replace standing cloud keys with short-lived run identities. Which choice best implements the requested behavior?

  1. Run triggers
  2. Organization variable sets
  3. HCP provider dynamic credentials
  4. A restricted private registry

Explanation

Correct Answer

C:

HCP Terraform can use supported dynamic provider credentials that are generated for runs rather than stored as permanent workspace secrets; this directly meets the requirement to replace standing cloud keys with short-lived run identities. By comparison, a restricted private registry is intended to let approved teams discover modules while controlling publication rights, which is a different task from replace standing cloud keys with short-lived run identities.

Incorrect Answers

A:

Run triggers coordinate dependent HCP Terraform workspaces through an event relationship without merging their states; this mechanism is useful when the job is to start downstream workspace runs after upstream workspace changes complete, whereas the current scenario requires the engineer to replace standing cloud keys with short-lived run identities. These operations have different effects in the stated Terraform workflow.

B:

Variable sets let administrators manage common workspace variables centrally and scope them to intended workspaces or projects; this mechanism is useful when the job is to supply shared environment or Terraform input values across several workspaces, whereas the current scenario requires the engineer to replace standing cloud keys with short-lived run identities. These operations have different effects in the stated Terraform workflow.

D:

Registry access and publishing permissions help centralize reusable module governance across teams; this mechanism is useful when the job is to let approved teams discover modules while controlling publication rights, whereas the current scenario requires the engineer to replace standing cloud keys with short-lived run identities. These operations have different effects in the stated Terraform workflow.

Question 249

During a design review, the requirement is to map an existing object's correct remote identifier to a Terraform address. Which option should the engineer select?

  1. Import IDs defined by providers
  2. Serial and lineage checks
  3. A normal plan with drift
  4. terraform state pull

Explanation

Correct Answer

A:

Import commands require the provider-defined identity format, not an arbitrary local Terraform block label; this directly meets the requirement to map an existing object's correct remote identifier to a Terraform address. By comparison, serial and lineage checks is intended to detect that a state snapshot belongs to a different history or older generation, which is a different task from map an existing object's correct remote identifier to a Terraform address.

Incorrect Answers

B:

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 map an existing object's correct remote identifier to a Terraform address. These operations have different effects in the stated Terraform workflow.

C:

Providers refresh remote resource attributes, and planning can propose updates to bring changed objects back to declared configuration; this mechanism is useful when the job is to detect and propose correction for changes made outside Terraform, whereas the current scenario requires the engineer to map an existing object's correct remote identifier to a Terraform address. These operations have different effects in the stated Terraform workflow.

D:

The state pull command retrieves state from the configured backend and prints a snapshot that may contain secrets; this mechanism is useful when the job is to obtain the current state snapshot for inspection or controlled backup, whereas the current scenario requires the engineer to map an existing object's correct remote identifier to a Terraform address. These operations have different effects in the stated Terraform workflow.

Question 250

A team compares Terraform mechanisms for the goal to catch a resource block lacking a mandatory argument. Which stated consequence belongs specifically to “Missing required argument detection”?

  1. Variable validation conditions evaluate against actual values when Terraform processes inputs, which is different from only checking syntax.
  2. Validation compares configuration with provider schemas and reports missing required fields.
  3. The validate command checks syntax and schema consistency in an initialized configuration without obtaining a full execution plan.
  4. Because validate consults provider and module definitions, run init first to install referenced dependencies.
  5. terraform validate runs offline-oriented configuration checks and does not deploy managed resources.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to catch a resource block lacking a mandatory argument, so it produces the behavior described. In contrast, validate after init serves a different goal: resolve missing provider schemas before checking configuration, not catch a resource block lacking a mandatory argument.

Incorrect Answers

A:

The description applies to variable validation during planning when an engineer needs to reject a supplied input value that violates a custom validation rule; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

C:

The description applies to terraform validate when an engineer needs to check that Terraform configuration is structurally valid without planning resource changes; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

D:

The description applies to validate after init when an engineer needs to resolve missing provider schemas before checking configuration; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

E:

The description applies to validate without live deployment when an engineer needs to detect invalid configuration even when no cloud changes should occur; the named missing required argument detection instead handles the requirement to catch a resource block lacking a mandatory argument, so this behavior does not describe Missing required argument detection in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests