Question 340
During a deployment checklist, one task is to omit short-lived input values from state and plan artifacts, while another is to obtain runtime-only data through an ephemeral provider operation. Select the matching pair of techniques.
- Use Vault to centralize secret access + Avoid unnecessary
nonsensitive(...) calls
- Mark a variable
ephemeral = true + Use an ephemeral resource to retrieve supported temporary secrets
- Rotate credentials after suspected disclosure + Use an
ephemeral resource to retrieve supported temporary secrets
- Mark a variable
ephemeral = true + Avoid committing secret .tfvars values
Explanation
Correct Answer
B:For the first criterion, 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 and obtain runtime-only data through an ephemeral provider operation; this directly addresses the need to omit short-lived input values from state and plan artifacts. For the separate second criterion, ephemeral resources avoid persisting their results in Terraform's normal state and plan artifacts; their values cannot be used in arbitrary persistent resource fields; this behavior should be assessed against the concrete need to omit short-lived input values from state and plan artifacts and obtain runtime-only data through an ephemeral provider operation; this fulfills the need to obtain runtime-only data through an ephemeral provider operation. Together they cover the independent tasks of omit short-lived input values from state and plan artifacts and obtain runtime-only data through an ephemeral provider operation without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure is intended to retrieve or distribute sensitive credentials under explicit access policy: 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 and obtain runtime-only data through an ephemeral provider operation. The second measure is intended to preserve Terraform's safety indicator for secret-bearing expressions: 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 and obtain runtime-only data through an ephemeral provider operation. Neither is the directly designated method for the separate goals of omit short-lived input values from state and plan artifacts and obtain runtime-only data through an ephemeral provider operation in this review.
C:The second measure does meet the obtain runtime-only data through an ephemeral provider operation requirement, but the first is designed for another concern: 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 omit short-lived input values from state and plan artifacts and obtain runtime-only data through an ephemeral provider operation. That first component is designed to reduce risk when secrets were written to state or repository history, which does not accomplish the requested task to omit short-lived input values from state and plan artifacts, even though the other measure satisfies obtain runtime-only data through an ephemeral provider operation.
D:The first measure meets the requirement to omit short-lived input values from state and plan artifacts, but its partner serves a different role: 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 omit short-lived input values from state and plan artifacts and obtain runtime-only data through an ephemeral provider operation. That second component is designed to prevent credentials from entering source history, so the still-missing criterion is to obtain runtime-only data through an ephemeral provider operation, while the first criterion remains omit short-lived input values from state and plan artifacts.
Question 341
An HCL author is separating managed infrastructure from lookups. Two independent changes are requested: first, consume the ID of an object declared through a resource block; second, retrieve remote information for evaluating the proposed change. Which pair of measures fulfills both?
- Reference
aws_instance.web.id for a managed resource + Distinguish locals from remote resource declarations
- Reference
data.aws_ami.base.id for a lookup + Read data sources during planning when inputs are known
- Reference
aws_instance.web.id for a managed resource + Read data sources during planning when inputs are known
- Use an
ephemeral resource for supported temporary data + Select resource instead of data when deletion must be managed
Explanation
Correct Answer
C:For the first 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 consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change; this directly addresses the need to consume the ID of an object declared through a resource block. For the separate second criterion, 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 consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change; this fulfills the need to retrieve remote information for evaluating the proposed change. Together they cover the independent tasks of consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure meets the requirement to consume the ID of an object declared through a resource block, but its partner serves a different role: Local values are named expressions evaluated inside a module; they neither invoke resource creation nor bind a remote object into state; this behavior should be assessed against the concrete need to consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change. That second component is designed to compute reusable expression results without creating an API object, so the still-missing criterion is to retrieve remote information for evaluating the proposed change, while the first criterion remains consume the ID of an object declared through a resource block.
B:The second measure does meet the retrieve remote information for evaluating the proposed change requirement, but the first is designed for another concern: The data. address prefix distinguishes a read-only lookup from a managed resource address; its value can feed managed resources without importing the looked-up object; this behavior should be assessed against the concrete need to consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change. That first component is designed to use an attribute returned by a provider data source, which does not accomplish the requested task to consume the ID of an object declared through a resource block, even though the other measure satisfies retrieve remote information for evaluating the proposed change.
D:The first measure is intended to obtain a short-lived value without persisting it in state or plan: 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 and retrieve remote information for evaluating the proposed change. The second 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 consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change. Neither is the directly designated method for the separate goals of consume the ID of an object declared through a resource block and retrieve remote information for evaluating the proposed change in this review.
Question 342
During a module implementation, one task is to read a named attribute from a managed resource, while another is to identify the stable key of the current map or set instance. Select the matching pair of techniques.
- Use
local.prefix + Use module.network.subnet_id
- Use
resource_type.name.attribute + Use each.key in for_each blocks
- Use
output to expose child internals intentionally + Use each.key in for_each blocks
- Use
resource_type.name.attribute + Understand values unknown until apply
Explanation
Correct Answer
B: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 identify the stable key of the current map or set instance; this directly addresses the need to read a named attribute from a managed resource. For the separate second criterion, keys form instance addresses such as resource.name["blue"]; the key is not the same as a numeric count.index; this behavior should be assessed against the concrete need to read a named attribute from a managed resource and identify the stable key of the current map or set instance; this fulfills the need to identify the stable key of the current map or set instance. Together they cover the independent tasks of read a named attribute from a managed resource and identify the stable key of the current map or set instance without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure is intended to reference a computed local value in the same module: 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 and identify the stable key of the current map or set instance. The second measure is intended to consume a value explicitly exposed by a child module: 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 identify the stable key of the current map or set instance. Neither is the directly designated method for the separate goals of read a named attribute from a managed resource and identify the stable key of the current map or set instance in this review.
C:The second measure does meet the identify the stable key of the current map or set instance requirement, but the first is designed for another concern: 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 and identify the stable key of the current map or set instance. That first component is designed to create a stable boundary for modules that callers depend on, which does not accomplish the requested task to read a named attribute from a managed resource, even though the other measure satisfies identify the stable key of the current map or set instance.
D: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 identify the stable key of the current map or set instance. That second component is designed to avoid assuming every computed attribute is fixed during planning, so the still-missing criterion is to identify the stable key of the current map or set instance, while the first criterion remains read a named attribute from a managed resource.
Question 343
A reviewer has to approve a two-part design: set a variable for one CLI operation; additionally, automatically load documented variable files in a root module. Which option pairs the correct mechanisms?
- Define
output for a root result + Use terraform.tfvars or *.auto.tfvars
- Pass values through
-var='name=value' + Recognize variable scope is per module
- Use a child-module output as
module.app.endpoint + Use terraform.tfvars or *.auto.tfvars
- Pass values through
-var='name=value' + Use terraform.tfvars or *.auto.tfvars
- Set
default for an optional configuration input + Declare variable "name" with a type constraint
Explanation
Correct Answer
D:For the first criterion, 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 set a variable for one CLI operation and automatically load documented variable files in a root module; this directly addresses the need to set a variable for one CLI operation. For the separate second criterion, 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 set a variable for one CLI operation and automatically load documented variable files in a root module; this fulfills the need to automatically load documented variable files in a root module. Together they cover the independent tasks of set a variable for one CLI operation and automatically load documented variable files in a root module without exchanging the responsibilities of these features.
Incorrect Answers
A:The second measure does meet the automatically load documented variable files in a root module requirement, but the first is designed for another concern: 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 set a variable for one CLI operation and automatically load documented variable files in a root module. That first component is designed to expose a selected computed value after provisioning, which does not accomplish the requested task to set a variable for one CLI operation, even though the other measure satisfies automatically load documented variable files in a root module.
B:The first measure meets the requirement to set a variable for one CLI operation, but its partner serves a different role: 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 set a variable for one CLI operation and automatically load documented variable files in a root module. That second component is designed to avoid reading a root input directly from an unrelated child module, so the still-missing criterion is to automatically load documented variable files in a root module, while the first criterion remains set a variable for one CLI operation.
C:The second measure does meet the automatically load documented variable files in a root module requirement, but the first is designed for another concern: 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 set a variable for one CLI operation and automatically load documented variable files in a root module. That first component is designed to transfer computed values from a child module to its caller, which does not accomplish the requested task to set a variable for one CLI operation, even though the other measure satisfies automatically load documented variable files in a root module.
E:The first 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 set a variable for one CLI operation and automatically load documented variable files in a root module. 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 set a variable for one CLI operation and automatically load documented variable files in a root module. Neither is the directly designated method for the separate goals of set a variable for one CLI operation and automatically load documented variable files in a root module in this review.
Question 344
In a planned migration, the requested result is to look up values by arbitrary string keys. What should the engineer select?
- Use
flatten(...) for nested lists
- Access a map with
var.tags["owner"]
- Use
tomap(...) to make a map
- Use
map(string) for named string values
- Use
type = any sparingly
Explanation
Correct Answer
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 look up values by arbitrary string keys. This directly supports the task to look up values by arbitrary string keys during a deployment checklist.
Incorrect Answers
A: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 look up values by arbitrary string keys. The distinction matters here: using that mechanism to collapse a list of lists into one sequence would still leave the objective to look up values by arbitrary string keys unmet.
B: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 look up values by arbitrary string keys. It may support a related workflow, but the question specifically requires the mechanism for look up values by arbitrary string keys rather than read a string-keyed collection value.
C: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 look up values by arbitrary string keys. The stated requirement is to look up values by arbitrary string keys, not to convert a compatible value into a homogeneous keyed collection; this alternative addresses a different control or phase.
E: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 look up values by arbitrary string keys. The distinction matters here: using that mechanism to permit values of varying shapes where a strict contract is impractical would still leave the objective to look up values by arbitrary string keys unmet.
Question 345
An engineer needs to build an object keyed by input identifiers as part of a planned migration. Which option is the best fit?
- Use
try(expr, fallback)
- Use
for_each with a map or set of strings
- Use
replace(text, old, new)
- Use a
dynamic block to generate nested blocks
- Use
{ for k, v in items : k => v.id }
Explanation
Correct Answer
E:Object-form for expressions produce named entries; duplicate output keys require deliberate grouping rather than silently overwriting an element; this behavior should be assessed against the concrete need to build an object keyed by input identifiers. This directly supports the task to build an object keyed by input identifiers during a maintenance request.
Incorrect Answers
A: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 build an object keyed by input identifiers. That can be useful when the aim is to recover from dynamic expression errors with an alternative result, but it does not directly deliver the requested ability to build an object keyed by input identifiers.
B: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 build an object keyed by input identifiers. The distinction matters here: using that mechanism to create instances keyed by stable identifiers would still leave the objective to build an object keyed by input identifiers unmet.
C:Replace performs value transformation during evaluation; it does not trigger replacement of a managed resource by itself; this behavior should be assessed against the concrete need to build an object keyed by input identifiers. It may support a related workflow, but the question specifically requires the mechanism for build an object keyed by input identifiers rather than substitute matching text or patterns in a string.
D:Dynamic blocks create nested configuration blocks, not top-level resources or meta-argument blocks; iteration can use for_each inside the dynamic block; this behavior should be assessed against the concrete need to build an object keyed by input identifiers. The stated requirement is to build an object keyed by input identifiers, not to repeat provider-specific nested blocks from a collection; this alternative addresses a different control or phase.
Question 346
A platform team must control dependencies and replacements. The requirement is to remove dependents before the infrastructure they rely on. Which Terraform mechanism directly meets this requirement?
- Use an attribute reference for an implicit edge
- Use
depends_on for a hidden dependency
- Use
create_before_destroy = true
- Use
terraform_data for value-driven replacement triggers
- Understand destroy order as dependency-aware
Explanation
Correct Answer
E: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 remove dependents before the infrastructure they rely on. This directly supports the task to remove dependents before the infrastructure they rely on during an automated release.
Incorrect Answers
A: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 remove dependents before the infrastructure they rely on. The stated requirement is to remove dependents before the infrastructure they rely on, not to order resources when the second consumes a value from the first; this alternative addresses a different control or phase.
B:Explicit dependencies model side effects or prerequisites that Terraform cannot infer from values; they may reduce concurrency or defer data-source reads; this behavior should be assessed against the concrete need to remove dependents before the infrastructure they rely on. That can be useful when the aim is to order operations even when no output attribute is consumed, but it does not directly deliver the requested ability to remove dependents before the infrastructure they rely on.
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 remove dependents before the infrastructure they rely on. The distinction matters here: using that mechanism to request creation of a replacement before deleting the old instance would still leave the objective to remove dependents before the infrastructure they rely on unmet.
D: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 remove dependents before the infrastructure they rely on. It may support a related workflow, but the question specifically requires the mechanism for remove dependents before the infrastructure they rely on rather than represent an input change through a managed resource lifecycle.
Question 347
A deployment must validate assumptions or outcomes. A reviewer must determine how to reject a malformed module input with a custom message. Which action is the appropriate choice?
- Use a postcondition for a provider-computed result
- Use variable validation for valid network prefixes
- Use
assert { condition = ... } inside check
- Use a variable
validation block
Explanation
Correct Answer
D: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. This directly supports the task to reject a malformed module input with a custom message during a staged rollout.
Incorrect Answers
A: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 reject a malformed module input with a custom message. It may support a related workflow, but the question specifically requires the mechanism for reject a malformed module input with a custom message rather than test a guarantee only after the remote result is known.
B: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 reject a malformed module input with a custom message. The stated requirement is to reject a malformed module input with a custom message, not to reject malformed or disallowed input before resource creation; this alternative addresses a different control or phase.
C:An assert block carries the condition and explanatory error text for a named check; it is not a normal managed resource declaration; this behavior should be assessed against the concrete need to reject a malformed module input with a custom message. That can be useful when the aim is to express the Boolean invariant and its diagnostic message, but it does not directly deliver the requested ability to reject a malformed module input with a custom message.
Question 348
A reviewer has to approve a two-part design: reduce dependence on hardcoded long-lived API keys; additionally, choose secrecy controls based on persistence as well as output redaction. Which option pairs the correct mechanisms?
- Mark a variable
ephemeral = true + Protect access to remote state
- Use HCP Terraform sensitive workspace variables + Distinguish
ephemeral from sensitive
- Use short-lived cloud identities for automation + Distinguish
ephemeral from sensitive
- Use short-lived cloud identities for automation + Use a provider-supported write-only argument
Explanation
Correct Answer
C:For the first criterion, dynamic provider credentials or workload federation can issue bounded run-specific authorization; this limits blast radius while still requiring correct API permissions; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction; this directly addresses the need to reduce dependence on hardcoded long-lived API keys. For the separate second criterion, sensitive marks affect presentation; ephemeral marks constrain persistence and permitted expression contexts; they solve related but nonidentical problems; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction; this fulfills the need to choose secrecy controls based on persistence as well as output redaction. Together they cover the independent tasks of reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction without exchanging the responsibilities of these features.
Incorrect Answers
A:The first measure is intended to omit short-lived input values from state and plan artifacts: Ephemeral values have restricted usable contexts such as provider configuration and write-only arguments; they are appropriate for transient tokens that must not be persisted; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction. The second 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 reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction. Neither is the directly designated method for the separate goals of reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction in this review.
B:The second measure does meet the choose secrecy controls based on persistence as well as output redaction requirement, but the first is designed for another concern: HCP Terraform offers marked-sensitive variables for workspace runs; their handling is a platform feature, not evidence that every resulting resource attribute is absent from state; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction. That first component is designed to restrict display of secret input values in hosted runs, which does not accomplish the requested task to reduce dependence on hardcoded long-lived API keys, even though the other measure satisfies choose secrecy controls based on persistence as well as output redaction.
D:The first measure meets the requirement to reduce dependence on hardcoded long-lived API keys, 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 reduce dependence on hardcoded long-lived API keys and choose secrecy controls based on persistence as well as output redaction. 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 choose secrecy controls based on persistence as well as output redaction, while the first criterion remains reduce dependence on hardcoded long-lived API keys.
Question 349
A Terraform review separates 2 requirements: (1) use an attribute returned by a provider data source; (2) adopt a previously existing object into Terraform management. Identify the two features that each directly handle one of those requirements. Choose TWO.
- Select
resource instead of data when deletion must be managed
- Reference
aws_instance.web.id for a managed resource
- Distinguish
locals from remote resource declarations
- Understand data source failure on a missing object
- Use a resource block together with an
import block
- Reference
data.aws_ami.base.id for a lookup
Explanation
Correct Answers
E:Import associates the provider's existing remote object with a declared resource address; simply reading it as a data source does not establish that lifecycle ownership; this behavior should be assessed against the concrete need to use an attribute returned by a provider data source and adopt a previously existing object into Terraform management. This matches the distinct objective to adopt a previously existing object into Terraform management; the remaining chosen features address use an attribute returned by a provider data source.
F:The data. address prefix distinguishes a read-only lookup from a managed resource address; its value can feed managed resources without importing the looked-up object; this behavior should be assessed against the concrete need to use an attribute returned by a provider data source and adopt a previously existing object into Terraform management. This matches the distinct objective to use an attribute returned by a provider data source; the remaining chosen features address adopt a previously existing object into Terraform management.
Incorrect Answers
A: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 use an attribute returned by a provider data source and adopt a previously existing object into Terraform management. Its main application is to make intentional destruction part of Terraform's lifecycle model; the checklist instead asks for use an attribute returned by a provider data source; and adopt a previously existing object into Terraform management. None of those distinct criteria specifically calls for this alternative.
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 use an attribute returned by a provider data source and adopt a previously existing object into Terraform management. Its main application is to consume the ID of an object declared through a resource block; the checklist instead asks for use an attribute returned by a provider data source; and adopt a previously existing object into Terraform management. None of those distinct criteria specifically calls for this alternative.
C:Local values are named expressions evaluated inside a module; they neither invoke resource creation nor bind a remote object into state; this behavior should be assessed against the concrete need to use an attribute returned by a provider data source and adopt a previously existing object into Terraform management. Its main application is to compute reusable expression results without creating an API object; the checklist instead asks for use an attribute returned by a provider data source; and adopt a previously existing object into Terraform management. None of those distinct criteria specifically calls for this alternative.
D: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 use an attribute returned by a provider data source and adopt a previously existing object into Terraform management. Its main application is to distinguish a failed lookup from a request to create the missing object; the checklist instead asks for use an attribute returned by a provider data source; and adopt a previously existing object into Terraform management. None of those distinct criteria specifically calls for this alternative.
Question 350
During a module implementation, the team must accomplish all of these distinct aims: (1) collect an attribute from a list-like collection of resource instances; (2) let Terraform infer safe operation order through data flow. Select exactly the two relevant mechanisms. Choose TWO.
- Use
resource.items[*].id for counted instances
- Avoid cyclic resource references
- Use direct attribute references to create implicit dependencies
- Use
local.prefix
- Use
depends_on for hidden ordering requirements
- Use
resource_type.name.attribute
Explanation
Correct Answers
A:Splat expressions iterate list, set, or tuple values, including count-created instances. for_each maps are normally traversed using a for expression; this behavior should be assessed against the concrete need to collect an attribute from a list-like collection of resource instances and let Terraform infer safe operation order through data flow. This matches the distinct objective to collect an attribute from a list-like collection of resource instances; the remaining chosen features address let Terraform infer safe operation order through data flow.
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 collect an attribute from a list-like collection of resource instances and let Terraform infer safe operation order through data flow. This matches the distinct objective to let Terraform infer safe operation order through data flow; the remaining chosen features address collect an attribute from a list-like collection of resource instances.
Incorrect Answers
B: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 collect an attribute from a list-like collection of resource instances and let Terraform infer safe operation order through data flow. Its main application is to prevent a graph in which objects depend on each other without a valid ordering; the checklist instead asks for collect an attribute from a list-like collection of resource instances; and let Terraform infer safe operation order through data flow. None of those distinct criteria specifically calls for this alternative.
D: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 collect an attribute from a list-like collection of resource instances and let Terraform infer safe operation order through data flow. Its main application is to reference a computed local value in the same module; the checklist instead asks for collect an attribute from a list-like collection of resource instances; and let Terraform infer safe operation order through data flow. None of those distinct criteria specifically calls for this alternative.
E: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 collect an attribute from a list-like collection of resource instances and let Terraform infer safe operation order through data flow. Its main application is to declare a relationship that cannot be expressed through an input attribute; the checklist instead asks for collect an attribute from a list-like collection of resource instances; and let Terraform infer safe operation order through data flow. None of those distinct criteria specifically calls for this alternative.
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 collect an attribute from a list-like collection of resource instances and let Terraform infer safe operation order through data flow. Its main application is to read a named attribute from a managed resource; the checklist instead asks for collect an attribute from a list-like collection of resource instances; and let Terraform infer safe operation order through data flow. None of those distinct criteria specifically calls for this alternative.