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?
- Treat saved plan files as sensitive artifacts
- Distinguish
ephemeral from sensitive
- Rotate credentials after suspected disclosure
- Use an
ephemeral resource to retrieve supported temporary secrets
- 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.
Question 421
A review finds confusion about resource versus data source behavior. The requirement is to compute reusable expression results without creating an API object. Which Terraform mechanism directly meets this requirement?
- Distinguish
locals from remote resource declarations
- Reference
aws_instance.web.id for a managed resource
- Use an
ephemeral resource for supported temporary data
- Keep a data lookup separate from a same-object managed declaration
Explanation
Correct Answer
A:Local values are named expressions evaluated inside a module; they neither invoke resource creation nor bind a remote object into state; this behavior should be assessed against the concrete need to compute reusable expression results without creating an API object. This directly supports the task to compute reusable expression results without creating an API object during a planned migration.
Incorrect Answers
B:A managed resource reference omits the data. prefix; terraform derives a dependency when an argument uses its computed attributes; this behavior should be assessed against the concrete need to compute reusable expression results without creating an API object. The stated requirement is to compute reusable expression results without creating an API object, not to consume the ID of an object declared through a resource block; this alternative addresses a different control or phase.
C: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 compute reusable expression results without creating an API object. 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 compute reusable expression results without creating an API object.
D: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 compute reusable expression results without creating an API object. The distinction matters here: using that mechanism to avoid mistaking two views of one API object for independent resources would still leave the objective to compute reusable expression results without creating an API object unmet.
Question 422
A configuration connects network and compute resources. A reviewer must determine how to collect an attribute from a list-like collection of resource instances. Which action is the appropriate choice?
- Use
resource_type.name.attribute
- Use a
for expression over a resource map
- Use
count.index inside counted blocks
- Use
resource.items[*].id for counted instances
Explanation
Correct Answer
D:Splat expressions iterate list, set, or tuple values, including count-created instances. for_each maps are normally traversed using a for expression; this behavior should be assessed against the concrete need to collect an attribute from a list-like collection of resource instances. This directly supports the task to collect an attribute from a list-like collection of resource instances during a cross-team handoff.
Incorrect Answers
A: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 collect an attribute from a list-like collection of resource instances. The distinction matters here: using that mechanism to read a named attribute from a managed resource would still leave the objective to collect an attribute from a list-like collection of resource instances 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 collect an attribute from a list-like collection of resource instances. It may support a related workflow, but the question specifically requires the mechanism for collect an attribute from a list-like collection of resource instances rather than extract values from instances created with for_each.
C:A count meta-argument creates numerically indexed instances. count.index is available in blocks that use count, not as a global value; this behavior should be assessed against the concrete need to collect an attribute from a list-like collection of resource instances. The stated requirement is to collect an attribute from a list-like collection of resource instances, not to identify the zero-based index of the current instance; this alternative addresses a different control or phase.
Question 423
The immediate Terraform task is to suppress ordinary disclosure of a secret in Terraform output. Which method handles that task most directly?
- Mark a variable
sensitive = true
- Use
terraform output -raw NAME for a string result
- Recognize variable scope is per module
- Mark an input variable
ephemeral = true
Explanation
Correct Answer
A: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 suppress ordinary disclosure of a secret in Terraform output. This directly supports the task to suppress ordinary disclosure of a secret in Terraform output during a platform review.
Incorrect Answers
B:Raw output formats a supported string, number, or Boolean directly without extra Terraform representation; complex objects require another output format; this behavior should be assessed against the concrete need to suppress ordinary disclosure of a secret in Terraform output. The distinction matters here: using that mechanism to retrieve a plain scalar output for shell integration would still leave the objective to suppress ordinary disclosure of a secret in Terraform output unmet.
C: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 suppress ordinary disclosure of a secret in Terraform output. It may support a related workflow, but the question specifically requires the mechanism for suppress ordinary disclosure of a secret in Terraform output rather than avoid reading a root input directly from an unrelated child module.
D: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 suppress ordinary disclosure of a secret in Terraform output. The stated requirement is to suppress ordinary disclosure of a secret in Terraform output, not to prevent a temporary secret from being persisted to state and plan files; this alternative addresses a different control or phase.
Question 424
A Terraform rollout has separate acceptance criteria: validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical. Which combined approach directly satisfies the two criteria?
- Use
map(string) for named string values + Use type = any sparingly
- Use
optional(...) in object attributes + Use flatten(...) for nested lists
- Use structural object attributes in module interfaces + Recognize map iteration's key ordering
- Use structural object attributes in module interfaces + Use
type = any sparingly
Explanation
Correct Answer
D:For the first criterion, 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 validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical; this directly addresses the need to validate required properties rather than accepting arbitrary untyped maps. For the separate second criterion, the any placeholder relaxes static expectations but sacrifices early type guarantees; most module interfaces benefit from a concrete type; this behavior should be assessed against the concrete need to validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical; this fulfills the need to permit values of varying shapes where a strict contract is impractical. Together they cover the independent tasks of validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the permit values of varying shapes where a strict contract is impractical requirement, but the first is designed for another concern: Maps provide a homogeneous value type and stable keys; they differ from lists, which are indexed by position; this behavior should be assessed against the concrete need to validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical. That first component is designed to look up values by arbitrary string keys, which does not accomplish the requested task to validate required properties rather than accepting arbitrary untyped maps, even though the other measure satisfies permit values of varying shapes where a strict contract is impractical.
B:The first measure is intended to allow an object field to be omitted from a typed input: Optional attributes let module callers omit selected fields and may provide defaults; they do not make unrelated required object attributes optional; this behavior should be assessed against the concrete need to validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical. The second measure is intended to collapse a list of lists into one sequence: 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 validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical. Neither is the directly designated method for the separate goals of validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical in this review.
C:The first measure meets the requirement to validate required properties rather than accepting arbitrary untyped maps, but its partner serves a different role: 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 validate required properties rather than accepting arbitrary untyped maps and permit values of varying shapes where a strict contract is impractical. That second component is designed to avoid interpreting maps as insertion-ordered sequences, so the still-missing criterion is to permit values of varying shapes where a strict contract is impractical, while the first criterion remains validate required properties rather than accepting arbitrary untyped maps.
Question 425
A module author is replacing repetitive HCL with expressions. The team must both render a local template with named variables and combine a sequence of strings with a separator. Which paired choice implements those distinct goals?
- Use
contains(collection, value) + Use join(delimiter, list)
- Use
alltrue(list_of_bools) + Use a conditional condition ? yes : no
- Use
templatefile(path, vars) + Use join(delimiter, list)
- Use
templatefile(path, vars) + Use can(expr)
Explanation
Correct Answer
C:For the first criterion, the function reads a template and evaluates references using the supplied variable map; it does not execute the rendered text as a shell script by itself; this behavior should be assessed against the concrete need to render a local template with named variables and combine a sequence of strings with a separator; this directly addresses the need to render a local template with named variables. For the separate second criterion, join forms one string from elements; split performs the reverse direction on a string; this behavior should be assessed against the concrete need to render a local template with named variables and combine a sequence of strings with a separator; this fulfills the need to combine a sequence of strings with a separator. Together they cover the independent tasks of render a local template with named variables and combine a sequence of strings with a separator without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the combine a sequence of strings with a separator requirement, but the first is designed for another concern: Contains returns a Boolean membership result; it does not check whether an object has a named attribute with a separate schema; this behavior should be assessed against the concrete need to render a local template with named variables and combine a sequence of strings with a separator. That first component is designed to test whether a collection includes a particular element, which does not accomplish the requested task to render a local template with named variables, even though the other measure satisfies combine a sequence of strings with a separator.
B:The first measure is intended to require every evaluated Boolean in a collection to be true: 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 render a local template with named variables and combine a sequence of strings with a separator. The second measure is intended to select between two expression results based on a Boolean test: The conditional expression evaluates a condition to choose a result; its two result arms must have compatible types for Terraform to infer a usable value; this behavior should be assessed against the concrete need to render a local template with named variables and combine a sequence of strings with a separator. Neither is the directly designated method for the separate goals of render a local template with named variables and combine a sequence of strings with a separator in this review.
D:The first measure meets the requirement to render a local template with named variables, but its partner serves a different role: Can returns a Boolean and is especially useful in custom validation rules; it does not return the underlying expression's successful value; this behavior should be assessed against the concrete need to render a local template with named variables and combine a sequence of strings with a separator. That second component is designed to test whether an expression can be evaluated without an error, so the still-missing criterion is to combine a sequence of strings with a separator, while the first criterion remains render a local template with named variables.
Question 426
An engineer is diagnosing unexpected resource ordering. The checklist contains independent tasks: (1) fail a plan that would destroy the protected resource while its block remains; (2) replace a resource when another managed resource or attribute changes. Which two options directly correspond to the respective tasks? Choose TWO.
- Use
terraform_data for value-driven replacement triggers
- Use
depends_on for a hidden dependency
- Recognize lifecycle arguments are evaluated early
- Use an attribute reference for an implicit edge
- Use
prevent_destroy = true on a configured resource
- Use
replace_triggered_by for resource change coupling
Explanation
Correct Answers
E: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 fail a plan that would destroy the protected resource while its block remains and replace a resource when another managed resource or attribute changes. This matches the distinct objective to fail a plan that would destroy the protected resource while its block remains; the remaining chosen features address replace a resource when another managed resource or attribute changes.
F: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 fail a plan that would destroy the protected resource while its block remains and replace a resource when another managed resource or attribute changes. This matches the distinct objective to replace a resource when another managed resource or attribute changes; the remaining chosen features address fail a plan that would destroy the protected resource while its block remains.
Incorrect Answers
A:A terraform_data resource can turn a changing value into a planned change that replace_triggered_by can reference; this avoids trying to reference a bare variable as a resource action; this behavior should be assessed against the concrete need to fail a plan that would destroy the protected resource while its block remains and replace a resource when another managed resource or attribute changes. Its main application is to represent an input change through a managed resource lifecycle; the checklist instead asks for fail a plan that would destroy the protected resource while its block remains; and replace a resource when another managed resource or attribute changes. None of those distinct criteria specifically calls for this alternative.
B:Explicit dependencies model side effects or prerequisites that Terraform cannot infer from values; they may reduce concurrency or defer data-source reads; this behavior should be assessed against the concrete need to fail a plan that would destroy the protected resource while its block remains and replace a resource when another managed resource or attribute changes. Its main application is to order operations even when no output attribute is consumed; the checklist instead asks for fail a plan that would destroy the protected resource while its block remains; and replace a resource when another managed resource or attribute changes. None of those distinct criteria specifically calls for this alternative.
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 fail a plan that would destroy the protected resource while its block remains and replace a resource when another managed resource or attribute changes. Its main application is to avoid dynamic expressions for create_before_destroy and similar rules; the checklist instead asks for fail a plan that would destroy the protected resource while its block remains; and replace a resource when another managed resource or attribute changes. None of those distinct criteria specifically calls for this alternative.
D:Terraform builds a dependency from the expression reference; a separate explicit ordering rule is unnecessary when data flow already expresses the relationship; this behavior should be assessed against the concrete need to fail a plan that would destroy the protected resource while its block remains and replace a resource when another managed resource or attribute changes. Its main application is to order resources when the second consumes a value from the first; the checklist instead asks for fail a plan that would destroy the protected resource while its block remains; and replace a resource when another managed resource or attribute changes. None of those distinct criteria specifically calls for this alternative.
Question 427
During a deployment checklist, one task is to stop a deployment when a required assumption fails, while another is to reject malformed or disallowed input before resource creation. Select the matching pair of techniques.
- Use a precondition rather than a check for an unsafe prerequisite + Use variable validation for valid network prefixes
- Use a precondition rather than a check for an unsafe prerequisite + Use a postcondition for a provider-computed result
- Use a resource
postcondition + Use variable validation for valid network prefixes
- Use
error_message for actionable custom diagnostics + Use try for optional nested values
Explanation
Correct Answer
A:For the first criterion, 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 stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation; this directly addresses the need to stop a deployment when a required assumption fails. For the separate second criterion, functions like can(cidrhost(...)) can validate address-format assumptions; this is input correctness, distinct from connectivity tests of a deployed network; this behavior should be assessed against the concrete need to stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation; this fulfills the need to reject malformed or disallowed input before resource creation. Together they cover the independent tasks of stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation without exchanging the responsibilities of these features.
Incorrect Answers
B:The first measure meets the requirement to stop a deployment when a required assumption fails, but its partner serves a different role: A computed attribute might be unknown during planning; postconditions evaluate when sufficient data exists, rather than fabricating a preliminary value; this behavior should be assessed against the concrete need to stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation. That second component is designed to test a guarantee only after the remote result is known, so the still-missing criterion is to reject malformed or disallowed input before resource creation, while the first criterion remains stop a deployment when a required assumption fails.
C:The second measure does meet the reject malformed or disallowed input before resource creation 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 stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation. That first component is designed to verify a property after the relevant resource or data evaluation, which does not accomplish the requested task to stop a deployment when a required assumption fails, even though the other measure satisfies reject malformed or disallowed input before resource creation.
D:The first measure is intended to tell users which contract failed and why: Variable validation and lifecycle conditions support custom messages; a vague error message makes troubleshooting harder even when the Boolean test is correct; this behavior should be assessed against the concrete need to stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation. The second measure is intended to provide a fallback when a dynamic attribute path is absent: Try handles dynamic evaluation failures in expressions and can help normalize inputs; it does not itself fail the configuration when the fallback is used; this behavior should be assessed against the concrete need to stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation. Neither is the directly designated method for the separate goals of stop a deployment when a required assumption fails and reject malformed or disallowed input before resource creation in this review.
Question 428
The immediate Terraform task is to choose secrecy controls based on persistence as well as output redaction. Which method handles that task most directly?
- Mark a secret root output
sensitive = true
- Avoid committing secret
.tfvars values
- Use short-lived cloud identities for automation
- Distinguish
ephemeral from sensitive
Explanation
Correct Answer
D: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 choose secrecy controls based on persistence as well as output redaction. This directly supports the task to choose secrecy controls based on persistence as well as output redaction during a configuration change.
Incorrect Answers
A: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 choose secrecy controls based on persistence as well as output redaction. The stated requirement is to choose secrecy controls based on persistence as well as output redaction, not to avoid normal display of an output carrying sensitive data; this alternative addresses a different control or phase.
B: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 choose secrecy controls based on persistence as well as output redaction. 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 choose secrecy controls based on persistence as well as output redaction.
C: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 choose secrecy controls based on persistence as well as output redaction. The distinction matters here: using that mechanism to reduce dependence on hardcoded long-lived API keys would still leave the objective to choose secrecy controls based on persistence as well as output redaction unmet.
Question 429
An engineer is deciding whether Terraform should own an existing object. A reviewer must determine how to distinguish a failed lookup from a request to create the missing object. Which action is the appropriate choice?
- Understand data source failure on a missing object
- Use an
ephemeral resource for supported temporary data
- Declare a managed object with
resource
- Recognize
terraform_data as a built-in managed resource
Explanation
Correct Answer
A: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 distinguish a failed lookup from a request to create the missing object. This directly supports the task to distinguish a failed lookup from a request to create the missing object during a cross-team handoff.
Incorrect Answers
B: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 distinguish a failed lookup from a request to create the missing object. 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 distinguish a failed lookup from a request to create the missing object.
C: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 distinguish a failed lookup from a request to create the missing object. The distinction matters here: using that mechanism to ask Terraform to own the lifecycle of a remote object would still leave the objective to distinguish a failed lookup from a request to create the missing object unmet.
D: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 distinguish a failed lookup from a request to create the missing object. It may support a related workflow, but the question specifically requires the mechanism for distinguish a failed lookup from a request to create the missing object rather than store arbitrary values or trigger replacements without a third-party resource API.
Question 430
The immediate Terraform task is to declare a relationship that cannot be expressed through an input attribute. Which method handles that task most directly?
- Understand values unknown until apply
- Use
resource_type.name.attribute
- Avoid cyclic resource references
- Use
depends_on for hidden ordering requirements
Explanation
Correct Answer
D: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 declare a relationship that cannot be expressed through an input attribute. This directly supports the task to declare a relationship that cannot be expressed through an input attribute during a platform review.
Incorrect Answers
A: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 declare a relationship that cannot be expressed through an input attribute. It may support a related workflow, but the question specifically requires the mechanism for declare a relationship that cannot be expressed through an input attribute rather than avoid assuming every computed attribute is fixed during planning.
B: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 declare a relationship that cannot be expressed through an input attribute. The stated requirement is to declare a relationship that cannot be expressed through an input attribute, not to read a named attribute from a managed resource; this alternative addresses a different control or phase.
C:A circular dependency has no acyclic execution order; splitting responsibilities or breaking unnecessary references resolves the cycle; this behavior should be assessed against the concrete need to declare a relationship that cannot be expressed through an input attribute. That can be useful when the aim is to prevent a graph in which objects depend on each other without a valid ordering, but it does not directly deliver the requested ability to declare a relationship that cannot be expressed through an input attribute.