Question 320
An author is choosing between ordered and keyed inputs. The requirement is to validate required properties rather than accepting arbitrary untyped maps. Which Terraform mechanism directly meets this requirement?
- Use
type = any sparingly
- Use
set(string) for unique unordered strings
- Use structural object attributes in module interfaces
- Use
map(string) for named string values
- Use
tomap(...) to make a map
Explanation
Correct Answer
C: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. This directly supports the task to validate required properties rather than accepting arbitrary untyped maps during a planned migration.
Incorrect Answers
A: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. It may support a related workflow, but the question specifically requires the mechanism for validate required properties rather than accepting arbitrary untyped maps rather than permit values of varying shapes where a strict contract is impractical.
B: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 validate required properties rather than accepting arbitrary untyped maps. The stated requirement is to validate required properties rather than accepting arbitrary untyped maps, not to enforce uniqueness without relying on list positions; this alternative addresses a different control or phase.
D: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. The distinction matters here: using that mechanism to look up values by arbitrary string keys would still leave the objective to validate required properties rather than accepting arbitrary untyped maps unmet.
E: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 validate required properties rather than accepting arbitrary untyped maps. It may support a related workflow, but the question specifically requires the mechanism for validate required properties rather than accepting arbitrary untyped maps rather than convert a compatible value into a homogeneous keyed collection.
Question 321
During a module implementation, one task is to obtain a map entry with a fallback for an absent key, while another is to append sequences while retaining element order. Select the matching pair of techniques.
- Use
lookup(map, key, default) + Use format("%s-%d", name, number)
- Use
coalesce(a, b, ...) + Use concat(list1, list2)
- Use
contains(collection, value) + Use a conditional condition ? yes : no
- Use
lookup(map, key, default) + Use concat(list1, list2)
- Use
split(delimiter, string) + Use concat(list1, list2)
- Use
lookup(map, key, default) + Use jsondecode(text)
Explanation
Correct Answer
D:For the first criterion, lookup returns the named value when present and the fallback otherwise; direct map indexing may fail when the key is missing; this behavior should be assessed against the concrete need to obtain a map entry with a fallback for an absent key and append sequences while retaining element order; this directly addresses the need to obtain a map entry with a fallback for an absent key. For the separate second criterion, 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 obtain a map entry with a fallback for an absent key and append sequences while retaining element order; this fulfills the need to append sequences while retaining element order. Together they cover the independent tasks of obtain a map entry with a fallback for an absent key and append sequences while retaining element order without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure meets the requirement to obtain a map entry with a fallback for an absent key, but its partner serves a different role: Format substitutes values into placeholders; it does not validate whether the resulting identifier is accepted by a cloud provider; this behavior should be assessed against the concrete need to obtain a map entry with a fallback for an absent key and append sequences while retaining element order. That second component is designed to build a string using a controlled formatting pattern, so the still-missing criterion is to append sequences while retaining element order, while the first criterion remains obtain a map entry with a fallback for an absent key.
B:The second measure does meet the append sequences while retaining element order 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 obtain a map entry with a fallback for an absent key and append sequences while retaining element order. That first component is designed to choose the first non-null and nonempty-string value, which does not accomplish the requested task to obtain a map entry with a fallback for an absent key, even though the other measure satisfies append sequences while retaining element order.
C:The first measure is intended to test whether a collection includes a particular element: 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 obtain a map entry with a fallback for an absent key and append sequences while retaining element order. 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 obtain a map entry with a fallback for an absent key and append sequences while retaining element order. Neither is the directly designated method for the separate goals of obtain a map entry with a fallback for an absent key and append sequences while retaining element order in this review.
E:The second measure does meet the append sequences while retaining element order requirement, but the first is designed for another concern: 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 obtain a map entry with a fallback for an absent key and append sequences while retaining element order. That first component is designed to divide text into a list around a separator, which does not accomplish the requested task to obtain a map entry with a fallback for an absent key, even though the other measure satisfies append sequences while retaining element order.
F:The first measure meets the requirement to obtain a map entry with a fallback for an absent key, but its partner serves a different role: 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 obtain a map entry with a fallback for an absent key and append sequences while retaining element order. That second component is designed to parse JSON into Terraform lists, objects, numbers, strings, and Booleans, so the still-missing criterion is to append sequences while retaining element order, while the first criterion remains obtain a map entry with a fallback for an absent key.
Question 322
A reviewer has to approve a two-part design: exclude selected post-creation attribute differences from update planning; additionally, represent an input change through a managed resource lifecycle. Which option pairs the correct mechanisms?
- Recognize propagated
create_before_destroy behavior + Use terraform_data for value-driven replacement triggers
- Use
ignore_changes = [tags] + Avoid a circular dependency graph
- Use
ignore_changes = [tags] + Use terraform_data for value-driven replacement triggers
- Use an attribute reference for an implicit edge + Use
prevent_destroy = true on a configured resource
Explanation
Correct Answer
C:For the first criterion, 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 exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle; this directly addresses the need to exclude selected post-creation attribute differences from update planning. For the separate second criterion, 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 exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle; this fulfills the need to represent an input change through a managed resource lifecycle. Together they cover the independent tasks of exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the represent an input change through a managed resource lifecycle requirement, but the first is designed for another concern: 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 exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle. That first component is designed to understand why a dependency may also be retained during a replacement, which does not accomplish the requested task to exclude selected post-creation attribute differences from update planning, even though the other measure satisfies represent an input change through a managed resource lifecycle.
B:The first measure meets the requirement to exclude selected post-creation attribute differences from update planning, but its partner serves a different role: Terraform cannot schedule a true cycle in its directed acyclic graph; rearranging references or splitting resource responsibilities can remove the cycle; this behavior should be assessed against the concrete need to exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle. That second component is designed to break mutual dependencies that prevent Terraform from ordering operations, so the still-missing criterion is to represent an input change through a managed resource lifecycle, while the first criterion remains exclude selected post-creation attribute differences from update planning.
D:The first measure is intended to order resources when the second consumes a value from the first: 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 exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle. The second measure is intended to fail a plan that would destroy the protected resource while its block remains: 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 exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle. Neither is the directly designated method for the separate goals of exclude selected post-creation attribute differences from update planning and represent an input change through a managed resource lifecycle in this review.
Question 323
A deployment must validate assumptions or outcomes. The checklist contains independent tasks: (1) separate structural HCL checking from runtime assertions; (2) express the Boolean invariant and its diagnostic message; (3) verify an assumption before Terraform processes the target resource operation. Which three options directly correspond to the respective tasks? Choose THREE.
- Use an output
precondition
- Use a variable
validation block
- Use
try for optional nested values
- Distinguish
terraform validate from in-configuration conditions
- Use a resource
precondition
- Use
assert { condition = ... } inside check
Explanation
Correct Answers
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 separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation. This matches the distinct objective to separate structural HCL checking from runtime assertions; the remaining chosen features address express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation.
E:A lifecycle precondition can inspect values needed for a safe operation; failure blocks proceeding instead of simply recording a health warning; this behavior should be assessed against the concrete need to separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation. This matches the distinct objective to verify an assumption before Terraform processes the target resource operation; the remaining chosen features address separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message.
F:An assert block carries the condition and explanatory error text for a named check; it is not a normal managed resource declaration; this behavior should be assessed against the concrete need to separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation. This matches the distinct objective to express the Boolean invariant and its diagnostic message; the remaining chosen features address separate structural HCL checking from runtime assertions and verify an assumption before Terraform processes the target resource operation.
Incorrect Answers
A:Output preconditions can check values or dependencies before the output is finalized; they keep exported data subject to explicit guarantees; this behavior should be assessed against the concrete need to separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation. Its main application is to ensure a module only exposes results that satisfy a contract; the checklist instead asks for separate structural HCL checking from runtime assertions; and express the Boolean invariant and its diagnostic message; and verify an assumption before Terraform processes the target resource operation. None of those distinct criteria specifically calls for this alternative.
B: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 separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation. Its main application is to reject a malformed module input with a custom message; the checklist instead asks for separate structural HCL checking from runtime assertions; and express the Boolean invariant and its diagnostic message; and verify an assumption before Terraform processes the target resource operation. None of those distinct criteria specifically calls for this alternative.
C: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 separate structural HCL checking from runtime assertions and express the Boolean invariant and its diagnostic message and verify an assumption before Terraform processes the target resource operation. Its main application is to provide a fallback when a dynamic attribute path is absent; the checklist instead asks for separate structural HCL checking from runtime assertions; and express the Boolean invariant and its diagnostic message; and verify an assumption before Terraform processes the target resource operation. None of those distinct criteria specifically calls for this alternative.
Question 324
An engineer needs to hide a secret from ordinary CLI displays as part of a planned migration. Which option is the best fit?
- Use a provider-supported write-only argument
- Use Vault to centralize secret access
- Avoid unnecessary
nonsensitive(...) calls
- Mark a variable
sensitive = true
Explanation
Correct Answer
D:Sensitivity propagates through expressions and hides values in many UI contexts; it does not, by itself, keep the original secret out of state or saved plan files; this behavior should be assessed against the concrete need to hide a secret from ordinary CLI displays. This directly supports the task to hide a secret from ordinary CLI displays during a maintenance request.
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 hide a secret from ordinary CLI displays. It may support a related workflow, but the question specifically requires the mechanism for hide a secret from ordinary CLI displays rather than send a secret to a managed resource without storing its value in plan or state.
B: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 hide a secret from ordinary CLI displays. The stated requirement is to hide a secret from ordinary CLI displays, not to retrieve or distribute sensitive credentials under explicit access policy; this alternative addresses a different control or phase.
C: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 hide a secret from ordinary CLI displays. 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 hide a secret from ordinary CLI displays.
Question 325
In an automated release, the requested result is to consume the ID of an object declared through a resource block. What should the engineer select?
- Recognize
terraform_data as a built-in managed resource
- Reference
aws_instance.web.id for a managed resource
- Select
resource instead of data when deletion must be managed
- Use an
ephemeral resource for supported temporary data
Explanation
Correct Answer
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 consume the ID of an object declared through a resource block. This directly supports the task to consume the ID of an object declared through a resource block during a module implementation.
Incorrect Answers
A: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 consume the ID of an object declared through a resource block. It may support a related workflow, but the question specifically requires the mechanism for consume the ID of an object declared through a resource block rather than store arbitrary values or trigger replacements without a third-party resource API.
C: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 consume the ID of an object declared through a resource block. That can be useful when the aim is to make intentional destruction part of Terraform's lifecycle model, but it does not directly deliver the requested ability to consume the ID of an object declared through a resource block.
D:Ephemeral resources are available for supported providers and valid contexts; they are not ordinary managed resources with persistent state identity; this behavior should be assessed against the concrete need to consume the ID of an object declared through a resource block. The distinction matters here: using that mechanism to obtain a short-lived value without persisting it in state or plan would still leave the objective to consume the ID of an object declared through a resource block unmet.
Question 326
During an automated release, the team must accomplish all of these distinct aims: (1) avoid assuming every computed attribute is fixed during planning; (2) create a stable boundary for modules that callers depend on. Select exactly the two relevant mechanisms. Choose TWO.
- Use
count.index inside counted blocks
- Understand values unknown until apply
- Use
output to expose child internals intentionally
- Use
data.type.name.attribute
- Use
resource_type.name.attribute
- Use
depends_on for hidden ordering requirements
Explanation
Correct Answers
B: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 and create a stable boundary for modules that callers depend on. This matches the distinct objective to avoid assuming every computed attribute is fixed during planning; the remaining chosen features address create a stable boundary for modules that callers depend on.
C: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 avoid assuming every computed attribute is fixed during planning and create a stable boundary for modules that callers depend on. This matches the distinct objective to create a stable boundary for modules that callers depend on; the remaining chosen features address avoid assuming every computed attribute is fixed during planning.
Incorrect Answers
A: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 avoid assuming every computed attribute is fixed during planning and create a stable boundary for modules that callers depend on. Its main application is to identify the zero-based index of the current instance; the checklist instead asks for avoid assuming every computed attribute is fixed during planning; and create a stable boundary for modules that callers depend on. None of those distinct criteria specifically calls for this alternative.
D: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 and create a stable boundary for modules that callers depend on. Its main application is to retrieve an attribute of a declared data source; the checklist instead asks for avoid assuming every computed attribute is fixed during planning; and create a stable boundary for modules that callers depend on. None of those distinct criteria specifically calls for this alternative.
E: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 avoid assuming every computed attribute is fixed during planning and create a stable boundary for modules that callers depend on. Its main application is to read a named attribute from a managed resource; the checklist instead asks for avoid assuming every computed attribute is fixed during planning; and create a stable boundary for modules that callers depend on. None of those distinct criteria specifically calls for this alternative.
F: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 avoid assuming every computed attribute is fixed during planning and create a stable boundary for modules that callers depend on. Its main application is to declare a relationship that cannot be expressed through an input attribute; the checklist instead asks for avoid assuming every computed attribute is fixed during planning; and create a stable boundary for modules that callers depend on. None of those distinct criteria specifically calls for this alternative.
Question 327
A CI job injects environment-dependent values. Two independent changes are requested: first, suppress ordinary disclosure of a secret in Terraform output; second, expose a selected computed value after provisioning. Which pair of measures fulfills both?
- Mark a variable
sensitive = true + Set nullable = false for a required non-null variable
- Mark a variable
sensitive = true + Define output for a root result
- Use
terraform.tfvars or *.auto.tfvars + Define output for a root result
- Omit
default to require a variable value + Define output for a root result
- Pass values through
-var-file=custom.tfvars + Set default for an optional configuration input
Explanation
Correct Answer
B:For the first criterion, 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 and expose a selected computed value after provisioning; this directly addresses the need to suppress ordinary disclosure of a secret in Terraform output. For the separate second criterion, 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 suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning; this fulfills the need to expose a selected computed value after provisioning. Together they cover the independent tasks of suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure meets the requirement to suppress ordinary disclosure of a secret in Terraform output, but its partner serves a different role: The nullable setting controls whether null can be supplied; it is different from a missing default and distinct from sensitive output masking; this behavior should be assessed against the concrete need to suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning. That second component is designed to reject explicit null values instead of treating them as ordinary accepted inputs, so the still-missing criterion is to expose a selected computed value after provisioning, while the first criterion remains suppress ordinary disclosure of a secret in Terraform output.
C:The second measure does meet the expose a selected computed value after provisioning requirement, but the first is designed for another concern: Terraform discovers these conventional names during CLI runs; arbitrarily named .tfvars files require explicit selection; this behavior should be assessed against the concrete need to suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning. That first component is designed to automatically load documented variable files in a root module, which does not accomplish the requested task to suppress ordinary disclosure of a secret in Terraform output, even though the other measure satisfies expose a selected computed value after provisioning.
D:The second measure does meet the expose a selected computed value after provisioning requirement, but the first is designed for another concern: A variable without a default is required; terraform prompts when interactive input is allowed or reports missing input otherwise; this behavior should be assessed against the concrete need to suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning. That first component is designed to make callers supply a necessary input during planning or applying, which does not accomplish the requested task to suppress ordinary disclosure of a secret in Terraform output, even though the other measure satisfies expose a selected computed value after provisioning.
E:The first measure is intended to load named environment inputs that are not automatically discovered: 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 suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning. The second measure is intended to supply a fallback when the caller omits the variable: A default provides a value without per-run input; a caller can still override it using a supported variable assignment mechanism; this behavior should be assessed against the concrete need to suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning. Neither is the directly designated method for the separate goals of suppress ordinary disclosure of a secret in Terraform output and expose a selected computed value after provisioning in this review.
Question 328
A configuration review examines list, map, object, tuple, and set semantics. A reviewer must determine how to remove duplicates and produce set semantics for iteration. Which action is the appropriate choice?
- Access a list with
var.zones[0]
- Use structural object attributes in module interfaces
- Convert values with
toset(...)
- Convert values with
tolist(...)
- Use
set(string) for unique unordered strings
Explanation
Correct Answer
C: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. This directly supports the task to remove duplicates and produce set semantics for iteration during a cross-team handoff.
Incorrect Answers
A: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. The stated requirement is to remove duplicates and produce set semantics for iteration, not to retrieve the first element of an ordered collection; this alternative addresses a different control or phase.
B: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 remove duplicates and produce set semantics for iteration. That can be useful when the aim is to validate required properties rather than accepting arbitrary untyped maps, but it does not directly deliver the requested ability to remove duplicates and produce set semantics for iteration.
D: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 remove duplicates and produce set semantics for iteration. It may support a related workflow, but the question specifically requires the mechanism for remove duplicates and produce set semantics for iteration rather than produce a list value when a downstream expression requires list semantics.
E: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. The stated requirement is to remove duplicates and produce set semantics for iteration, not to enforce uniqueness without relying on list positions; this alternative addresses a different control or phase.
Question 329
A reviewer has to approve a two-part design: divide text into a list around a separator; additionally, measure the number of elements or characters in a value. Which option pairs the correct mechanisms?
- Use
split(delimiter, string) + Use length(value) for a collection or string
- Use
split(delimiter, string) + Use count for numbered resource instances
- Use
setproduct(a, b) + Use length(value) for a collection or string
- Use
jsondecode(text) + Use format("%s-%d", name, number)
- Use
split(delimiter, string) + Use jsonencode(value)
- Use
merge(map1, map2) + Use length(value) for a collection or string
Explanation
Correct Answer
A:For the first criterion, 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 and measure the number of elements or characters in a value; this directly addresses the need to divide text into a list around a separator. For the separate second criterion, length works with strings and collections; it does not estimate provisioned resource counts when values are unknown; this behavior should be assessed against the concrete need to divide text into a list around a separator and measure the number of elements or characters in a value; this fulfills the need to measure the number of elements or characters in a value. Together they cover the independent tasks of divide text into a list around a separator and measure the number of elements or characters in a value without exchanging the responsibilities of these features.
Incorrect Answers
B:The first measure meets the requirement to divide text into a list around a separator, but its partner serves a different role: Count produces addresses indexed by integers; changing list order may shift how items map to instances when coupled with positional inputs; this behavior should be assessed against the concrete need to divide text into a list around a separator and measure the number of elements or characters in a value. That second component is designed to create a known number of repeated managed resource instances, so the still-missing criterion is to measure the number of elements or characters in a value, while the first criterion remains divide text into a list around a separator.
C:The second measure does meet the measure the number of elements or characters in a value 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 divide text into a list around a separator and measure the number of elements or characters in a value. That first component is designed to create every ordered combination across two input collections, which does not accomplish the requested task to divide text into a list around a separator, even though the other measure satisfies measure the number of elements or characters in a value.
D:The first 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 divide text into a list around a separator and measure the number of elements or characters in a value. The second measure is intended to build a string using a controlled formatting pattern: Format substitutes values into placeholders; it does not validate whether the resulting identifier is accepted by a cloud provider; this behavior should be assessed against the concrete need to divide text into a list around a separator and measure the number of elements or characters in a value. Neither is the directly designated method for the separate goals of divide text into a list around a separator and measure the number of elements or characters in a value in this review.
E:The first measure meets the requirement to divide text into a list around a separator, but its partner serves a different role: 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 divide text into a list around a separator and measure the number of elements or characters in a value. That second component is designed to serialize a Terraform value into JSON text for an API argument, so the still-missing criterion is to measure the number of elements or characters in a value, while the first criterion remains divide text into a list around a separator.
F:The second measure does meet the measure the number of elements or characters in a value requirement, but the first is designed for another concern: Merge returns one map/object composed from inputs; it does not concatenate list elements or destroy original remote objects; this behavior should be assessed against the concrete need to divide text into a list around a separator and measure the number of elements or characters in a value. That first component is designed to combine maps with later arguments overriding duplicate keys, which does not accomplish the requested task to divide text into a list around a separator, even though the other measure satisfies measure the number of elements or characters in a value.
Question 330
In a planned migration, the requested result is to request creation of a replacement before deleting the old instance. What should the engineer select?
- Use graph parallelism for independent resources
- Use
replace_triggered_by for resource change coupling
- Use
create_before_destroy = true
- Use
replace_triggered_by rather than depends_on for forced rebuilding
Explanation
Correct Answer
C: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 request creation of a replacement before deleting the old instance. This directly supports the task to request creation of a replacement before deleting the old instance during a deployment checklist.
Incorrect Answers
A: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 request creation of a replacement before deleting the old instance. The distinction matters here: using that mechanism to allow unrelated operations to proceed concurrently would still leave the objective to request creation of a replacement before deleting the old instance unmet.
B: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 request creation of a replacement before deleting the old instance. It may support a related workflow, but the question specifically requires the mechanism for request creation of a replacement before deleting the old instance rather than replace a resource when another managed resource or attribute changes.
D:A dependency establishes when work runs; it does not by itself demand a replacement of an unchanged dependent object; this behavior should be assessed against the concrete need to request creation of a replacement before deleting the old instance. That can be useful when the aim is to differentiate operation ordering from replacement semantics, but it does not directly deliver the requested ability to request creation of a replacement before deleting the old instance.