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

Question 380

An infrastructure repository handles database passwords and tokens. A reviewer must determine how to avoid leaking inputs and backend information through CI downloads. Which action is the appropriate choice?

  1. Use short-lived cloud identities for automation
  2. Avoid unnecessary nonsensitive(...) calls
  3. Distinguish ephemeral from sensitive
  4. Mark a secret root output sensitive = true
  5. Treat saved plan files as sensitive artifacts

Explanation

Correct Answer

E:

Binary plans can preserve configuration values and secrets; redaction in human-readable output does not make the saved plan safe to publish; this behavior should be assessed against the concrete need to avoid leaking inputs and backend information through CI downloads. This directly supports the task to avoid leaking inputs and backend information through CI downloads during a cross-team handoff.

Incorrect Answers

A:

Dynamic provider credentials or workload federation can issue bounded run-specific authorization; this limits blast radius while still requiring correct API permissions; this behavior should be assessed against the concrete need to avoid leaking inputs and backend information through CI downloads. The distinction matters here: using that mechanism to reduce dependence on hardcoded long-lived API keys would still leave the objective to avoid leaking inputs and backend information through CI downloads unmet.

B:

Nonsensitive removes the sensitivity mark from a value; it does not erase the underlying secret and can expose it in outputs or logs; this behavior should be assessed against the concrete need to avoid leaking inputs and backend information through CI downloads. It may support a related workflow, but the question specifically requires the mechanism for avoid leaking inputs and backend information through CI downloads rather than preserve Terraform's safety indicator for secret-bearing expressions.

C:

Sensitive marks affect presentation; ephemeral marks constrain persistence and permitted expression contexts; they solve related but nonidentical problems; this behavior should be assessed against the concrete need to avoid leaking inputs and backend information through CI downloads. The stated requirement is to avoid leaking inputs and backend information through CI downloads, not to choose secrecy controls based on persistence as well as output redaction; this alternative addresses a different control or phase.

D:

Output sensitivity masks typical CLI views; authorized state readers and certain machine-readable commands may still reveal the value; this behavior should be assessed against the concrete need to avoid leaking inputs and backend information through CI downloads. That can be useful when the aim is to avoid normal display of an output carrying sensitive data, but it does not directly deliver the requested ability to avoid leaking inputs and backend information through CI downloads.

Question 381

An engineer is deciding whether Terraform should own an existing object. Two independent changes are requested: first, make intentional destruction part of Terraform's lifecycle model; second, direct API operations and lookups to the intended account or region. Which pair of measures fulfills both?

  1. Understand data source failure on a missing object + Use provider selection on both resource and data blocks
  2. Select resource instead of data when deletion must be managed + Keep a data lookup separate from a same-object managed declaration
  3. Select resource instead of data when deletion must be managed + Use provider selection on both resource and data blocks
  4. Query an existing object with data + Read data sources during planning when inputs are known

Explanation

Correct Answer

C:

For the first criterion, a data source never directs Terraform to delete the looked-up object; lifecycle ownership requires a managed declaration or an adopted resource; this behavior should be assessed against the concrete need to make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region; this directly addresses the need to make intentional destruction part of Terraform's lifecycle model. For the separate second criterion, provider aliases control where the relevant API call is sent; a data source without an explicit alias may query the default context even when a nearby resource uses an alternate one; this behavior should be assessed against the concrete need to make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region; this fulfills the need to direct API operations and lookups to the intended account or region. Together they cover the independent tasks of make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the direct API operations and lookups to the intended account or region requirement, but the first is designed for another concern: Many provider data sources require a matching remote object and report an error when none exists; terraform does not create a replacement solely because the data block is present; this behavior should be assessed against the concrete need to make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region. That first component is designed to distinguish a failed lookup from a request to create the missing object, which does not accomplish the requested task to make intentional destruction part of Terraform's lifecycle model, even though the other measure satisfies direct API operations and lookups to the intended account or region.

B:

The first measure meets the requirement to make intentional destruction part of Terraform's lifecycle model, but its partner serves a different role: A data source can read attributes but does not change who owns the underlying object; managing and reading one object need careful dependency design to avoid deferred or inconsistent reads; this behavior should be assessed against the concrete need to make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region. That second component is designed to avoid mistaking two views of one API object for independent resources, so the still-missing criterion is to direct API operations and lookups to the intended account or region, while the first criterion remains make intentional destruction part of Terraform's lifecycle model.

D:

The first measure is intended to read an object without asking Terraform to create or manage it: Data sources ask providers to fetch properties; they do not make Terraform responsible for deleting or updating the queried object; this behavior should be assessed against the concrete need to make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region. The second measure is intended to retrieve remote information for evaluating the proposed change: Terraform normally asks the provider to read data sources during a plan; reads may be deferred when inputs or dependent changes are not yet known; this behavior should be assessed against the concrete need to make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region. Neither is the directly designated method for the separate goals of make intentional destruction part of Terraform's lifecycle model and direct API operations and lookups to the intended account or region in this review.

Question 382

During a deployment checklist, one task is to let Terraform infer safe operation order through data flow, while another is to avoid assuming every computed attribute is fixed during planning. Select the matching pair of techniques.

  1. Use each.key in for_each blocks + Use resource_type.name.attribute
  2. Use output to expose child internals intentionally + Understand values unknown until apply
  3. Use direct attribute references to create implicit dependencies + Understand values unknown until apply
  4. Use direct attribute references to create implicit dependencies + Use data.type.name.attribute

Explanation

Correct Answer

C:

For the first criterion, a resource that consumes another's attribute implicitly depends on it; explicit depends_on is unnecessary when the reference already captures the ordering need; this behavior should be assessed against the concrete need to let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning; this directly addresses the need to let Terraform infer safe operation order through data flow. For the separate second criterion, terraform can propagate unknown values through expressions and defer dependent evaluations; unknown does not necessarily mean the configuration is invalid; this behavior should be assessed against the concrete need to let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning; this fulfills the need to avoid assuming every computed attribute is fixed during planning. Together they cover the independent tasks of let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to identify the stable key of the current map or set instance: Keys form instance addresses such as resource.name["blue"]; the key is not the same as a numeric count.index; this behavior should be assessed against the concrete need to let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning. The second measure is intended to read a named attribute from a managed resource: The expression resolves through the address and provider schema; terraform sees the dependency and can wait for an unknown computed value until apply; this behavior should be assessed against the concrete need to let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning. Neither is the directly designated method for the separate goals of let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning in this review.

B:

The second measure does meet the avoid assuming every computed attribute is fixed during planning requirement, but the first is designed for another concern: An output value makes selected internal attributes available as module.name.output; child resources themselves remain encapsulated behind the module boundary; this behavior should be assessed against the concrete need to let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning. That first component is designed to create a stable boundary for modules that callers depend on, which does not accomplish the requested task to let Terraform infer safe operation order through data flow, even though the other measure satisfies avoid assuming every computed attribute is fixed during planning.

D:

The first measure meets the requirement to let Terraform infer safe operation order through data flow, but its partner serves a different role: The data. prefix selects a read-only lookup namespace; without the prefix Terraform would interpret the address as a managed resource; this behavior should be assessed against the concrete need to let Terraform infer safe operation order through data flow and avoid assuming every computed attribute is fixed during planning. That second component is designed to retrieve an attribute of a declared data source, so the still-missing criterion is to avoid assuming every computed attribute is fixed during planning, while the first criterion remains let Terraform infer safe operation order through data flow.

Question 383

A reviewer has to approve a two-part design: avoid reading a root input directly from an unrelated child module; additionally, obtain structured output values in scripts. Which option pairs the correct mechanisms?

  1. Recognize variable scope is per module + Mark a sensitive output sensitive = true
  2. Set default for an optional configuration input + Define output for a root result
  3. Mark a variable sensitive = true + Use terraform output -json for machine-readable results
  4. Recognize variable scope is per module + Use terraform output -json for machine-readable results

Explanation

Correct Answer

D:

For the first criterion, a child declares its own inputs and receives values in the module call; variables do not automatically become global across the module tree; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts; this directly addresses the need to avoid reading a root input directly from an unrelated child module. For the separate second criterion, jSON mode includes values and sensitivity metadata; downstream tooling must treat sensitive data carefully; this command reads recorded outputs, not arbitrary provider API properties; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts; this fulfills the need to obtain structured output values in scripts. Together they cover the independent tasks of avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to avoid reading a root input directly from an unrelated child module, but its partner serves a different role: Sensitive outputs are redacted in typical CLI presentation but remain recoverable from state by authorized readers; a root output is not secure secret storage; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts. That second component is designed to avoid showing a secret output value in normal human-readable CLI displays, so the still-missing criterion is to obtain structured output values in scripts, while the first criterion remains avoid reading a root input directly from an unrelated child module.

B:

The first measure is intended to supply a fallback when the caller omits the variable: A default provides a value without per-run input; a caller can still override it using a supported variable assignment mechanism; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts. The second measure is intended to expose a selected computed value after provisioning: Outputs provide a documented interface for command output and automation; they can be inspected with terraform output when recorded in state; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts. Neither is the directly designated method for the separate goals of avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts in this review.

C:

The second measure does meet the obtain structured output values in scripts requirement, but the first is designed for another concern: The mark affects display and propagation of sensitivity; ordinary sensitive values may still be persisted in state and saved plans; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module and obtain structured output values in scripts. That first component is designed to suppress ordinary disclosure of a secret in Terraform output, which does not accomplish the requested task to avoid reading a root input directly from an unrelated child module, even though the other measure satisfies obtain structured output values in scripts.

Question 384

A Terraform rollout has separate acceptance criteria: enforce uniqueness without relying on list positions and specify a named record with different attribute types. Which combined approach directly satisfies the two criteria?

  1. Use set(string) for unique unordered strings + Use object({ name = string, enabled = bool })
  2. Use set(string) for unique unordered strings + Convert values with tolist(...)
  3. Use tuple([string, number]) + Use structural object attributes in module interfaces
  4. Access a map with var.tags["owner"] + Use object({ name = string, enabled = bool })

Explanation

Correct Answer

A:

For the first criterion, sets discard duplicate elements and are not an ordered sequence; this changes instance-key considerations if used with for_each; this behavior should be assessed against the concrete need to enforce uniqueness without relying on list positions and specify a named record with different attribute types; this directly addresses the need to enforce uniqueness without relying on list positions. For the separate second criterion, an object defines an exact attribute schema rather than a homogeneous map; terraform checks and may convert compatible input shapes to that contract; this behavior should be assessed against the concrete need to enforce uniqueness without relying on list positions and specify a named record with different attribute types; this fulfills the need to specify a named record with different attribute types. Together they cover the independent tasks of enforce uniqueness without relying on list positions and specify a named record with different attribute types without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure meets the requirement to enforce uniqueness without relying on list positions, but its partner serves a different role: The conversion yields a list but an unordered source set may produce an arbitrary order; do not use it to promise stable positions for set elements; this behavior should be assessed against the concrete need to enforce uniqueness without relying on list positions and specify a named record with different attribute types. That second component is designed to produce a list value when a downstream expression requires list semantics, so the still-missing criterion is to specify a named record with different attribute types, while the first criterion remains enforce uniqueness without relying on list positions.

C:

The first measure is intended to define a fixed-position sequence with different element types: Tuples have a declared type for each position; a list(string) would not preserve the intended mixed-element contract; this behavior should be assessed against the concrete need to enforce uniqueness without relying on list positions and specify a named record with different attribute types. The second measure is intended to validate required properties rather than accepting arbitrary untyped maps: A typed object can express nested requirements clearly; it improves errors when a caller omits a field or supplies an incompatible value; this behavior should be assessed against the concrete need to enforce uniqueness without relying on list positions and specify a named record with different attribute types. Neither is the directly designated method for the separate goals of enforce uniqueness without relying on list positions and specify a named record with different attribute types in this review.

D:

The second measure does meet the specify a named record with different attribute types requirement, but the first is designed for another concern: Bracket indexing selects an entry by key; a numeric list index such as [0] is not a substitute for a map key; this behavior should be assessed against the concrete need to enforce uniqueness without relying on list positions and specify a named record with different attribute types. That first component is designed to read a string-keyed collection value, which does not accomplish the requested task to enforce uniqueness without relying on list positions, even though the other measure satisfies specify a named record with different attribute types.

Question 385

A developer is transforming collection values. The team must both create every ordered combination across two input collections and require zero or one element and extract the single element when present. Which paired choice implements those distinct goals?

  1. Use setproduct(a, b) + Use alltrue(list_of_bools)
  2. Use concat(list1, list2) + Use one(collection)
  3. Use setproduct(a, b) + Use one(collection)
  4. Use merge(map1, map2) + Use a splat expression items[*].id

Explanation

Correct Answer

C:

For the first criterion, setproduct computes the Cartesian product, useful for pairing environments and roles; it is not an alternative to the resource dependency graph; this behavior should be assessed against the concrete need to create every ordered combination across two input collections and require zero or one element and extract the single element when present; this directly addresses the need to create every ordered combination across two input collections. For the separate second criterion, one returns the element or null for an empty collection, and errors on more than one; it is useful for conditional singleton resources; this behavior should be assessed against the concrete need to create every ordered combination across two input collections and require zero or one element and extract the single element when present; this fulfills the need to require zero or one element and extract the single element when present. Together they cover the independent tasks of create every ordered combination across two input collections and require zero or one element and extract the single element when present without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to create every ordered combination across two input collections, but its partner serves a different role: Alltrue is useful for validating all entries in an input list; anytrue instead tests whether at least one entry succeeds; this behavior should be assessed against the concrete need to create every ordered combination across two input collections and require zero or one element and extract the single element when present. That second component is designed to require every evaluated Boolean in a collection to be true, so the still-missing criterion is to require zero or one element and extract the single element when present, while the first criterion remains create every ordered combination across two input collections.

B:

The second measure does meet the require zero or one element and extract the single element when present requirement, but the first is designed for another concern: Concat combines lists or tuples into one sequence; it does not remove duplicates as a set conversion would; this behavior should be assessed against the concrete need to create every ordered combination across two input collections and require zero or one element and extract the single element when present. That first component is designed to append sequences while retaining element order, which does not accomplish the requested task to create every ordered combination across two input collections, even though the other measure satisfies require zero or one element and extract the single element when present.

D:

The first measure is intended to combine maps with later arguments overriding duplicate keys: Merge returns one map/object composed from inputs; it does not concatenate list elements or destroy original remote objects; this behavior should be assessed against the concrete need to create every ordered combination across two input collections and require zero or one element and extract the single element when present. The second measure is intended to collect the same attribute from every list-like object: The [*] form is concise for sequences; map-valued for_each resources usually require a for expression instead; this behavior should be assessed against the concrete need to create every ordered combination across two input collections and require zero or one element and extract the single element when present. Neither is the directly designated method for the separate goals of create every ordered combination across two input collections and require zero or one element and extract the single element when present in this review.

Question 386

A Terraform review distinguishes lifecycle safeguards from graph edges. The requirement is to break mutual dependencies that prevent Terraform from ordering operations. Which Terraform mechanism directly meets this requirement?

  1. Use ignore_changes = [tags]
  2. Avoid a circular dependency graph
  3. Use graph parallelism for independent resources
  4. Use prevent_destroy = true on a configured resource
  5. Use replace_triggered_by rather than depends_on for forced rebuilding

Explanation

Correct Answer

B:

Terraform cannot schedule a true cycle in its directed acyclic graph; rearranging references or splitting resource responsibilities can remove the cycle; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations. This directly supports the task to break mutual dependencies that prevent Terraform from ordering operations during a planned migration.

Incorrect Answers

A:

Ignore-changes permits another process to adjust specified fields without Terraform constantly reverting them; it does not ignore creation-time arguments; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations. That can be useful when the aim is to exclude selected post-creation attribute differences from update planning, but it does not directly deliver the requested ability to break mutual dependencies that prevent Terraform from ordering operations.

C:

Terraform can schedule independent graph nodes in parallel within its configured limit; artificial dependencies reduce parallel execution; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations. It may support a related workflow, but the question specifically requires the mechanism for break mutual dependencies that prevent Terraform from ordering operations rather than allow unrelated operations to proceed concurrently.

D:

This is a lifecycle safety check, not a remote deletion-protection feature; removing the resource block also removes the rule from consideration; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations. The stated requirement is to break mutual dependencies that prevent Terraform from ordering operations, not to fail a plan that would destroy the protected resource while its block remains; this alternative addresses a different control or phase.

E:

A dependency establishes when work runs; it does not by itself demand a replacement of an unchanged dependent object; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations. That can be useful when the aim is to differentiate operation ordering from replacement semantics, but it does not directly deliver the requested ability to break mutual dependencies that prevent Terraform from ordering operations.

Question 387

During a module implementation, one task is to ensure a module only exposes results that satisfy a contract, while another is to express the Boolean invariant and its diagnostic message. Select the matching pair of techniques.

  1. Use can(regex(...)) in validation + Use a resource precondition
  2. Use an output precondition + Distinguish terraform validate from in-configuration conditions
  3. Use a resource postcondition + Use assert { condition = ... } inside check
  4. Use a check block with assertions + Use assert { condition = ... } inside check
  5. Use an output precondition + Use assert { condition = ... } inside check

Explanation

Correct Answer

E:

For the first criterion, output preconditions can check values or dependencies before the output is finalized; they keep exported data subject to explicit guarantees; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message; this directly addresses the need to ensure a module only exposes results that satisfy a contract. For the separate second criterion, an assert block carries the condition and explanatory error text for a named check; it is not a normal managed resource declaration; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message; this fulfills the need to express the Boolean invariant and its diagnostic message. Together they cover the independent tasks of ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to test a string against a pattern without crashing on a nonmatch: Regex can raise an error when no match exists; can converts that evaluability into a Boolean; it makes a precise input-validation rule possible; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message. The second measure is intended to verify an assumption before Terraform processes the target resource operation: A lifecycle precondition can inspect values needed for a safe operation; failure blocks proceeding instead of simply recording a health warning; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message. Neither is the directly designated method for the separate goals of ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message in this review.

B:

The first measure meets the requirement to ensure a module only exposes results that satisfy a contract, but its partner serves a different role: The CLI validation command checks configuration consistency; custom conditions examine values and guarantees at relevant evaluation phases; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message. That second component is designed to separate structural HCL checking from runtime assertions, so the still-missing criterion is to express the Boolean invariant and its diagnostic message, while the first criterion remains ensure a module only exposes results that satisfy a contract.

C:

The second measure does meet the express the Boolean invariant and its diagnostic message requirement, but the first is designed for another concern: A lifecycle postcondition checks an expected guarantee and can prevent dependent operations when it fails; it differs from a pre-operation assumption; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message. That first component is designed to verify a property after the relevant resource or data evaluation, which does not accomplish the requested task to ensure a module only exposes results that satisfy a contract, even though the other measure satisfies express the Boolean invariant and its diagnostic message.

D:

The second measure does meet the express the Boolean invariant and its diagnostic message requirement, but the first is designed for another concern: Checks are designed for nonblocking validation and can report warnings during plan/apply; critical prerequisites belong in blocking custom conditions; this behavior should be assessed against the concrete need to ensure a module only exposes results that satisfy a contract and express the Boolean invariant and its diagnostic message. That first component is designed to monitor an infrastructure invariant and report failed checks without blocking the whole operation, which does not accomplish the requested task to ensure a module only exposes results that satisfy a contract, even though the other measure satisfies express the Boolean invariant and its diagnostic message.

Question 388

The immediate Terraform task is to avoid normal display of an output carrying sensitive data. Which method handles that task most directly?

  1. Rotate credentials after suspected disclosure
  2. Mark a secret root output sensitive = true
  3. Avoid committing secret .tfvars values
  4. Mark a variable sensitive = true
  5. Distinguish ephemeral from sensitive

Explanation

Correct Answer

B:

Output sensitivity masks typical CLI views; authorized state readers and certain machine-readable commands may still reveal the value; this behavior should be assessed against the concrete need to avoid normal display of an output carrying sensitive data. This directly supports the task to avoid normal display of an output carrying sensitive data during a platform review.

Incorrect Answers

A:

Removing a line from code does not revoke already exposed tokens; credential rotation and cleanup of historical artifacts are separate security steps; this behavior should be assessed against the concrete need to avoid normal display of an output carrying sensitive data. It may support a related workflow, but the question specifically requires the mechanism for avoid normal display of an output carrying sensitive data rather than reduce risk when secrets were written to state or repository history.

C:

Input files can contain plaintext and are often copied to laptops and CI systems; store sensitive values in a managed secret store or protected execution environment instead; this behavior should be assessed against the concrete need to avoid normal display of an output carrying sensitive data. That can be useful when the aim is to prevent credentials from entering source history, but it does not directly deliver the requested ability to avoid normal display of an output carrying sensitive data.

D:

Sensitivity propagates through expressions and hides values in many UI contexts; it does not, by itself, keep the original secret out of state or saved plan files; this behavior should be assessed against the concrete need to avoid normal display of an output carrying sensitive data. The distinction matters here: using that mechanism to hide a secret from ordinary CLI displays would still leave the objective to avoid normal display of an output carrying sensitive data unmet.

E:

Sensitive marks affect presentation; ephemeral marks constrain persistence and permitted expression contexts; they solve related but nonidentical problems; this behavior should be assessed against the concrete need to avoid normal display of an output carrying sensitive data. It may support a related workflow, but the question specifically requires the mechanism for avoid normal display of an output carrying sensitive data rather than choose secrecy controls based on persistence as well as output redaction.

Question 389

During a deployment checklist, one task is to avoid mistaking two views of one API object for independent resources, while another is to distinguish a failed lookup from a request to create the missing object. Select the matching pair of techniques.

  1. Recognize terraform_data as a built-in managed resource + Read data sources during planning when inputs are known
  2. Keep a data lookup separate from a same-object managed declaration + Understand data source failure on a missing object
  3. Declare a managed object with resource + Understand data source failure on a missing object
  4. Keep a data lookup separate from a same-object managed declaration + Use an ephemeral resource for supported temporary data

Explanation

Correct Answer

B:

For the first criterion, a data source can read attributes but does not change who owns the underlying object; managing and reading one object need careful dependency design to avoid deferred or inconsistent reads; this behavior should be assessed against the concrete need to avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object; this directly addresses the need to avoid mistaking two views of one API object for independent resources. For the separate second criterion, many provider data sources require a matching remote object and report an error when none exists; terraform does not create a replacement solely because the data block is present; this behavior should be assessed against the concrete need to avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object; this fulfills the need to distinguish a failed lookup from a request to create the missing object. Together they cover the independent tasks of avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to store arbitrary values or trigger replacements without a third-party resource API: The built-in Terraform provider supplies this resource for lifecycle-oriented uses; it is not a general substitute for querying arbitrary cloud objects; this behavior should be assessed against the concrete need to avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object. The second measure is intended to retrieve remote information for evaluating the proposed change: Terraform normally asks the provider to read data sources during a plan; reads may be deferred when inputs or dependent changes are not yet known; this behavior should be assessed against the concrete need to avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object. Neither is the directly designated method for the separate goals of avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object in this review.

C:

The second measure does meet the distinguish a failed lookup from a request to create the missing object requirement, but the first is designed for another concern: A resource block is part of the desired managed infrastructure; terraform tracks its remote identity in state and may create, update, replace, or destroy it; this behavior should be assessed against the concrete need to avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object. That first component is designed to ask Terraform to own the lifecycle of a remote object, which does not accomplish the requested task to avoid mistaking two views of one API object for independent resources, even though the other measure satisfies distinguish a failed lookup from a request to create the missing object.

D:

The first measure meets the requirement to avoid mistaking two views of one API object for independent resources, but its partner serves a different role: Ephemeral resources are available for supported providers and valid contexts; they are not ordinary managed resources with persistent state identity; this behavior should be assessed against the concrete need to avoid mistaking two views of one API object for independent resources and distinguish a failed lookup from a request to create the missing object. That second component is designed to obtain a short-lived value without persisting it in state or plan, so the still-missing criterion is to distinguish a failed lookup from a request to create the missing object, while the first criterion remains avoid mistaking two views of one API object for independent resources.

Question 390

The immediate Terraform task is to reference a computed local value in the same module. Which method handles that task most directly?

  1. Use output to expose child internals intentionally
  2. Use a for expression over a resource map
  3. Use local.prefix
  4. Use direct attribute references to create implicit dependencies

Explanation

Correct Answer

C:

Local expressions help avoid repeating calculations; each module has its own local namespace; callers cannot directly inspect a child's locals; this behavior should be assessed against the concrete need to reference a computed local value in the same module. This directly supports the task to reference a computed local value in the same module during a configuration change.

Incorrect Answers

A:

An output value makes selected internal attributes available as module.name.output; child resources themselves remain encapsulated behind the module boundary; this behavior should be assessed against the concrete need to reference a computed local value in the same module. The distinction matters here: using that mechanism to create a stable boundary for modules that callers depend on would still leave the objective to reference a computed local value in the same module unmet.

B:

A map-oriented expression can iterate keys and values to build a list or map; a legacy list-style splat is not the right accessor for a for_each resource map; this behavior should be assessed against the concrete need to reference a computed local value in the same module. It may support a related workflow, but the question specifically requires the mechanism for reference a computed local value in the same module rather than extract values from instances created with for_each.

D:

A resource that consumes another's attribute implicitly depends on it; explicit depends_on is unnecessary when the reference already captures the ordering need; this behavior should be assessed against the concrete need to reference a computed local value in the same module. That can be useful when the aim is to let Terraform infer safe operation order through data flow, but it does not directly deliver the requested ability to reference a computed local value in the same module.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests