HashiCorp Terraform Associate (HashiCorp Certified: Terraform Associate) Practice Test 45

Question 440

An author is choosing between ordered and keyed inputs. Two independent changes are requested: first, define a fixed-position sequence with different element types; second, read a string-keyed collection value. Which pair of measures fulfills both?

  1. Convert values with toset(...) + Access a map with var.tags["owner"]
  2. Use tuple([string, number]) + Use tomap(...) to make a map
  3. Use tuple([string, number]) + Access a map with var.tags["owner"]
  4. Use structural object attributes in module interfaces + Use type = any sparingly

Explanation

Correct Answer

C:

For the first criterion, tuples have a declared type for each position; a list(string) would not preserve the intended mixed-element contract; this behavior should be assessed against the concrete need to define a fixed-position sequence with different element types and read a string-keyed collection value; this directly addresses the need to define a fixed-position sequence with different element types. For the separate second criterion, 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 define a fixed-position sequence with different element types and read a string-keyed collection value; this fulfills the need to read a string-keyed collection value. Together they cover the independent tasks of define a fixed-position sequence with different element types and read a string-keyed collection value without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the read a string-keyed collection value requirement, but the first is designed for another concern: 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 define a fixed-position sequence with different element types and read a string-keyed collection value. That first component is designed to remove duplicates and produce set semantics for iteration, which does not accomplish the requested task to define a fixed-position sequence with different element types, even though the other measure satisfies read a string-keyed collection value.

B:

The first measure meets the requirement to define a fixed-position sequence with different element types, but its partner serves a different role: 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 define a fixed-position sequence with different element types and read a string-keyed collection value. That second component is designed to convert a compatible value into a homogeneous keyed collection, so the still-missing criterion is to read a string-keyed collection value, while the first criterion remains define a fixed-position sequence with different element types.

D:

The first measure is intended to validate required properties rather than accepting arbitrary untyped maps: A typed object can express nested requirements clearly; it improves errors when a caller omits a field or supplies an incompatible value; this behavior should be assessed against the concrete need to define a fixed-position sequence with different element types and read a string-keyed collection value. The second measure is intended to permit values of varying shapes where a strict contract is impractical: 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 define a fixed-position sequence with different element types and read a string-keyed collection value. Neither is the directly designated method for the separate goals of define a fixed-position sequence with different element types and read a string-keyed collection value in this review.

Question 441

During a deployment checklist, one task is to require every evaluated Boolean in a collection to be true, while another is to assemble a map from paired key and value lists. Select the matching pair of techniques.

  1. Use alltrue(list_of_bools) + Use zipmap(keys, values)
  2. Use alltrue(list_of_bools) + Use one(collection)
  3. Use [for item in items : item.name] + Use zipmap(keys, values)
  4. Use try(expr, fallback) + Use replace(text, old, new)

Explanation

Correct Answer

A:

For the first criterion, alltrue is useful for validating all entries in an input list; anytrue instead tests whether at least one entry succeeds; this behavior should be assessed against the concrete need to require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists; this directly addresses the need to require every evaluated Boolean in a collection to be true. For the separate second criterion, 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 require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists; this fulfills the need to assemble a map from paired key and value lists. Together they cover the independent tasks of require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure meets the requirement to require every evaluated Boolean in a collection to be true, but its partner serves a different role: One returns the element or null for an empty collection, and errors on more than one; it is useful for conditional singleton resources; this behavior should be assessed against the concrete need to require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists. That second component is designed to require zero or one element and extract the single element when present, so the still-missing criterion is to assemble a map from paired key and value lists, while the first criterion remains require every evaluated Boolean in a collection to be true.

C:

The second measure does meet the assemble a map from paired key and value lists requirement, but the first is designed for another concern: A for expression iterates input elements and constructs values without declaring extra managed resources; it can also filter elements using an if clause; this behavior should be assessed against the concrete need to require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists. That first component is designed to transform a collection into a derived list, which does not accomplish the requested task to require every evaluated Boolean in a collection to be true, even though the other measure satisfies assemble a map from paired key and value lists.

D:

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 require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists. The second measure is intended to substitute matching text or patterns in a string: 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 require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists. Neither is the directly designated method for the separate goals of require every evaluated Boolean in a collection to be true and assemble a map from paired key and value lists in this review.

Question 442

The immediate Terraform task is to understand why a dependency may also be retained during a replacement. Which method handles that task most directly?

  1. Recognize propagated create_before_destroy behavior
  2. Use create_before_destroy = true
  3. Use an attribute reference for an implicit edge
  4. Use ignore_changes = [tags]

Explanation

Correct Answer

A:

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 understand why a dependency may also be retained during a replacement. This directly supports the task to understand why a dependency may also be retained during a replacement during a configuration change.

Incorrect Answers

B:

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 understand why a dependency may also be retained during a replacement. That can be useful when the aim is to request creation of a replacement before deleting the old instance, but it does not directly deliver the requested ability to understand why a dependency may also be retained during a replacement.

C:

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 understand why a dependency may also be retained during a replacement. The distinction matters here: using that mechanism to order resources when the second consumes a value from the first would still leave the objective to understand why a dependency may also be retained during a replacement unmet.

D:

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 understand why a dependency may also be retained during a replacement. It may support a related workflow, but the question specifically requires the mechanism for understand why a dependency may also be retained during a replacement rather than exclude selected post-creation attribute differences from update planning.

Question 443

A Terraform rollout has separate acceptance criteria: test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent. Which combined approach directly satisfies the two criteria?

  1. Use a postcondition for a provider-computed result + Use try for optional nested values
  2. Use assert { condition = ... } inside check + Use a resource postcondition
  3. Use a resource precondition + Use try for optional nested values
  4. Use a postcondition for a provider-computed result + Use a variable validation block

Explanation

Correct Answer

A:

For the first criterion, 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 test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent; this directly addresses the need to test a guarantee only after the remote result is known. For the separate second criterion, 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 test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent; this fulfills the need to provide a fallback when a dynamic attribute path is absent. Together they cover the independent tasks of test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to express the Boolean invariant and its diagnostic message: 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 test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent. The second measure is intended to verify a property after the relevant resource or data evaluation: A lifecycle postcondition checks an expected guarantee and can prevent dependent operations when it fails; it differs from a pre-operation assumption; this behavior should be assessed against the concrete need to test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent. Neither is the directly designated method for the separate goals of test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent in this review.

C:

The second measure does meet the provide a fallback when a dynamic attribute path is absent requirement, but the first is designed for another concern: 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 test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent. That first component is designed to verify an assumption before Terraform processes the target resource operation, which does not accomplish the requested task to test a guarantee only after the remote result is known, even though the other measure satisfies provide a fallback when a dynamic attribute path is absent.

D:

The first measure meets the requirement to test a guarantee only after the remote result is known, but its partner serves a different role: 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 test a guarantee only after the remote result is known and provide a fallback when a dynamic attribute path is absent. That second component is designed to reject a malformed module input with a custom message, so the still-missing criterion is to provide a fallback when a dynamic attribute path is absent, while the first criterion remains test a guarantee only after the remote result is known.

Question 444

A Terraform review separates 3 requirements: (1) reduce dependence on hardcoded long-lived API keys; (2) avoid leaking inputs and backend information through CI downloads; (3) hide a secret from ordinary CLI displays. Identify the three features that each directly handle one of those requirements. Choose THREE.

  1. Mark a secret root output sensitive = true
  2. Treat saved plan files as sensitive artifacts
  3. Mark a variable sensitive = true
  4. Use an ephemeral resource to retrieve supported temporary secrets
  5. Distinguish ephemeral from sensitive
  6. Use short-lived cloud identities for automation

Explanation

Correct Answers

B:

Binary plans can preserve configuration values and secrets; redaction in human-readable output does not make the saved plan safe to publish; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays. This matches the distinct objective to avoid leaking inputs and backend information through CI downloads; the remaining chosen features address reduce dependence on hardcoded long-lived API keys and hide a secret from ordinary CLI displays.

C:

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 reduce dependence on hardcoded long-lived API keys and avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays. This matches the distinct objective to hide a secret from ordinary CLI displays; the remaining chosen features address reduce dependence on hardcoded long-lived API keys and avoid leaking inputs and backend information through CI downloads.

F:

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 avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays. This matches the distinct objective to reduce dependence on hardcoded long-lived API keys; the remaining chosen features address avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays.

Incorrect Answers

A:

Output sensitivity masks typical CLI views; authorized state readers and certain machine-readable commands may still reveal the value; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays. Its main application is to avoid normal display of an output carrying sensitive data; the checklist instead asks for reduce dependence on hardcoded long-lived API keys; and avoid leaking inputs and backend information through CI downloads; and hide a secret from ordinary CLI displays. None of those distinct criteria specifically calls for this alternative.

D:

Ephemeral resources avoid persisting their results in Terraform's normal state and plan artifacts; their values cannot be used in arbitrary persistent resource fields; this behavior should be assessed against the concrete need to reduce dependence on hardcoded long-lived API keys and avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays. Its main application is to obtain runtime-only data through an ephemeral provider operation; the checklist instead asks for reduce dependence on hardcoded long-lived API keys; and avoid leaking inputs and backend information through CI downloads; and hide a secret from ordinary CLI displays. None of those distinct criteria specifically calls for this alternative.

E:

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 avoid leaking inputs and backend information through CI downloads and hide a secret from ordinary CLI displays. Its main application is to choose secrecy controls based on persistence as well as output redaction; the checklist instead asks for reduce dependence on hardcoded long-lived API keys; and avoid leaking inputs and backend information through CI downloads; and hide a secret from ordinary CLI displays. None of those distinct criteria specifically calls for this alternative.

Question 445

A Terraform rollout has separate acceptance criteria: retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API. Which combined approach directly satisfies the two criteria?

  1. Read data sources during planning when inputs are known + Understand data source failure on a missing object
  2. Read data sources during planning when inputs are known + Query an existing object with data
  3. Distinguish locals from remote resource declarations + Use an ephemeral resource for supported temporary data
  4. Reference aws_instance.web.id for a managed resource + Recognize terraform_data as a built-in managed resource
  5. Use provider selection on both resource and data blocks + Recognize terraform_data as a built-in managed resource
  6. Read data sources during planning when inputs are known + Recognize terraform_data as a built-in managed resource

Explanation

Correct Answer

F:

For the first 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 retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API; this directly addresses the need to retrieve remote information for evaluating the proposed change. For the separate second criterion, 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 and store arbitrary values or trigger replacements without a third-party resource API; this fulfills the need to store arbitrary values or trigger replacements without a third-party resource API. Together they cover the independent tasks of retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to retrieve remote information for evaluating the proposed change, but its partner serves a different role: 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 and store arbitrary values or trigger replacements without a third-party resource API. That second component is designed to distinguish a failed lookup from a request to create the missing object, so the still-missing criterion is to store arbitrary values or trigger replacements without a third-party resource API, while the first criterion remains retrieve remote information for evaluating the proposed change.

B:

The first measure meets the requirement to retrieve remote information for evaluating the proposed change, but its partner serves a different role: Data sources ask providers to fetch properties; they do not make Terraform responsible for deleting or updating the queried object; this behavior should be assessed against the concrete need to retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API. That second component is designed to read an object without asking Terraform to create or manage it, so the still-missing criterion is to store arbitrary values or trigger replacements without a third-party resource API, while the first criterion remains retrieve remote information for evaluating the proposed change.

C:

The first measure is intended to compute reusable expression results without creating an API object: 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 retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API. The second 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 retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API. Neither is the directly designated method for the separate goals of retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API in this review.

D:

The second measure does meet the store arbitrary values or trigger replacements without a third-party resource API requirement, but the first is designed for another concern: 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 retrieve remote information for evaluating the proposed change and store arbitrary values or trigger replacements without a third-party resource API. That first component is designed to consume the ID of an object declared through a resource block, which does not accomplish the requested task to retrieve remote information for evaluating the proposed change, even though the other measure satisfies store arbitrary values or trigger replacements without a third-party resource API.

E:

The second measure does meet the store arbitrary values or trigger replacements without a third-party resource API requirement, but the first is designed for another concern: 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 and store arbitrary values or trigger replacements without a third-party resource API. That first component is designed to direct API operations and lookups to the intended account or region, which does not accomplish the requested task to retrieve remote information for evaluating the proposed change, even though the other measure satisfies store arbitrary values or trigger replacements without a third-party resource API.

Question 446

A configuration connects network and compute resources. The team must both read a module input variable inside that module and identify the zero-based index of the current instance. Which paired choice implements those distinct goals?

  1. Use var.region + Use count.index inside counted blocks
  2. Use a for expression over a resource map + Understand values unknown until apply
  3. Use var.region + Use depends_on for hidden ordering requirements
  4. Use resource_type.name.attribute + Use count.index inside counted blocks

Explanation

Correct Answer

A:

For the first criterion, the var. namespace refers to values supplied through the module's interface; it does not directly fetch provider configuration or remote state; this behavior should be assessed against the concrete need to read a module input variable inside that module and identify the zero-based index of the current instance; this directly addresses the need to read a module input variable inside that module. For the separate second criterion, a count meta-argument creates numerically indexed instances. count.index is available in blocks that use count, not as a global value; this behavior should be assessed against the concrete need to read a module input variable inside that module and identify the zero-based index of the current instance; this fulfills the need to identify the zero-based index of the current instance. Together they cover the independent tasks of read a module input variable inside that module and identify the zero-based index of the current instance without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to extract values from instances created with for_each: A map-oriented expression can iterate keys and values to build a list or map; a legacy list-style splat is not the right accessor for a for_each resource map; this behavior should be assessed against the concrete need to read a module input variable inside that module and identify the zero-based index of the current instance. The second measure is intended to avoid assuming every computed attribute is fixed during planning: 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 module input variable inside that module and identify the zero-based index of the current instance. Neither is the directly designated method for the separate goals of read a module input variable inside that module and identify the zero-based index of the current instance in this review.

C:

The first measure meets the requirement to read a module input variable inside that module, but its partner serves a different role: 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 read a module input variable inside that module and identify the zero-based index of the current instance. That second component is designed to declare a relationship that cannot be expressed through an input attribute, so the still-missing criterion is to identify the zero-based index of the current instance, while the first criterion remains read a module input variable inside that module.

D:

The second measure does meet the identify the zero-based index of the current instance requirement, but the first is designed for another concern: 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 module input variable inside that module and identify the zero-based index of the current instance. That first component is designed to read a named attribute from a managed resource, which does not accomplish the requested task to read a module input variable inside that module, even though the other measure satisfies identify the zero-based index of the current instance.

Question 447

A CI job injects environment-dependent values. The checklist contains independent tasks: (1) prevent a temporary secret from being persisted to state and plan files; (2) obtain structured output values in scripts; (3) suppress ordinary disclosure of a secret in Terraform output. Which three options directly correspond to the respective tasks? Choose THREE.

  1. Pass values through -var-file=custom.tfvars
  2. Use validation inside a variable block
  3. Use terraform output -json for machine-readable results
  4. Mark a variable sensitive = true
  5. Use terraform output -raw NAME for a string result
  6. Mark an input variable ephemeral = true

Explanation

Correct Answers

C:

JSON mode includes values and sensitivity metadata; downstream tooling must treat sensitive data carefully; this command reads recorded outputs, not arbitrary provider API properties; this behavior should be assessed against the concrete need to prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output. This matches the distinct objective to obtain structured output values in scripts; the remaining chosen features address prevent a temporary secret from being persisted to state and plan files and suppress ordinary disclosure of a secret in Terraform output.

D:

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 prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output. This matches the distinct objective to suppress ordinary disclosure of a secret in Terraform output; the remaining chosen features address prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts.

F:

Ephemeral inputs have restricted reference contexts such as provider blocks and write-only arguments; sensitivity by itself does not provide the same omission guarantee; this behavior should be assessed against the concrete need to prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output. This matches the distinct objective to prevent a temporary secret from being persisted to state and plan files; the remaining chosen features address obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output.

Incorrect Answers

A:

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 prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output. Its main application is to load named environment inputs that are not automatically discovered; the checklist instead asks for prevent a temporary secret from being persisted to state and plan files; and obtain structured output values in scripts; and suppress ordinary disclosure of a secret in Terraform output. None of those distinct criteria specifically calls for this alternative.

B:

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 prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output. Its main application is to reject caller inputs that violate a Boolean rule; the checklist instead asks for prevent a temporary secret from being persisted to state and plan files; and obtain structured output values in scripts; and suppress ordinary disclosure of a secret in Terraform output. None of those distinct criteria specifically calls for this alternative.

E:

Raw output formats a supported string, number, or Boolean directly without extra Terraform representation; complex objects require another output format; this behavior should be assessed against the concrete need to prevent a temporary secret from being persisted to state and plan files and obtain structured output values in scripts and suppress ordinary disclosure of a secret in Terraform output. Its main application is to retrieve a plain scalar output for shell integration; the checklist instead asks for prevent a temporary secret from being persisted to state and plan files; and obtain structured output values in scripts; and suppress ordinary disclosure of a secret in Terraform output. None of those distinct criteria specifically calls for this alternative.

Question 448

During a deployment checklist, one task is to convert a compatible value into a homogeneous keyed collection, while another is to validate required properties rather than accepting arbitrary untyped maps. Select the matching pair of techniques.

  1. Use set(string) for unique unordered strings + Recognize map iteration's key ordering
  2. Use tomap(...) to make a map + Access a list with var.zones[0]
  3. Use tomap(...) to make a map + Use structural object attributes in module interfaces
  4. Use map(string) for named string values + Use structural object attributes in module interfaces

Explanation

Correct Answer

C:

For the first 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 convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps; this directly addresses the need to convert a compatible value into a homogeneous keyed collection. For the separate second criterion, a typed object can express nested requirements clearly; it improves errors when a caller omits a field or supplies an incompatible value; this behavior should be assessed against the concrete need to convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps; this fulfills the need to validate required properties rather than accepting arbitrary untyped maps. Together they cover the independent tasks of convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first 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 convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps. The second measure is intended to avoid interpreting maps as insertion-ordered sequences: 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 convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps. Neither is the directly designated method for the separate goals of convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps in this review.

B:

The first measure meets the requirement to convert a compatible value into a homogeneous keyed collection, but its partner serves a different role: 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 convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps. That second component is designed to retrieve the first element of an ordered collection, so the still-missing criterion is to validate required properties rather than accepting arbitrary untyped maps, while the first criterion remains convert a compatible value into a homogeneous keyed collection.

D:

The second measure does meet the validate required properties rather than accepting arbitrary untyped maps requirement, but the first is designed for another concern: Maps provide a homogeneous value type and stable keys; they differ from lists, which are indexed by position; this behavior should be assessed against the concrete need to convert a compatible value into a homogeneous keyed collection and validate required properties rather than accepting arbitrary untyped maps. That first component is designed to look up values by arbitrary string keys, which does not accomplish the requested task to convert a compatible value into a homogeneous keyed collection, even though the other measure satisfies validate required properties rather than accepting arbitrary untyped maps.

Question 449

The immediate Terraform task is to test whether an expression can be evaluated without an error. Which method handles that task most directly?

  1. Use a dynamic block to generate nested blocks
  2. Use split(delimiter, string)
  3. Use concat(list1, list2)
  4. Use can(expr)

Explanation

Correct Answer

D:

Can returns a Boolean and is especially useful in custom validation rules; it does not return the underlying expression's successful value; this behavior should be assessed against the concrete need to test whether an expression can be evaluated without an error. This directly supports the task to test whether an expression can be evaluated without an error during a configuration change.

Incorrect Answers

A:

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 test whether an expression can be evaluated without an error. The distinction matters here: using that mechanism to repeat provider-specific nested blocks from a collection would still leave the objective to test whether an expression can be evaluated without an error unmet.

B:

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 test whether an expression can be evaluated without an error. It may support a related workflow, but the question specifically requires the mechanism for test whether an expression can be evaluated without an error rather than divide text into a list around a separator.

C:

Concat combines lists or tuples into one sequence; it does not remove duplicates as a set conversion would; this behavior should be assessed against the concrete need to test whether an expression can be evaluated without an error. The stated requirement is to test whether an expression can be evaluated without an error, not to append sequences while retaining element order; this alternative addresses a different control or phase.

Question 450

In an automated release, the requested result is to delay all operations in a child module until required prerequisites complete. What should the engineer select?

  1. Use ignore_changes = [tags]
  2. Recognize lifecycle arguments are evaluated early
  3. Use explicit dependencies on module calls carefully
  4. Use depends_on for a hidden dependency

Explanation

Correct Answer

C:

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 delay all operations in a child module until required prerequisites complete. This directly supports the task to delay all operations in a child module until required prerequisites complete during a module implementation.

Incorrect Answers

A:

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 delay all operations in a child module until required prerequisites complete. That can be useful when the aim is to exclude selected post-creation attribute differences from update planning, but it does not directly deliver the requested ability to delay all operations in a child module until required prerequisites complete.

B:

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 delay all operations in a child module until required prerequisites complete. The distinction matters here: using that mechanism to avoid dynamic expressions for create_before_destroy and similar rules would still leave the objective to delay all operations in a child module until required prerequisites complete unmet.

D:

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 delay all operations in a child module until required prerequisites complete. The stated requirement is to delay all operations in a child module until required prerequisites complete, not to order operations even when no output attribute is consumed; this alternative addresses a different control or phase.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests