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

Question 410

A Terraform rollout has separate acceptance criteria: break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on. Which combined approach directly satisfies the two criteria?

  1. Avoid a circular dependency graph + Understand destroy order as dependency-aware
  2. Avoid a circular dependency graph + Use explicit dependencies on module calls carefully
  3. Use graph parallelism for independent resources + Understand destroy order as dependency-aware
  4. Recognize lifecycle arguments are evaluated early + Use replace_triggered_by for resource change coupling

Explanation

Correct Answer

A:

For the first criterion, 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 and remove dependents before the infrastructure they rely on; this directly addresses the need to break mutual dependencies that prevent Terraform from ordering operations. For the separate second criterion, terraform generally reverses dependency order for teardown; this minimizes failures caused by destroying prerequisites too early; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on; this fulfills the need to remove dependents before the infrastructure they rely on. Together they cover the independent tasks of break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure meets the requirement to break mutual dependencies that prevent Terraform from ordering operations, but its partner serves a different role: depends_on on a module applies to the module's relevant actions, not just one output; it may be broader than a targeted output reference; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on. That second component is designed to delay all operations in a child module until required prerequisites complete, so the still-missing criterion is to remove dependents before the infrastructure they rely on, while the first criterion remains break mutual dependencies that prevent Terraform from ordering operations.

C:

The second measure does meet the remove dependents before the infrastructure they rely on requirement, but the first is designed for another concern: 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 and remove dependents before the infrastructure they rely on. That first component is designed to allow unrelated operations to proceed concurrently, which does not accomplish the requested task to break mutual dependencies that prevent Terraform from ordering operations, even though the other measure satisfies remove dependents before the infrastructure they rely on.

D:

The first measure is intended to avoid dynamic expressions for create_before_destroy and similar rules: These lifecycle settings shape the graph construction stage and typically require literal values; a runtime input cannot freely toggle them as ordinary arguments; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on. The second measure is intended to replace a resource when another managed resource or attribute changes: The rule ties replacement to planned actions on managed resources; plain local values do not themselves have planned resource actions; this behavior should be assessed against the concrete need to break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on. Neither is the directly designated method for the separate goals of break mutual dependencies that prevent Terraform from ordering operations and remove dependents before the infrastructure they rely on in this review.

Question 411

An engineer needs to express the Boolean invariant and its diagnostic message as part of a planned migration. Which option is the best fit?

  1. Use a variable validation block
  2. Use a resource precondition
  3. Use assert { condition = ... } inside check
  4. Use alltrue over transformed entries

Explanation

Correct Answer

C:

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 express the Boolean invariant and its diagnostic message. This directly supports the task to express the Boolean invariant and its diagnostic message during a maintenance request.

Incorrect Answers

A:

A variable validation condition evaluates to a Boolean and reports the specified error when false; it sets the input contract independently of provider API permissions; this behavior should be assessed against the concrete need to express the Boolean invariant and its diagnostic message. It may support a related workflow, but the question specifically requires the mechanism for express the Boolean invariant and its diagnostic message rather than reject a malformed module input with a custom message.

B:

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 express the Boolean invariant and its diagnostic message. The stated requirement is to express the Boolean invariant and its diagnostic message, not to verify an assumption before Terraform processes the target resource operation; this alternative addresses a different control or phase.

D:

Combining a for expression with alltrue yields a single Boolean input contract; it is not the same as testing only the first list element; this behavior should be assessed against the concrete need to express the Boolean invariant and its diagnostic message. The distinction matters here: using that mechanism to validate every element of a collection against one rule would still leave the objective to express the Boolean invariant and its diagnostic message unmet.

Question 412

A Terraform team is hardening secret management. Two independent changes are requested: first, send a secret to a managed resource without storing its value in plan or state; second, retrieve or distribute sensitive credentials under explicit access policy. Which pair of measures fulfills both?

  1. Mark a variable sensitive = true + Use Vault to centralize secret access
  2. Use a provider-supported write-only argument + Treat saved plan files as sensitive artifacts
  3. Use environment-based provider authentication when supported + Use Vault to centralize secret access
  4. Protect access to remote state + Mark a variable ephemeral = true
  5. Use a provider-supported write-only argument + Use Vault to centralize secret access

Explanation

Correct Answer

E:

For the first criterion, write-only arguments exist only where the provider schema supports them; they are available in Terraform 1.11+, including the tested 1.12 release; this behavior should be assessed against the concrete need to send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy; this directly addresses the need to send a secret to a managed resource without storing its value in plan or state. For the separate second criterion, vault provides secret-management and credential capabilities; its Terraform provider can integrate with Vault APIs, but ordinary read results may still be recorded unless ephemeral patterns are used; this behavior should be assessed against the concrete need to send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy; this fulfills the need to retrieve or distribute sensitive credentials under explicit access policy. Together they cover the independent tasks of send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the retrieve or distribute sensitive credentials under explicit access policy requirement, but the first is designed for another concern: 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 send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy. That first component is designed to hide a secret from ordinary CLI displays, which does not accomplish the requested task to send a secret to a managed resource without storing its value in plan or state, even though the other measure satisfies retrieve or distribute sensitive credentials under explicit access policy.

B:

The first measure meets the requirement to send a secret to a managed resource without storing its value in plan or state, but its partner serves a different role: 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 send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy. That second component is designed to avoid leaking inputs and backend information through CI downloads, so the still-missing criterion is to retrieve or distribute sensitive credentials under explicit access policy, while the first criterion remains send a secret to a managed resource without storing its value in plan or state.

C:

The second measure does meet the retrieve or distribute sensitive credentials under explicit access policy requirement, but the first is designed for another concern: Many providers support environment variables or workload identity; this lowers credential exposure in source but still requires secure runtime injection; this behavior should be assessed against the concrete need to send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy. That first component is designed to avoid embedding long-lived credentials in HCL provider blocks, which does not accomplish the requested task to send a secret to a managed resource without storing its value in plan or state, even though the other measure satisfies retrieve or distribute sensitive credentials under explicit access policy.

D:

The first measure is intended to secure resource attributes and possibly persisted secrets: A remote backend may encrypt stored state and enforce access controls; terraform sensitive annotations do not replace backend security; this behavior should be assessed against the concrete need to send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy. The second measure is intended to omit short-lived input values from state and plan artifacts: Ephemeral values have restricted usable contexts such as provider configuration and write-only arguments; they are appropriate for transient tokens that must not be persisted; this behavior should be assessed against the concrete need to send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy. Neither is the directly designated method for the separate goals of send a secret to a managed resource without storing its value in plan or state and retrieve or distribute sensitive credentials under explicit access policy in this review.

Question 413

An engineer needs to use an attribute returned by a provider data source as part of an automated release. Which option is the best fit?

  1. Declare a managed object with resource
  2. Use a resource block together with an import block
  3. Reference data.aws_ami.base.id for a lookup
  4. Use an ephemeral resource for supported temporary data

Explanation

Correct Answer

C:

The data. address prefix distinguishes a read-only lookup from a managed resource address; its value can feed managed resources without importing the looked-up object; this behavior should be assessed against the concrete need to use an attribute returned by a provider data source. This directly supports the task to use an attribute returned by a provider data source during an infrastructure audit.

Incorrect Answers

A:

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 use an attribute returned by a provider data source. The distinction matters here: using that mechanism to ask Terraform to own the lifecycle of a remote object would still leave the objective to use an attribute returned by a provider data source unmet.

B:

Import associates the provider's existing remote object with a declared resource address; simply reading it as a data source does not establish that lifecycle ownership; this behavior should be assessed against the concrete need to use an attribute returned by a provider data source. It may support a related workflow, but the question specifically requires the mechanism for use an attribute returned by a provider data source rather than adopt a previously existing object into Terraform management.

D:

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 use an attribute returned by a provider data source. That can be useful when the aim is to obtain a short-lived value without persisting it in state or plan, but it does not directly deliver the requested ability to use an attribute returned by a provider data source.

Question 414

An HCL review is investigating dependency and reference syntax. The requirement is to identify the stable key of the current map or set instance. Which Terraform mechanism directly meets this requirement?

  1. Use depends_on for hidden ordering requirements
  2. Use module.network.subnet_id
  3. Use local.prefix
  4. Use each.key in for_each blocks

Explanation

Correct Answer

D:

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 identify the stable key of the current map or set instance. This directly supports the task to identify the stable key of the current map or set instance during a planned migration.

Incorrect Answers

A:

Terraform's graph uses the explicit edge even without a data reference; overusing whole-resource dependencies may defer reads and reduce concurrency; this behavior should be assessed against the concrete need to identify the stable key of the current map or set instance. That can be useful when the aim is to declare a relationship that cannot be expressed through an input attribute, but it does not directly deliver the requested ability to identify the stable key of the current map or set instance.

B:

A caller sees child-module outputs rather than arbitrary internal resources; the output also communicates dependencies and can serve as an interface contract; this behavior should be assessed against the concrete need to identify the stable key of the current map or set instance. The distinction matters here: using that mechanism to consume a value explicitly exposed by a child module would still leave the objective to identify the stable key of the current map or set instance unmet.

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 identify the stable key of the current map or set instance. It may support a related workflow, but the question specifically requires the mechanism for identify the stable key of the current map or set instance rather than reference a computed local value in the same module.

Question 415

An application module needs reliable input and output contracts. A reviewer must determine how to avoid showing a secret output value in normal human-readable CLI displays. Which action is the appropriate choice?

  1. Mark an input variable ephemeral = true
  2. Set nullable = false for a required non-null variable
  3. Mark a variable sensitive = true
  4. Mark a sensitive output sensitive = true

Explanation

Correct Answer

D:

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 showing a secret output value in normal human-readable CLI displays. This directly supports the task to avoid showing a secret output value in normal human-readable CLI displays during a cross-team handoff.

Incorrect Answers

A:

Ephemeral inputs have restricted reference contexts such as provider blocks and write-only arguments; sensitivity by itself does not provide the same omission guarantee; this behavior should be assessed against the concrete need to avoid showing a secret output value in normal human-readable CLI displays. The stated requirement is to avoid showing a secret output value in normal human-readable CLI displays, not to prevent a temporary secret from being persisted to state and plan files; this alternative addresses a different control or phase.

B:

The nullable setting controls whether null can be supplied; it is different from a missing default and distinct from sensitive output masking; this behavior should be assessed against the concrete need to avoid showing a secret output value in normal human-readable CLI displays. That can be useful when the aim is to reject explicit null values instead of treating them as ordinary accepted inputs, but it does not directly deliver the requested ability to avoid showing a secret output value in normal human-readable CLI displays.

C:

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 showing a secret output value in normal human-readable CLI displays. The distinction matters here: using that mechanism to suppress ordinary disclosure of a secret in Terraform output would still leave the objective to avoid showing a secret output value in normal human-readable CLI displays unmet.

Question 416

The immediate Terraform task is to collapse a list of lists into one sequence. Which method handles that task most directly?

  1. Recognize map iteration's key ordering
  2. Convert values with toset(...)
  3. Use flatten(...) for nested lists
  4. Use list(string) for ordered strings

Explanation

Correct Answer

C:

Flatten recursively reduces nested list/tuple containers while preserving the flattened order; it does not merge map attributes; this behavior should be assessed against the concrete need to collapse a list of lists into one sequence. This directly supports the task to collapse a list of lists into one sequence during a platform review.

Incorrect Answers

A:

When Terraform converts map elements into an ordered result, it sorts keys lexically; this differs from an explicitly ordered input list; this behavior should be assessed against the concrete need to collapse a list of lists into one sequence. It may support a related workflow, but the question specifically requires the mechanism for collapse a list of lists into one sequence rather than avoid interpreting maps as insertion-ordered sequences.

B:

Conversion is useful for stable for_each string keys; it is not equivalent to preserving the original list order; this behavior should be assessed against the concrete need to collapse a list of lists into one sequence. The stated requirement is to collapse a list of lists into one sequence, not to remove duplicates and produce set semantics for iteration; this alternative addresses a different control or phase.

D:

Lists have elements of one element type and maintain order; they are appropriate when resource arguments expect an ordered collection; this behavior should be assessed against the concrete need to collapse a list of lists into one sequence. The distinction matters here: using that mechanism to preserve a sequence in which position and duplicates may matter would still leave the objective to collapse a list of lists into one sequence unmet.

Question 417

A Terraform rollout has separate acceptance criteria: build a string using a controlled formatting pattern and substitute matching text or patterns in a string. Which combined approach directly satisfies the two criteria?

  1. Use format("%s-%d", name, number) + Use [for item in items : item.name]
  2. Use format("%s-%d", name, number) + Use replace(text, old, new)
  3. Use coalesce(a, b, ...) + Use replace(text, old, new)
  4. Use file(path) to read local text + Use a dynamic block to generate nested blocks

Explanation

Correct Answer

B:

For the first criterion, format substitutes values into placeholders; it does not validate whether the resulting identifier is accepted by a cloud provider; this behavior should be assessed against the concrete need to build a string using a controlled formatting pattern and substitute matching text or patterns in a string; this directly addresses the need to build a string using a controlled formatting pattern. For the separate second criterion, replace performs value transformation during evaluation; it does not trigger replacement of a managed resource by itself; this behavior should be assessed against the concrete need to build a string using a controlled formatting pattern and substitute matching text or patterns in a string; this fulfills the need to substitute matching text or patterns in a string. Together they cover the independent tasks of build a string using a controlled formatting pattern and substitute matching text or patterns in a string without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to build a string using a controlled formatting pattern, but its partner serves a different role: A for expression iterates input elements and constructs values without declaring extra managed resources; it can also filter elements using an if clause; this behavior should be assessed against the concrete need to build a string using a controlled formatting pattern and substitute matching text or patterns in a string. That second component is designed to transform a collection into a derived list, so the still-missing criterion is to substitute matching text or patterns in a string, while the first criterion remains build a string using a controlled formatting pattern.

C:

The second measure does meet the substitute matching text or patterns in a string requirement, but the first is designed for another concern: Coalesce provides a fallback over suitable scalar values; it does not catch arbitrary expression errors like try; this behavior should be assessed against the concrete need to build a string using a controlled formatting pattern and substitute matching text or patterns in a string. That first component is designed to choose the first non-null and nonempty-string value, which does not accomplish the requested task to build a string using a controlled formatting pattern, even though the other measure satisfies substitute matching text or patterns in a string.

D:

The first measure is intended to obtain existing UTF-8 file contents during expression evaluation: File reads files present when evaluation starts; it is not a dependency-aware way to read a file that a resource will create during apply; this behavior should be assessed against the concrete need to build a string using a controlled formatting pattern and substitute matching text or patterns in a string. The second measure is intended to repeat provider-specific nested blocks from a collection: Dynamic blocks create nested configuration blocks, not top-level resources or meta-argument blocks; iteration can use for_each inside the dynamic block; this behavior should be assessed against the concrete need to build a string using a controlled formatting pattern and substitute matching text or patterns in a string. Neither is the directly designated method for the separate goals of build a string using a controlled formatting pattern and substitute matching text or patterns in a string in this review.

Question 418

An engineer needs to avoid dynamic expressions for create_before_destroy and similar rules as part of a planned migration. Which option is the best fit?

  1. Recognize propagated create_before_destroy behavior
  2. Use graph parallelism for independent resources
  3. Recognize lifecycle arguments are evaluated early
  4. Use replace_triggered_by rather than depends_on for forced rebuilding

Explanation

Correct Answer

C:

These lifecycle settings shape the graph construction stage and typically require literal values; a runtime input cannot freely toggle them as ordinary arguments; this behavior should be assessed against the concrete need to avoid dynamic expressions for create_before_destroy and similar rules. This directly supports the task to avoid dynamic expressions for create_before_destroy and similar rules during a maintenance request.

Incorrect Answers

A:

Terraform may propagate create-before-destroy to dependencies and preserve that decision in state; a downstream replacement can therefore affect upstream lifecycle ordering; this behavior should be assessed against the concrete need to avoid dynamic expressions for create_before_destroy and similar rules. That can be useful when the aim is to understand why a dependency may also be retained during a replacement, but it does not directly deliver the requested ability to avoid dynamic expressions for create_before_destroy and similar rules.

B:

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 avoid dynamic expressions for create_before_destroy and similar rules. The distinction matters here: using that mechanism to allow unrelated operations to proceed concurrently would still leave the objective to avoid dynamic expressions for create_before_destroy and similar rules unmet.

D:

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 avoid dynamic expressions for create_before_destroy and similar rules. The stated requirement is to avoid dynamic expressions for create_before_destroy and similar rules, not to differentiate operation ordering from replacement semantics; this alternative addresses a different control or phase.

Question 419

A deployment must validate assumptions or outcomes. Two independent changes are requested: first, test a string against a pattern without crashing on a nonmatch; second, verify a property after the relevant resource or data evaluation. Which pair of measures fulfills both?

  1. Use alltrue over transformed entries + Use an output precondition
  2. Use a variable validation block + Use a resource postcondition
  3. Use can(regex(...)) in validation + Use a resource postcondition
  4. Use can(regex(...)) in validation + Use a precondition rather than a check for an unsafe prerequisite

Explanation

Correct Answer

C:

For the first criterion, 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 test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation; this directly addresses the need to test a string against a pattern without crashing on a nonmatch. For the separate second criterion, 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 test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation; this fulfills the need to verify a property after the relevant resource or data evaluation. Together they cover the independent tasks of test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to validate every element of a collection against one rule: Combining a for expression with alltrue yields a single Boolean input contract; it is not the same as testing only the first list element; this behavior should be assessed against the concrete need to test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation. The second measure is intended to ensure a module only exposes results that satisfy a contract: 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 test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation. Neither is the directly designated method for the separate goals of test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation in this review.

B:

The second measure does meet the verify a property after the relevant resource or data evaluation requirement, but the first is designed for another concern: A variable validation condition evaluates to a Boolean and reports the specified error when false; it sets the input contract independently of provider API permissions; this behavior should be assessed against the concrete need to test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation. That first component is designed to reject a malformed module input with a custom message, which does not accomplish the requested task to test a string against a pattern without crashing on a nonmatch, even though the other measure satisfies verify a property after the relevant resource or data evaluation.

D:

The first measure meets the requirement to test a string against a pattern without crashing on a nonmatch, but its partner serves a different role: Blocking conditions are appropriate when continuing could create invalid infrastructure; a check block typically reports a warning and lets operations proceed; this behavior should be assessed against the concrete need to test a string against a pattern without crashing on a nonmatch and verify a property after the relevant resource or data evaluation. That second component is designed to stop a deployment when a required assumption fails, so the still-missing criterion is to verify a property after the relevant resource or data evaluation, while the first criterion remains test a string against a pattern without crashing on a nonmatch.

Question 420

A reviewer is comparing redaction, ephemeral values, and state protection. A reviewer must determine how to reduce risk when secrets were written to state or repository history. Which action is the appropriate choice?

  1. Treat saved plan files as sensitive artifacts
  2. Distinguish ephemeral from sensitive
  3. Rotate credentials after suspected disclosure
  4. Use an ephemeral resource to retrieve supported temporary secrets
  5. Use a provider-supported write-only argument

Explanation

Correct Answer

C:

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 reduce risk when secrets were written to state or repository history. This directly supports the task to reduce risk when secrets were written to state or repository history during a staged rollout.

Incorrect Answers

A:

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 reduce risk when secrets were written to state or repository history. It may support a related workflow, but the question specifically requires the mechanism for reduce risk when secrets were written to state or repository history rather than avoid leaking inputs and backend information through CI downloads.

B:

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 reduce risk when secrets were written to state or repository history. The stated requirement is to reduce risk when secrets were written to state or repository history, not to choose secrecy controls based on persistence as well as output redaction; this alternative addresses a different control or phase.

D:

Ephemeral resources avoid persisting their results in Terraform's normal state and plan artifacts; their values cannot be used in arbitrary persistent resource fields; this behavior should be assessed against the concrete need to reduce risk when secrets were written to state or repository history. The distinction matters here: using that mechanism to obtain runtime-only data through an ephemeral provider operation would still leave the objective to reduce risk when secrets were written to state or repository history unmet.

E:

Write-only arguments exist only where the provider schema supports them; they are available in Terraform 1.11+, including the tested 1.12 release; this behavior should be assessed against the concrete need to reduce risk when secrets were written to state or repository history. It may support a related workflow, but the question specifically requires the mechanism for reduce risk when secrets were written to state or repository history rather than send a secret to a managed resource without storing its value in plan or state.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests