Question 360
A Terraform module defines strongly typed collections. Two independent changes are requested: first, allow an object field to be omitted from a typed input; second, retrieve the first element of an ordered collection. Which pair of measures fulfills both?
- Use
optional(...) in object attributes + Access a list with var.zones[0]
- Use
object({ name = string, enabled = bool }) + Access a list with var.zones[0]
- Use
optional(...) in object attributes + Use type = any sparingly
- Use
tomap(...) to make a map + Use list(string) for ordered strings
- Convert values with
tolist(...) + Access a list with var.zones[0]
Explanation
Correct Answer
A:For the first criterion, 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 allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection; this directly addresses the need to allow an object field to be omitted from a typed input. For the separate second criterion, lists use zero-based positional indices; a set lacks a stable positional index for this purpose; this behavior should be assessed against the concrete need to allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection; this fulfills the need to retrieve the first element of an ordered collection. Together they cover the independent tasks of allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection without exchanging the responsibilities of these features.
Incorrect Answers
B:The second measure does meet the retrieve the first element of an ordered collection requirement, but the first is designed for another concern: 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 allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection. That first component is designed to specify a named record with different attribute types, which does not accomplish the requested task to allow an object field to be omitted from a typed input, even though the other measure satisfies retrieve the first element of an ordered collection.
C:The first measure meets the requirement to allow an object field to be omitted from a typed input, but its partner serves a different role: 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 allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection. That second component is designed to permit values of varying shapes where a strict contract is impractical, so the still-missing criterion is to retrieve the first element of an ordered collection, while the first criterion remains allow an object field to be omitted from a typed input.
D:The first measure is intended to convert a compatible value into a homogeneous keyed collection: 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 allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection. The second measure is intended to preserve a sequence in which position and duplicates may matter: 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 allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection. Neither is the directly designated method for the separate goals of allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection in this review.
E:The second measure does meet the retrieve the first element of an ordered collection requirement, but the first is designed for another concern: 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 allow an object field to be omitted from a typed input and retrieve the first element of an ordered collection. That first component is designed to produce a list value when a downstream expression requires list semantics, which does not accomplish the requested task to allow an object field to be omitted from a typed input, even though the other measure satisfies retrieve the first element of an ordered collection.
Question 361
During a deployment checklist, one task is to derive a smaller subnet CIDR from a parent prefix, while another is to collect the same attribute from every list-like object. Select the matching pair of techniques.
- Use
zipmap(keys, values) + Use a splat expression items[*].id
- Use
coalesce(a, b, ...) + Use a splat expression items[*].id
- Use
jsonencode(value) + Use distinct(list)
- Use
cidrsubnet(prefix, newbits, netnum) + Use a splat expression items[*].id
- Use
cidrsubnet(prefix, newbits, netnum) + Use a dynamic block to generate nested blocks
Explanation
Correct Answer
D:For the first criterion, 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 derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object; this directly addresses the need to derive a smaller subnet CIDR from a parent prefix. For the separate second criterion, the [*] form is concise for sequences; map-valued for_each resources usually require a for expression instead; this behavior should be assessed against the concrete need to derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object; this fulfills the need to collect the same attribute from every list-like object. Together they cover the independent tasks of derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the collect the same attribute from every list-like object requirement, but the first is designed for another concern: Zipmap associates entries positionally and expects compatible list lengths; it is different from merging two already formed maps; this behavior should be assessed against the concrete need to derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object. That first component is designed to assemble a map from paired key and value lists, which does not accomplish the requested task to derive a smaller subnet CIDR from a parent prefix, even though the other measure satisfies collect the same attribute from every list-like object.
B:The second measure does meet the collect the same attribute from every list-like object 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 derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object. That first component is designed to choose the first non-null and nonempty-string value, which does not accomplish the requested task to derive a smaller subnet CIDR from a parent prefix, even though the other measure satisfies collect the same attribute from every list-like object.
C:The first measure is intended to serialize a Terraform value into JSON text for an API argument: JSON encoding handles escaping and structured representations; hand-built string interpolation is more error-prone for nested JSON; this behavior should be assessed against the concrete need to derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object. The second measure is intended to remove duplicate list elements while preserving first occurrence order: 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 derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object. Neither is the directly designated method for the separate goals of derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object in this review.
E:The first measure meets the requirement to derive a smaller subnet CIDR from a parent prefix, but its partner serves a different role: 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 derive a smaller subnet CIDR from a parent prefix and collect the same attribute from every list-like object. That second component is designed to repeat provider-specific nested blocks from a collection, so the still-missing criterion is to collect the same attribute from every list-like object, while the first criterion remains derive a smaller subnet CIDR from a parent prefix.
Question 362
The immediate Terraform task is to replace a resource when another managed resource or attribute changes. Which method handles that task most directly?
- Use
terraform_data for value-driven replacement triggers
- Understand destroy order as dependency-aware
- Use
replace_triggered_by for resource change coupling
- Recognize lifecycle arguments are evaluated early
- Use explicit dependencies on module calls carefully
Explanation
Correct Answer
C: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 replace a resource when another managed resource or attribute changes. This directly supports the task to replace a resource when another managed resource or attribute changes during a configuration change.
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 replace a resource when another managed resource or attribute changes. The distinction matters here: using that mechanism to represent an input change through a managed resource lifecycle would still leave the objective to replace a resource when another managed resource or attribute changes unmet.
B: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 replace a resource when another managed resource or attribute changes. It may support a related workflow, but the question specifically requires the mechanism for replace a resource when another managed resource or attribute changes rather than remove dependents before the infrastructure they rely on.
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 replace a resource when another managed resource or attribute changes. That can be useful when the aim is to avoid dynamic expressions for create_before_destroy and similar rules, but it does not directly deliver the requested ability to replace a resource when another managed resource or attribute changes.
E: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 replace a resource when another managed resource or attribute changes. The distinction matters here: using that mechanism to delay all operations in a child module until required prerequisites complete would still leave the objective to replace a resource when another managed resource or attribute changes unmet.
Question 363
In an automated release, the requested result is to monitor an infrastructure invariant and report failed checks without blocking the whole operation. What should the engineer select?
- Use
error_message for actionable custom diagnostics
- Use a postcondition for a provider-computed result
- Use variable validation for valid network prefixes
- Use
try for optional nested values
- Use a
check block with assertions
Explanation
Correct Answer
E:Checks are designed for nonblocking validation and can report warnings during plan/apply; critical prerequisites belong in blocking custom conditions; this behavior should be assessed against the concrete need to monitor an infrastructure invariant and report failed checks without blocking the whole operation. This directly supports the task to monitor an infrastructure invariant and report failed checks without blocking the whole operation during a module implementation.
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 monitor an infrastructure invariant and report failed checks without blocking the whole operation. That can be useful when the aim is to tell users which contract failed and why, but it does not directly deliver the requested ability to monitor an infrastructure invariant and report failed checks without blocking the whole operation.
B: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 monitor an infrastructure invariant and report failed checks without blocking the whole operation. The distinction matters here: using that mechanism to test a guarantee only after the remote result is known would still leave the objective to monitor an infrastructure invariant and report failed checks without blocking the whole operation unmet.
C: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 monitor an infrastructure invariant and report failed checks without blocking the whole operation. It may support a related workflow, but the question specifically requires the mechanism for monitor an infrastructure invariant and report failed checks without blocking the whole operation rather than reject malformed or disallowed input before resource creation.
D: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 monitor an infrastructure invariant and report failed checks without blocking the whole operation. The stated requirement is to monitor an infrastructure invariant and report failed checks without blocking the whole operation, not to provide a fallback when a dynamic attribute path is absent; this alternative addresses a different control or phase.
Question 364
An engineer needs to omit short-lived input values from state and plan artifacts as part of an automated release. Which option is the best fit?
- Use a provider-supported write-only argument
- Avoid unnecessary
nonsensitive(...) calls
- Mark a variable
ephemeral = true
- Use Vault to centralize secret access
Explanation
Correct Answer
C: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 omit short-lived input values from state and plan artifacts. This directly supports the task to omit short-lived input values from state and plan artifacts during an infrastructure audit.
Incorrect Answers
A: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 omit short-lived input values from state and plan artifacts. The stated requirement is to omit short-lived input values from state and plan artifacts, not to send a secret to a managed resource without storing its value in plan or state; this alternative addresses a different control or phase.
B:Nonsensitive removes the sensitivity mark from a value; it does not erase the underlying secret and can expose it in outputs or logs; this behavior should be assessed against the concrete need to omit short-lived input values from state and plan artifacts. That can be useful when the aim is to preserve Terraform's safety indicator for secret-bearing expressions, but it does not directly deliver the requested ability to omit short-lived input values from state and plan artifacts.
D: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 omit short-lived input values from state and plan artifacts. It may support a related workflow, but the question specifically requires the mechanism for omit short-lived input values from state and plan artifacts rather than retrieve or distribute sensitive credentials under explicit access policy.
Question 365
In a planned migration, the requested result is to retrieve remote information for evaluating the proposed change. What should the engineer select?
- Read data sources during planning when inputs are known
- Understand data source failure on a missing object
- Recognize
terraform_data as a built-in managed resource
- Use provider selection on both resource and data blocks
Explanation
Correct Answer
A: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 retrieve remote information for evaluating the proposed change. This directly supports the task to retrieve remote information for evaluating the proposed change during a deployment checklist.
Incorrect Answers
B: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 retrieve remote information for evaluating the proposed change. That can be useful when the aim is to distinguish a failed lookup from a request to create the missing object, but it does not directly deliver the requested ability to retrieve remote information for evaluating the proposed change.
C: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 retrieve remote information for evaluating the proposed change. The distinction matters here: using that mechanism to store arbitrary values or trigger replacements without a third-party resource API would still leave the objective to retrieve remote information for evaluating the proposed change unmet.
D: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 retrieve remote information for evaluating the proposed change. It may support a related workflow, but the question specifically requires the mechanism for retrieve remote information for evaluating the proposed change rather than direct API operations and lookups to the intended account or region.
Question 366
An engineer needs to avoid assuming every computed attribute is fixed during planning as part of a planned migration. Which option is the best fit?
- Avoid cyclic resource references
- Use direct attribute references to create implicit dependencies
- Use
data.type.name.attribute
- Understand values unknown until apply
Explanation
Correct Answer
D: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 avoid assuming every computed attribute is fixed during planning. This directly supports the task to avoid assuming every computed attribute is fixed during planning during a maintenance request.
Incorrect Answers
A: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 avoid assuming every computed attribute is fixed during planning. It may support a related workflow, but the question specifically requires the mechanism for avoid assuming every computed attribute is fixed during planning rather than prevent a graph in which objects depend on each other without a valid ordering.
B: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 avoid assuming every computed attribute is fixed during planning. The stated requirement is to avoid assuming every computed attribute is fixed during planning, not to let Terraform infer safe operation order through data flow; this alternative addresses a different control or phase.
C:The data. prefix selects a read-only lookup namespace; without the prefix Terraform would interpret the address as a managed resource; this behavior should be assessed against the concrete need to avoid assuming every computed attribute is fixed during planning. That can be useful when the aim is to retrieve an attribute of a declared data source, but it does not directly deliver the requested ability to avoid assuming every computed attribute is fixed during planning.
Question 367
An application module needs reliable input and output contracts. Two independent changes are requested: first, avoid showing a secret output value in normal human-readable CLI displays; second, reject caller inputs that violate a Boolean rule. Which pair of measures fulfills both?
- Use
TF_VAR_name environment variables + Use validation inside a variable block
- Mark a sensitive output
sensitive = true + Use validation inside a variable block
- Mark a sensitive output
sensitive = true + Define output for a root result
- Recognize variable scope is per module + Declare
variable "name" with a type constraint
Explanation
Correct Answer
B:For the first criterion, 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 and reject caller inputs that violate a Boolean rule; this directly addresses the need to avoid showing a secret output value in normal human-readable CLI displays. For the separate second criterion, 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 avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule; this fulfills the need to reject caller inputs that violate a Boolean rule. Together they cover the independent tasks of avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the reject caller inputs that violate a Boolean rule requirement, but the first is designed for another concern: 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 avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule. That first component is designed to provide a root input value without writing it in a tfvars file, which does not accomplish the requested task to avoid showing a secret output value in normal human-readable CLI displays, even though the other measure satisfies reject caller inputs that violate a Boolean rule.
C:The first measure meets the requirement to avoid showing a secret output value in normal human-readable CLI displays, but its partner serves a different role: Outputs provide a documented interface for command output and automation; they can be inspected with terraform output when recorded in state; this behavior should be assessed against the concrete need to avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule. That second component is designed to expose a selected computed value after provisioning, so the still-missing criterion is to reject caller inputs that violate a Boolean rule, while the first criterion remains avoid showing a secret output value in normal human-readable CLI displays.
D:The first measure is intended to avoid reading a root input directly from an unrelated child module: A child declares its own inputs and receives values in the module call; variables do not automatically become global across the module tree; this behavior should be assessed against the concrete need to avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule. The second measure is intended to enforce the expected shape of a module input: Input types such as string, list(string), or object(...) describe accepted values; terraform checks the supplied value against this contract; this behavior should be assessed against the concrete need to avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule. Neither is the directly designated method for the separate goals of avoid showing a secret output value in normal human-readable CLI displays and reject caller inputs that violate a Boolean rule in this review.
Question 368
During a deployment checklist, one task is to remove duplicates and produce set semantics for iteration, while another is to convert a compatible value into a homogeneous keyed collection. Select the matching pair of techniques.
- Access a list with
var.zones[0] + Use tomap(...) to make a map
- Convert values with
toset(...) + Recognize map iteration's key ordering
- Access a map with
var.tags["owner"] + Use set(string) for unique unordered strings
- Convert values with
toset(...) + Use tomap(...) to make a map
Explanation
Correct Answer
D:For the first criterion, 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 remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection; this directly addresses the need to remove duplicates and produce set semantics for iteration. For the separate second criterion, 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 remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection; this fulfills the need to convert a compatible value into a homogeneous keyed collection. Together they cover the independent tasks of remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the convert a compatible value into a homogeneous keyed collection requirement, but the first is designed for another concern: Lists use zero-based positional indices; a set lacks a stable positional index for this purpose; this behavior should be assessed against the concrete need to remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection. That first component is designed to retrieve the first element of an ordered collection, which does not accomplish the requested task to remove duplicates and produce set semantics for iteration, even though the other measure satisfies convert a compatible value into a homogeneous keyed collection.
B:The first measure meets the requirement to remove duplicates and produce set semantics for iteration, 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 remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection. That second component is designed to avoid interpreting maps as insertion-ordered sequences, so the still-missing criterion is to convert a compatible value into a homogeneous keyed collection, while the first criterion remains remove duplicates and produce set semantics for iteration.
C:The first measure is intended to read a string-keyed collection value: 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 remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection. The second measure is intended to enforce uniqueness without relying on list positions: Sets discard duplicate elements and are not an ordered sequence; this changes instance-key considerations if used with for_each; this behavior should be assessed against the concrete need to remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection. Neither is the directly designated method for the separate goals of remove duplicates and produce set semantics for iteration and convert a compatible value into a homogeneous keyed collection in this review.
Question 369
A reviewer has to approve a two-part design: repeat provider-specific nested blocks from a collection; additionally, create instances keyed by stable identifiers. Which option pairs the correct mechanisms?
- Use
setproduct(a, b) + Use for_each with a map or set of strings
- Use
try(expr, fallback) + Use jsondecode(text)
- Use a splat expression
items[*].id + Use for_each with a map or set of strings
- Use a
dynamic block to generate nested blocks + Use for_each with a map or set of strings
- Use a
dynamic block to generate nested blocks + Use cidrsubnet(prefix, newbits, netnum)
Explanation
Correct Answer
D:For the first criterion, 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 repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers; this directly addresses the need to repeat provider-specific nested blocks from a collection. For the separate second criterion, for-each instances use map or set keys in addresses, helping avoid index churn; values must be known before Terraform can choose instance identities; this behavior should be assessed against the concrete need to repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers; this fulfills the need to create instances keyed by stable identifiers. Together they cover the independent tasks of repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the create instances keyed by stable identifiers requirement, but the first is designed for another concern: Setproduct computes the Cartesian product, useful for pairing environments and roles; it is not an alternative to the resource dependency graph; this behavior should be assessed against the concrete need to repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers. That first component is designed to create every ordered combination across two input collections, which does not accomplish the requested task to repeat provider-specific nested blocks from a collection, even though the other measure satisfies create instances keyed by stable identifiers.
B:The first measure is intended to recover from dynamic expression errors with an alternative result: Try evaluates arguments until one succeeds; it should not mask known structural errors or replace explicit input validation; this behavior should be assessed against the concrete need to repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers. The second measure is intended to parse JSON into Terraform lists, objects, numbers, strings, and Booleans: Decoding returns native expression values; it is not a remote data-source read or a YAML parser; this behavior should be assessed against the concrete need to repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers. Neither is the directly designated method for the separate goals of repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers in this review.
C:The second measure does meet the create instances keyed by stable identifiers requirement, but the first is designed for another concern: The [*] form is concise for sequences; map-valued for_each resources usually require a for expression instead; this behavior should be assessed against the concrete need to repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers. That first component is designed to collect the same attribute from every list-like object, which does not accomplish the requested task to repeat provider-specific nested blocks from a collection, even though the other measure satisfies create instances keyed by stable identifiers.
E:The first measure meets the requirement to repeat provider-specific nested blocks from a collection, but its partner serves a different role: 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 repeat provider-specific nested blocks from a collection and create instances keyed by stable identifiers. That second component is designed to derive a smaller subnet CIDR from a parent prefix, so the still-missing criterion is to create instances keyed by stable identifiers, while the first criterion remains repeat provider-specific nested blocks from a collection.
Question 370
A Terraform rollout has separate acceptance criteria: avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics. Which combined approach directly satisfies the two criteria?
- Use an attribute reference for an implicit edge + Use
replace_triggered_by rather than depends_on for forced rebuilding
- Recognize lifecycle arguments are evaluated early + Use
create_before_destroy = true
- Use
terraform_data for value-driven replacement triggers + Use explicit dependencies on module calls carefully
- Recognize lifecycle arguments are evaluated early + Use
replace_triggered_by rather than depends_on for forced rebuilding
- Use
ignore_changes = [tags] + Use replace_triggered_by rather than depends_on for forced rebuilding
Explanation
Correct Answer
D:For the first criterion, 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 and differentiate operation ordering from replacement semantics; this directly addresses the need to avoid dynamic expressions for create_before_destroy and similar rules. For the separate second criterion, 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 and differentiate operation ordering from replacement semantics; this fulfills the need to differentiate operation ordering from replacement semantics. Together they cover the independent tasks of avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the differentiate operation ordering from replacement semantics requirement, but the first is designed for another concern: 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 avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics. That first component is designed to order resources when the second consumes a value from the first, which does not accomplish the requested task to avoid dynamic expressions for create_before_destroy and similar rules, even though the other measure satisfies differentiate operation ordering from replacement semantics.
B:The first measure meets the requirement to avoid dynamic expressions for create_before_destroy and similar rules, but its partner serves a different role: This lifecycle rule can reduce service interruption where unique names and quotas allow coexistence; it cannot guarantee an API permits two simultaneous objects; this behavior should be assessed against the concrete need to avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics. That second component is designed to request creation of a replacement before deleting the old instance, so the still-missing criterion is to differentiate operation ordering from replacement semantics, while the first criterion remains avoid dynamic expressions for create_before_destroy and similar rules.
C:The first measure is intended to represent an input change through a managed resource lifecycle: 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 avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics. The second measure is intended to delay all operations in a child module until required prerequisites complete: 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 avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics. Neither is the directly designated method for the separate goals of avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics in this review.
E:The second measure does meet the differentiate operation ordering from replacement semantics requirement, but the first is designed for another concern: Ignore-changes permits another process to adjust specified fields without Terraform constantly reverting them; it does not ignore creation-time arguments; this behavior should be assessed against the concrete need to avoid dynamic expressions for create_before_destroy and similar rules and differentiate operation ordering from replacement semantics. That first component is designed to exclude selected post-creation attribute differences from update planning, which does not accomplish the requested task to avoid dynamic expressions for create_before_destroy and similar rules, even though the other measure satisfies differentiate operation ordering from replacement semantics.