Question 270
The immediate Terraform task is to read a named attribute from a managed resource. Which method handles that task most directly?
- Use
output to expose child internals intentionally
- Use
local.prefix
- Use direct attribute references to create implicit dependencies
- Use
count.index inside counted blocks
- Understand values unknown until apply
- Use
resource_type.name.attribute
Explanation
Correct Answer
F: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 read a named attribute from a managed resource. This directly supports the task to read a named attribute from a managed resource during a platform review.
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 read a named attribute from a managed resource. It may support a related workflow, but the question specifically requires the mechanism for read a named attribute from a managed resource rather than create a stable boundary for modules that callers depend on.
B: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 read a named attribute from a managed resource. The stated requirement is to read a named attribute from a managed resource, not to reference a computed local value in the same module; this alternative addresses a different control or phase.
C: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 read a named attribute from a managed resource. 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 read a named attribute from a managed resource.
D: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 read a named attribute from a managed resource. The distinction matters here: using that mechanism to identify the zero-based index of the current instance would still leave the objective to read a named attribute from a managed resource unmet.
E: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 read a named attribute from a managed resource. It may support a related workflow, but the question specifically requires the mechanism for read a named attribute from a managed resource rather than avoid assuming every computed attribute is fixed during planning.
Question 271
In a planned migration, the requested result is to reject caller inputs that violate a Boolean rule. What should the engineer select?
- Use
validation inside a variable block
- Use
terraform output -json for machine-readable results
- Mark a sensitive output
sensitive = true
- Pass values through
-var-file=custom.tfvars
Explanation
Correct Answer
A:The condition and custom error message give feedback near the module boundary; it is not an HCP policy set or a provider API permission check; this behavior should be assessed against the concrete need to reject caller inputs that violate a Boolean rule. This directly supports the task to reject caller inputs that violate a Boolean rule during a deployment checklist.
Incorrect Answers
B: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 reject caller inputs that violate a Boolean rule. It may support a related workflow, but the question specifically requires the mechanism for reject caller inputs that violate a Boolean rule rather than obtain structured output values in scripts.
C: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 reject caller inputs that violate a Boolean rule. The stated requirement is to reject caller inputs that violate a Boolean rule, not to avoid showing a secret output value in normal human-readable CLI displays; this alternative addresses a different control or phase.
D:Explicit variable files let separate runs use separate configurations; the file supplies module inputs, not resource lifecycle commands; this behavior should be assessed against the concrete need to reject caller inputs that violate a Boolean rule. That can be useful when the aim is to load named environment inputs that are not automatically discovered, but it does not directly deliver the requested ability to reject caller inputs that violate a Boolean rule.
Question 272
An author is choosing between ordered and keyed inputs. The checklist contains independent tasks: (1) preserve a sequence in which position and duplicates may matter; (2) read a string-keyed collection value; (3) produce a list value when a downstream expression requires list semantics. Which three options directly correspond to the respective tasks? Choose THREE.
- Use
list(string) for ordered strings
- Convert values with
toset(...)
- Convert values with
tolist(...)
- Access a map with
var.tags["owner"]
- Use
optional(...) in object attributes
- Use
object({ name = string, enabled = bool })
Explanation
Correct Answers
A: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 preserve a sequence in which position and duplicates may matter and read a string-keyed collection value and produce a list value when a downstream expression requires list semantics. This matches the distinct objective to preserve a sequence in which position and duplicates may matter; the remaining chosen features address read a string-keyed collection value and produce a list value when a downstream expression requires list semantics.
C: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 preserve a sequence in which position and duplicates may matter and read a string-keyed collection value and produce a list value when a downstream expression requires list semantics. This matches the distinct objective to produce a list value when a downstream expression requires list semantics; the remaining chosen features address preserve a sequence in which position and duplicates may matter and read a string-keyed collection value.
D: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 preserve a sequence in which position and duplicates may matter and read a string-keyed collection value and produce a list value when a downstream expression requires list semantics. This matches the distinct objective to read a string-keyed collection value; the remaining chosen features address preserve a sequence in which position and duplicates may matter and produce a list value when a downstream expression requires list semantics.
Incorrect Answers
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 preserve a sequence in which position and duplicates may matter and read a string-keyed collection value and produce a list value when a downstream expression requires list semantics. Its main application is to remove duplicates and produce set semantics for iteration; the checklist instead asks for preserve a sequence in which position and duplicates may matter; and read a string-keyed collection value; and produce a list value when a downstream expression requires list semantics. None of those distinct criteria specifically calls for this alternative.
E: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 preserve a sequence in which position and duplicates may matter and read a string-keyed collection value and produce a list value when a downstream expression requires list semantics. Its main application is to allow an object field to be omitted from a typed input; the checklist instead asks for preserve a sequence in which position and duplicates may matter; and read a string-keyed collection value; and produce a list value when a downstream expression requires list semantics. None of those distinct criteria specifically calls for this alternative.
F: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 preserve a sequence in which position and duplicates may matter and read a string-keyed collection value and produce a list value when a downstream expression requires list semantics. Its main application is to specify a named record with different attribute types; the checklist instead asks for preserve a sequence in which position and duplicates may matter; and read a string-keyed collection value; and produce a list value when a downstream expression requires list semantics. None of those distinct criteria specifically calls for this alternative.
Question 273
A reviewer is assessing Terraform built-in functions and generated nested blocks. The requirement is to divide text into a list around a separator. Which Terraform mechanism directly meets this requirement?
- Use
cidrsubnet(prefix, newbits, netnum)
- Use
distinct(list)
- Use
concat(list1, list2)
- Use
split(delimiter, string)
Explanation
Correct Answer
D:Split produces a sequence of pieces; it does not construct a map from the resulting values automatically; this behavior should be assessed against the concrete need to divide text into a list around a separator. This directly supports the task to divide text into a list around a separator during an automated release.
Incorrect Answers
A:CIDR functions perform address arithmetic on a known network; they do not create cloud networks or allocate provider resources; this behavior should be assessed against the concrete need to divide text into a list around a separator. The stated requirement is to divide text into a list around a separator, not to derive a smaller subnet CIDR from a parent prefix; this alternative addresses a different control or phase.
B:Distinct retains a list representation with unique values; it is useful when order still matters and a set would alter semantics; this behavior should be assessed against the concrete need to divide text into a list around a separator. That can be useful when the aim is to remove duplicate list elements while preserving first occurrence order, but it does not directly deliver the requested ability to divide text into a list around a separator.
C: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 divide text into a list around a separator. The distinction matters here: using that mechanism to append sequences while retaining element order would still leave the objective to divide text into a list around a separator unmet.
Question 274
A platform team must control dependencies and replacements. A reviewer must determine how to allow unrelated operations to proceed concurrently. Which action is the appropriate choice?
- Use
depends_on for a hidden dependency
- Recognize propagated
create_before_destroy behavior
- Use graph parallelism for independent resources
- Recognize lifecycle arguments are evaluated early
Explanation
Correct Answer
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 allow unrelated operations to proceed concurrently. This directly supports the task to allow unrelated operations to proceed concurrently during a staged rollout.
Incorrect Answers
A: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 allow unrelated operations to proceed concurrently. It may support a related workflow, but the question specifically requires the mechanism for allow unrelated operations to proceed concurrently rather than order operations even when no output attribute is consumed.
B: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 allow unrelated operations to proceed concurrently. The stated requirement is to allow unrelated operations to proceed concurrently, not to understand why a dependency may also be retained during a replacement; this alternative addresses a different control or phase.
D: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 allow unrelated operations to proceed concurrently. The distinction matters here: using that mechanism to avoid dynamic expressions for create_before_destroy and similar rules would still leave the objective to allow unrelated operations to proceed concurrently unmet.
Question 275
A deployment must validate assumptions or outcomes. The checklist contains independent tasks: (1) reject a malformed module input with a custom message; (2) verify a property after the relevant resource or data evaluation. Which two options directly correspond to the respective tasks? Choose TWO.
- Use
error_message for actionable custom diagnostics
- Use
can(regex(...)) in validation
- Use a variable
validation block
- Distinguish
terraform validate from in-configuration conditions
- Use a resource
postcondition
Explanation
Correct Answers
C: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 reject a malformed module input with a custom message and verify a property after the relevant resource or data evaluation. This matches the distinct objective to reject a malformed module input with a custom message; the remaining chosen features address verify a property after the relevant resource or data evaluation.
E: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 reject a malformed module input with a custom message and verify a property after the relevant resource or data evaluation. This matches the distinct objective to verify a property after the relevant resource or data evaluation; the remaining chosen features address reject a malformed module input with a custom message.
Incorrect Answers
A: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 reject a malformed module input with a custom message and verify a property after the relevant resource or data evaluation. Its main application is to tell users which contract failed and why; the checklist instead asks for reject a malformed module input with a custom message; and verify a property after the relevant resource or data evaluation. None of those distinct criteria specifically calls for this alternative.
B: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 reject a malformed module input with a custom message and verify a property after the relevant resource or data evaluation. Its main application is to test a string against a pattern without crashing on a nonmatch; the checklist instead asks for reject a malformed module input with a custom message; and verify a property after the relevant resource or data evaluation. None of those distinct criteria specifically calls for this alternative.
D: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 reject a malformed module input with a custom message and verify a property after the relevant resource or data evaluation. Its main application is to separate structural HCL checking from runtime assertions; the checklist instead asks for reject a malformed module input with a custom message; and verify a property after the relevant resource or data evaluation. None of those distinct criteria specifically calls for this alternative.
Question 276
A Terraform rollout has separate acceptance criteria: avoid normal display of an output carrying sensitive data and reduce risk when secrets were written to state or repository history. Which combined approach directly satisfies the two criteria?
- Protect access to remote state + Avoid committing secret
.tfvars values
- Mark a secret root output
sensitive = true + Rotate credentials after suspected disclosure
- Avoid unnecessary
nonsensitive(...) calls + Rotate credentials after suspected disclosure
- Mark a secret root output
sensitive = true + Use a provider-supported write-only argument
Explanation
Correct Answer
B:For the first criterion, 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 and reduce risk when secrets were written to state or repository history; this directly addresses the need to avoid normal display of an output carrying sensitive data. For the separate second criterion, 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 and reduce risk when secrets were written to state or repository history; this fulfills the need to reduce risk when secrets were written to state or repository history. Together they cover the independent tasks of avoid normal display of an output carrying sensitive data and reduce risk when secrets were written to state or repository history without exchanging the responsibilities of these features.
Incorrect Answers
A: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 avoid normal display of an output carrying sensitive data and reduce risk when secrets were written to state or repository history. The second measure is intended to prevent credentials from entering source history: 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 and reduce risk when secrets were written to state or repository history. Neither is the directly designated method for the separate goals of avoid normal display of an output carrying sensitive data and reduce risk when secrets were written to state or repository history in this review.
C:The second measure does meet the reduce risk when secrets were written to state or repository history requirement, but the first is designed for another concern: 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 normal display of an output carrying sensitive data and reduce risk when secrets were written to state or repository history. That first component is designed to preserve Terraform's safety indicator for secret-bearing expressions, which does not accomplish the requested task to avoid normal display of an output carrying sensitive data, even though the other measure satisfies reduce risk when secrets were written to state or repository history.
D:The first measure meets the requirement to avoid normal display of an output carrying sensitive data, but its partner serves a different role: 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 avoid normal display of an output carrying sensitive data and reduce risk when secrets were written to state or repository history. That second component is designed to send a secret to a managed resource without storing its value in plan or state, so the still-missing criterion is to reduce risk when secrets were written to state or repository history, while the first criterion remains avoid normal display of an output carrying sensitive data.
Question 277
A reviewer has to approve a two-part design: read an object without asking Terraform to create or manage it; additionally, consume the ID of an object declared through a resource block. Which option pairs the correct mechanisms?
- Query an existing object with
data + Declare a managed object with resource
- Keep a data lookup separate from a same-object managed declaration + Reference
aws_instance.web.id for a managed resource
- Select
resource instead of data when deletion must be managed + Use provider selection on both resource and data blocks
- Query an existing object with
data + Reference aws_instance.web.id for a managed resource
- Read data sources during planning when inputs are known + Reference
aws_instance.web.id for a managed resource
Explanation
Correct Answer
D:For the first criterion, 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block; this directly addresses the need to read an object without asking Terraform to create or manage it. For the separate second criterion, 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block; this fulfills the need to consume the ID of an object declared through a resource block. Together they cover the independent tasks of read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure meets the requirement to read an object without asking Terraform to create or manage it, but its partner serves a different role: 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block. That second component is designed to ask Terraform to own the lifecycle of a remote object, so the still-missing criterion is to consume the ID of an object declared through a resource block, while the first criterion remains read an object without asking Terraform to create or manage it.
B:The second measure does meet the consume the ID of an object declared through a resource block requirement, but the first is designed for another concern: 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block. That first component is designed to avoid mistaking two views of one API object for independent resources, which does not accomplish the requested task to read an object without asking Terraform to create or manage it, even though the other measure satisfies consume the ID of an object declared through a resource block.
C:The first measure is intended to make intentional destruction part of Terraform's lifecycle model: 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block. The second measure is intended to direct API operations and lookups to the intended account or region: 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block. Neither is the directly designated method for the separate goals of read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block in this review.
E:The second measure does meet the consume the ID of an object declared through a resource block requirement, but the first is designed for another concern: 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 read an object without asking Terraform to create or manage it and consume the ID of an object declared through a resource block. That first component is designed to retrieve remote information for evaluating the proposed change, which does not accomplish the requested task to read an object without asking Terraform to create or manage it, even though the other measure satisfies consume the ID of an object declared through a resource block.
Question 278
A Terraform rollout has separate acceptance criteria: read a named attribute from a managed resource and consume a value explicitly exposed by a child module. Which combined approach directly satisfies the two criteria?
- Avoid cyclic resource references + Use a
for expression over a resource map
- Use
count.index inside counted blocks + Use module.network.subnet_id
- Use
resource_type.name.attribute + Use resource.items[*].id for counted instances
- Use
resource_type.name.attribute + Use module.network.subnet_id
- Use direct attribute references to create implicit dependencies + Use
module.network.subnet_id
- Use
resource_type.name.attribute + Understand values unknown until apply
Explanation
Correct Answer
D:For the first criterion, 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module; this directly addresses the need to read a named attribute from a managed resource. For the separate second criterion, 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module; this fulfills the need to consume a value explicitly exposed by a child module. Together they cover the independent tasks of read a named attribute from a managed resource and consume a value explicitly exposed by a child module without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure is intended to prevent a graph in which objects depend on each other without a valid ordering: 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module. The second measure is intended to extract values from instances created with for_each: 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module. Neither is the directly designated method for the separate goals of read a named attribute from a managed resource and consume a value explicitly exposed by a child module in this review.
B:The second measure does meet the consume a value explicitly exposed by a child module requirement, but the first is designed for another concern: 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module. That first component is designed to identify the zero-based index of the current instance, which does not accomplish the requested task to read a named attribute from a managed resource, even though the other measure satisfies consume a value explicitly exposed by a child module.
C:The first measure meets the requirement to read a named attribute from a managed resource, but its partner serves a different role: 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module. That second component is designed to collect an attribute from a list-like collection of resource instances, so the still-missing criterion is to consume a value explicitly exposed by a child module, while the first criterion remains read a named attribute from a managed resource.
E:The second measure does meet the consume a value explicitly exposed by a child module requirement, but the first is designed for another concern: 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module. That first component is designed to let Terraform infer safe operation order through data flow, which does not accomplish the requested task to read a named attribute from a managed resource, even though the other measure satisfies consume a value explicitly exposed by a child module.
F:The first measure meets the requirement to read a named attribute from a managed resource, but its partner serves a different role: 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 read a named attribute from a managed resource and consume a value explicitly exposed by a child module. That second component is designed to avoid assuming every computed attribute is fixed during planning, so the still-missing criterion is to consume a value explicitly exposed by a child module, while the first criterion remains read a named attribute from a managed resource.
Question 279
An engineer needs to transfer computed values from a child module to its caller as part of a planned migration. Which option is the best fit?
- Use a child-module output as
module.app.endpoint
- Pass values through
-var='name=value'
- Use
TF_VAR_name environment variables
- Mark an input variable
ephemeral = true
Explanation
Correct Answer
A:Only declared outputs form the public child-module interface; the caller cannot directly use an internal resource just by knowing its internal name; this behavior should be assessed against the concrete need to transfer computed values from a child module to its caller. This directly supports the task to transfer computed values from a child module to its caller during a maintenance request.
Incorrect Answers
B:CLI assignments have high precedence among standard CLI variable sources; they do not change the default declaration in source control; this behavior should be assessed against the concrete need to transfer computed values from a child module to its caller. The stated requirement is to transfer computed values from a child module to its caller, not to set a variable for one CLI operation; this alternative addresses a different control or phase.
C:Terraform reads variables with the TF_VAR_ prefix, subject to other higher-precedence input sources; environment variables can still leak in logs or process environments; this behavior should be assessed against the concrete need to transfer computed values from a child module to its caller. That can be useful when the aim is to provide a root input value without writing it in a tfvars file, but it does not directly deliver the requested ability to transfer computed values from a child module to its caller.
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 transfer computed values from a child module to its caller. The distinction matters here: using that mechanism to prevent a temporary secret from being persisted to state and plan files would still leave the objective to transfer computed values from a child module to its caller unmet.
Question 280
A configuration review examines list, map, object, tuple, and set semantics. Two independent changes are requested: first, produce a list value when a downstream expression requires list semantics; second, collapse a list of lists into one sequence. Which pair of measures fulfills both?
- Convert values with
tolist(...) + Use flatten(...) for nested lists
- Use
tomap(...) to make a map + Use flatten(...) for nested lists
- Use
object({ name = string, enabled = bool }) + Use structural object attributes in module interfaces
- Convert values with
tolist(...) + Use list(string) for ordered strings
Explanation
Correct Answer
A:For the first criterion, 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 produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence; this directly addresses the need to produce a list value when a downstream expression requires list semantics. For the separate second criterion, 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 produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence; this fulfills the need to collapse a list of lists into one sequence. Together they cover the independent tasks of produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence without exchanging the responsibilities of these features.
Incorrect Answers
B:The second measure does meet the collapse a list of lists into one sequence requirement, but the first is designed for another concern: Map conversion attempts a common element type for the values; a heterogeneous object may need a more explicit object contract instead; this behavior should be assessed against the concrete need to produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence. That first component is designed to convert a compatible value into a homogeneous keyed collection, which does not accomplish the requested task to produce a list value when a downstream expression requires list semantics, even though the other measure satisfies collapse a list of lists into one sequence.
C:The first measure is intended to specify a named record with different attribute types: 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 produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence. 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 produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence. Neither is the directly designated method for the separate goals of produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence in this review.
D:The first measure meets the requirement to produce a list value when a downstream expression requires list semantics, but its partner serves a different role: 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 produce a list value when a downstream expression requires list semantics and collapse a list of lists into one sequence. That second component is designed to preserve a sequence in which position and duplicates may matter, so the still-missing criterion is to collapse a list of lists into one sequence, while the first criterion remains produce a list value when a downstream expression requires list semantics.