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

Question 430

The immediate Terraform task is to declare a relationship that cannot be expressed through an input attribute. Which method handles that task most directly?

  1. Understand values unknown until apply
  2. Use resource_type.name.attribute
  3. Avoid cyclic resource references
  4. Use depends_on for hidden ordering requirements

Explanation

Correct Answer

D:

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 declare a relationship that cannot be expressed through an input attribute. This directly supports the task to declare a relationship that cannot be expressed through an input attribute during a platform review.

Incorrect Answers

A:

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 declare a relationship that cannot be expressed through an input attribute. It may support a related workflow, but the question specifically requires the mechanism for declare a relationship that cannot be expressed through an input attribute rather than avoid assuming every computed attribute is fixed during planning.

B:

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 declare a relationship that cannot be expressed through an input attribute. The stated requirement is to declare a relationship that cannot be expressed through an input attribute, not to read a named attribute from a managed resource; this alternative addresses a different control or phase.

C:

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 declare a relationship that cannot be expressed through an input attribute. That can be useful when the aim is to prevent a graph in which objects depend on each other without a valid ordering, but it does not directly deliver the requested ability to declare a relationship that cannot be expressed through an input attribute.

Question 431

In a planned migration, the requested result is to avoid reading a root input directly from an unrelated child module. What should the engineer select?

  1. Recognize variable scope is per module
  2. Use a child-module output as module.app.endpoint
  3. Use validation inside a variable block
  4. Set default for an optional configuration input

Explanation

Correct Answer

A:

A child declares its own inputs and receives values in the module call; variables do not automatically become global across the module tree; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module. This directly supports the task to avoid reading a root input directly from an unrelated child module during a deployment checklist.

Incorrect Answers

B:

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 avoid reading a root input directly from an unrelated child module. It may support a related workflow, but the question specifically requires the mechanism for avoid reading a root input directly from an unrelated child module rather than transfer computed values from a child module to its caller.

C:

The condition and custom error message give feedback near the module boundary; it is not an HCP policy set or a provider API permission check; this behavior should be assessed against the concrete need to avoid reading a root input directly from an unrelated child module. The stated requirement is to avoid reading a root input directly from an unrelated child module, not to reject caller inputs that violate a Boolean rule; this alternative addresses a different control or phase.

D:

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 avoid reading a root input directly from an unrelated child module. That can be useful when the aim is to supply a fallback when the caller omits the variable, but it does not directly deliver the requested ability to avoid reading a root input directly from an unrelated child module.

Question 432

An engineer needs to avoid interpreting maps as insertion-ordered sequences as part of a planned migration. Which option is the best fit?

  1. Convert values with toset(...)
  2. Use map(string) for named string values
  3. Use structural object attributes in module interfaces
  4. Recognize map iteration's key ordering

Explanation

Correct Answer

D:

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 avoid interpreting maps as insertion-ordered sequences. This directly supports the task to avoid interpreting maps as insertion-ordered sequences during a maintenance request.

Incorrect Answers

A:

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 avoid interpreting maps as insertion-ordered sequences. That can be useful when the aim is to remove duplicates and produce set semantics for iteration, but it does not directly deliver the requested ability to avoid interpreting maps as insertion-ordered sequences.

B:

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 avoid interpreting maps as insertion-ordered sequences. The distinction matters here: using that mechanism to look up values by arbitrary string keys would still leave the objective to avoid interpreting maps as insertion-ordered sequences unmet.

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 avoid interpreting maps as insertion-ordered sequences. It may support a related workflow, but the question specifically requires the mechanism for avoid interpreting maps as insertion-ordered sequences rather than validate required properties rather than accepting arbitrary untyped maps.

Question 433

A developer is transforming collection values. The checklist contains independent tasks: (1) append sequences while retaining element order; (2) choose the first non-null and nonempty-string value. Which two options directly correspond to the respective tasks? Choose TWO.

  1. Use coalesce(a, b, ...)
  2. Use can(expr)
  3. Use concat(list1, list2)
  4. Use a dynamic block to generate nested blocks
  5. Use file(path) to read local text

Explanation

Correct Answers

A:

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 append sequences while retaining element order and choose the first non-null and nonempty-string value. This matches the distinct objective to choose the first non-null and nonempty-string value; the remaining chosen features address append sequences while retaining element order.

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 append sequences while retaining element order and choose the first non-null and nonempty-string value. This matches the distinct objective to append sequences while retaining element order; the remaining chosen features address choose the first non-null and nonempty-string value.

Incorrect Answers

B:

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 append sequences while retaining element order and choose the first non-null and nonempty-string value. Its main application is to test whether an expression can be evaluated without an error; the checklist instead asks for append sequences while retaining element order; and choose the first non-null and nonempty-string value. None of those distinct criteria specifically calls for this alternative.

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 append sequences while retaining element order and choose the first non-null and nonempty-string value. Its main application is to repeat provider-specific nested blocks from a collection; the checklist instead asks for append sequences while retaining element order; and choose the first non-null and nonempty-string value. None of those distinct criteria specifically calls for this alternative.

E:

File reads files present when evaluation starts; it is not a dependency-aware way to read a file that a resource will create during apply; this behavior should be assessed against the concrete need to append sequences while retaining element order and choose the first non-null and nonempty-string value. Its main application is to obtain existing UTF-8 file contents during expression evaluation; the checklist instead asks for append sequences while retaining element order; and choose the first non-null and nonempty-string value. None of those distinct criteria specifically calls for this alternative.

Question 434

During a deployment checklist, one task is to replace a resource when another managed resource or attribute changes, while another is to break mutual dependencies that prevent Terraform from ordering operations. Select the matching pair of techniques.

  1. Use replace_triggered_by for resource change coupling + Use depends_on for a hidden dependency
  2. Use explicit dependencies on module calls carefully + Use terraform_data for value-driven replacement triggers
  3. Use replace_triggered_by for resource change coupling + Avoid a circular dependency graph
  4. Use replace_triggered_by rather than depends_on for forced rebuilding + Avoid a circular dependency graph

Explanation

Correct Answer

C:

For the first criterion, the rule ties replacement to planned actions on managed resources; plain local values do not themselves have planned resource actions; this behavior should be assessed against the concrete need to replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations; this directly addresses the need to replace a resource when another managed resource or attribute changes. For the separate second criterion, 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 replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations; this fulfills the need to break mutual dependencies that prevent Terraform from ordering operations. Together they cover the independent tasks of replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to replace a resource when another managed resource or attribute changes, but its partner serves a different role: 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 replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations. That second component is designed to order operations even when no output attribute is consumed, so the still-missing criterion is to break mutual dependencies that prevent Terraform from ordering operations, while the first criterion remains replace a resource when another managed resource or attribute changes.

B:

The first measure is intended to delay all operations in a child module until required prerequisites complete: depends_on on a module applies to the module's relevant actions, not just one output; it may be broader than a targeted output reference; this behavior should be assessed against the concrete need to replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations. The second measure is intended to represent an input change through a managed resource lifecycle: A terraform_data resource can turn a changing value into a planned change that replace_triggered_by can reference; this avoids trying to reference a bare variable as a resource action; this behavior should be assessed against the concrete need to replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations. Neither is the directly designated method for the separate goals of replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations in this review.

D:

The second measure does meet the break mutual dependencies that prevent Terraform from ordering operations requirement, but the first is designed for another concern: 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 replace a resource when another managed resource or attribute changes and break mutual dependencies that prevent Terraform from ordering operations. That first component is designed to differentiate operation ordering from replacement semantics, which does not accomplish the requested task to replace a resource when another managed resource or attribute changes, even though the other measure satisfies break mutual dependencies that prevent Terraform from ordering operations.

Question 435

A reviewer has to approve a two-part design: reject malformed or disallowed input before resource creation; additionally, separate structural HCL checking from runtime assertions. Which option pairs the correct mechanisms?

  1. Use variable validation for valid network prefixes + Use error_message for actionable custom diagnostics
  2. Use alltrue over transformed entries + Distinguish terraform validate from in-configuration conditions
  3. Use a check block with assertions + Use a resource precondition
  4. Use variable validation for valid network prefixes + Distinguish terraform validate from in-configuration conditions

Explanation

Correct Answer

D:

For the first criterion, 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 malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions; this directly addresses the need to reject malformed or disallowed input before resource creation. For the separate second criterion, the CLI validation command checks configuration consistency; custom conditions examine values and guarantees at relevant evaluation phases; this behavior should be assessed against the concrete need to reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions; this fulfills the need to separate structural HCL checking from runtime assertions. Together they cover the independent tasks of reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to reject malformed or disallowed input before resource creation, but its partner serves a different role: Variable validation and lifecycle conditions support custom messages; a vague error message makes troubleshooting harder even when the Boolean test is correct; this behavior should be assessed against the concrete need to reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions. That second component is designed to tell users which contract failed and why, so the still-missing criterion is to separate structural HCL checking from runtime assertions, while the first criterion remains reject malformed or disallowed input before resource creation.

B:

The second measure does meet the separate structural HCL checking from runtime assertions requirement, but the first is designed for another concern: Combining a for expression with alltrue yields a single Boolean input contract; it is not the same as testing only the first list element; this behavior should be assessed against the concrete need to reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions. That first component is designed to validate every element of a collection against one rule, which does not accomplish the requested task to reject malformed or disallowed input before resource creation, even though the other measure satisfies separate structural HCL checking from runtime assertions.

C:

The first measure is intended to monitor an infrastructure invariant and report failed checks without blocking the whole operation: Checks are designed for nonblocking validation and can report warnings during plan/apply; critical prerequisites belong in blocking custom conditions; this behavior should be assessed against the concrete need to reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions. The second measure is intended to verify an assumption before Terraform processes the target resource operation: 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 reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions. Neither is the directly designated method for the separate goals of reject malformed or disallowed input before resource creation and separate structural HCL checking from runtime assertions in this review.

Question 436

A Terraform rollout has separate acceptance criteria: reduce risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys. Which combined approach directly satisfies the two criteria?

  1. Rotate credentials after suspected disclosure + Use short-lived cloud identities for automation
  2. Treat saved plan files as sensitive artifacts + Use Vault to centralize secret access
  3. Rotate credentials after suspected disclosure + Distinguish ephemeral from sensitive
  4. Avoid committing secret .tfvars values + Use short-lived cloud identities for automation

Explanation

Correct Answer

A:

For the first criterion, removing a line from code does not revoke already exposed tokens; credential rotation and cleanup of historical artifacts are separate security steps; this behavior should be assessed against the concrete need to reduce risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys; this directly addresses the need to reduce risk when secrets were written to state or repository history. For the separate second 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 risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys; this fulfills the need to reduce dependence on hardcoded long-lived API keys. Together they cover the independent tasks of reduce risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to avoid leaking inputs and backend information through CI downloads: 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 risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys. The second 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 reduce risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys. Neither is the directly designated method for the separate goals of reduce risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys in this review.

C:

The first measure meets the requirement to reduce risk when secrets were written to state or repository history, but its partner serves a different role: 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 risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys. That second component is designed to choose secrecy controls based on persistence as well as output redaction, so the still-missing criterion is to reduce dependence on hardcoded long-lived API keys, while the first criterion remains reduce risk when secrets were written to state or repository history.

D:

The second measure does meet the reduce dependence on hardcoded long-lived API keys requirement, but the first is designed for another concern: 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 reduce risk when secrets were written to state or repository history and reduce dependence on hardcoded long-lived API keys. That first component is designed to prevent credentials from entering source history, which does not accomplish the requested task to reduce risk when secrets were written to state or repository history, even though the other measure satisfies reduce dependence on hardcoded long-lived API keys.

Question 437

The immediate Terraform task is to read an object without asking Terraform to create or manage it. Which method handles that task most directly?

  1. Recognize terraform_data as a built-in managed resource
  2. Select resource instead of data when deletion must be managed
  3. Distinguish locals from remote resource declarations
  4. Use provider selection on both resource and data blocks
  5. Query an existing object with data
  6. Keep a data lookup separate from a same-object managed declaration

Explanation

Correct Answer

E:

Data sources ask providers to fetch properties; they do not make Terraform responsible for deleting or updating the queried object; this behavior should be assessed against the concrete need to read an object without asking Terraform to create or manage it. This directly supports the task to read an object without asking Terraform to create or manage it during a platform review.

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 read an object without asking Terraform to create or manage it. That can be useful when the aim is to store arbitrary values or trigger replacements without a third-party resource API, but it does not directly deliver the requested ability to read an object without asking Terraform to create or manage it.

B:

A data source never directs Terraform to delete the looked-up object; lifecycle ownership requires a managed declaration or an adopted resource; this behavior should be assessed against the concrete need to read an object without asking Terraform to create or manage it. The distinction matters here: using that mechanism to make intentional destruction part of Terraform's lifecycle model would still leave the objective to read an object without asking Terraform to create or manage it unmet.

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 read an object without asking Terraform to create or manage it. It may support a related workflow, but the question specifically requires the mechanism for read an object without asking Terraform to create or manage it rather than compute reusable expression results without creating an API object.

D:

Provider aliases control where the relevant API call is sent; a data source without an explicit alias may query the default context even when a nearby resource uses an alternate one; this behavior should be assessed against the concrete need to read an object without asking Terraform to create or manage it. The stated requirement is to read an object without asking Terraform to create or manage it, not to direct API operations and lookups to the intended account or region; this alternative addresses a different control or phase.

F:

A data source can read attributes but does not change who owns the underlying object; managing and reading one object need careful dependency design to avoid deferred or inconsistent reads; this behavior should be assessed against the concrete need to read an object without asking Terraform to create or manage it. The distinction matters here: using that mechanism to avoid mistaking two views of one API object for independent resources would still leave the objective to read an object without asking Terraform to create or manage it unmet.

Question 438

In a planned migration, the requested result is to read a module input variable inside that module. What should the engineer select?

  1. Use direct attribute references to create implicit dependencies
  2. Use data.type.name.attribute
  3. Use var.region
  4. Use local.prefix

Explanation

Correct Answer

C:

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. This directly supports the task to read a module input variable inside that module during a deployment checklist.

Incorrect Answers

A:

A resource that consumes another's attribute implicitly depends on it; explicit depends_on is unnecessary when the reference already captures the ordering need; this behavior should be assessed against the concrete need to read a module input variable inside that module. The stated requirement is to read a module input variable inside that module, not to let Terraform infer safe operation order through data flow; this alternative addresses a different control or phase.

B:

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 read a module input variable inside that module. That can be useful when the aim is to retrieve an attribute of a declared data source, but it does not directly deliver the requested ability to read a module input variable inside that module.

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 read a module input variable inside that module. It may support a related workflow, but the question specifically requires the mechanism for read a module input variable inside that module rather than reference a computed local value in the same module.

Question 439

An application module needs reliable input and output contracts. The team must both load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file. Which paired choice implements those distinct goals?

  1. Pass values through -var-file=custom.tfvars + Use TF_VAR_name environment variables
  2. Mark an input variable ephemeral = true + Mark a variable sensitive = true
  3. Use a child-module output as module.app.endpoint + Use TF_VAR_name environment variables
  4. Pass values through -var-file=custom.tfvars + Define output for a root result

Explanation

Correct Answer

A:

For the first criterion, 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 load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file; this directly addresses the need to load named environment inputs that are not automatically discovered. For the separate second criterion, terraform reads variables with the TF_VAR_ prefix, subject to other higher-precedence input sources; environment variables can still leak in logs or process environments; this behavior should be assessed against the concrete need to load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file; this fulfills the need to provide a root input value without writing it in a tfvars file. Together they cover the independent tasks of load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to prevent a temporary secret from being persisted to state and plan files: 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 load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file. The second measure is intended to suppress ordinary disclosure of a secret in Terraform output: 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 load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file. Neither is the directly designated method for the separate goals of load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file in this review.

C:

The second measure does meet the provide a root input value without writing it in a tfvars file 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 load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file. That first component is designed to transfer computed values from a child module to its caller, which does not accomplish the requested task to load named environment inputs that are not automatically discovered, even though the other measure satisfies provide a root input value without writing it in a tfvars file.

D:

The first measure meets the requirement to load named environment inputs that are not automatically discovered, but its partner serves a different role: Outputs provide a documented interface for command output and automation; they can be inspected with terraform output when recorded in state; this behavior should be assessed against the concrete need to load named environment inputs that are not automatically discovered and provide a root input value without writing it in a tfvars file. That second component is designed to expose a selected computed value after provisioning, so the still-missing criterion is to provide a root input value without writing it in a tfvars file, while the first criterion remains load named environment inputs that are not automatically discovered.

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.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests