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

Question 800

An infrastructure architecture discussion has a concrete implementation goal: deploy similarly structured stacks with environment-specific settings. What is the most appropriate Terraform mechanism?

  1. Collaboration through remote state
  2. Plan-before-apply reviews
  3. Idempotent convergence
  4. Environment parametrization

Explanation

Correct Answer

D:

Terraform input variables permit different values for capacity, names and endpoints without copying the entire resource definition; this directly meets the requirement to deploy similarly structured stacks with environment-specific settings. By comparison, idempotent convergence is intended to run unchanged configuration repeatedly without inventing new infrastructure updates, which is a different task from deploy similarly structured stacks with environment-specific settings.

Incorrect Answers

A:

A backend supporting remote storage and locking can centralize state and prevent conflicting concurrent changes; this mechanism is useful when the job is to allow authorized operators to use one shared source of Terraform state, whereas the current scenario requires the engineer to deploy similarly structured stacks with environment-specific settings. These operations have different effects in the stated Terraform workflow.

B:

A Terraform plan is a reviewable proposed set of actions; execution occurs only when an apply runs against the chosen plan; this mechanism is useful when the job is to see intended infrastructure changes without immediately creating them, whereas the current scenario requires the engineer to deploy similarly structured stacks with environment-specific settings. These operations have different effects in the stated Terraform workflow.

C:

With no configuration or remote drift requiring action, a new plan normally proposes no infrastructure changes; this mechanism is useful when the job is to run unchanged configuration repeatedly without inventing new infrastructure updates, whereas the current scenario requires the engineer to deploy similarly structured stacks with environment-specific settings. These operations have different effects in the stated Terraform workflow.

Question 801

A Terraform module author needs to sort a list of strings lexicographically. Which feature or operation is the most direct match?

  1. The base64encode function
  2. The sort function
  3. The dynamic block
  4. The ternary conditional operator

Explanation

Correct Answer

B:

sort returns an ordered list of string elements according to lexical comparison rather than original insertion order; this directly meets the requirement to sort a list of strings lexicographically. By comparison, the dynamic block is intended to generate repeated nested blocks from a collection, which is a different task from sort a list of strings lexicographically.

Incorrect Answers

A:

base64encode applies a reversible encoding and should not be mistaken for encryption of secrets; this mechanism is useful when the job is to turn ordinary string content into Base64 text, whereas the current scenario requires the engineer to sort a list of strings lexicographically. These operations have different effects in the stated Terraform workflow.

C:

dynamic constructs blocks required by resource schemas; it does not create standalone Terraform resource declarations; this mechanism is useful when the job is to generate repeated nested blocks from a collection, whereas the current scenario requires the engineer to sort a list of strings lexicographically. These operations have different effects in the stated Terraform workflow.

D:

The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks; this mechanism is useful when the job is to set a resource argument according to a boolean expression, whereas the current scenario requires the engineer to sort a list of strings lexicographically. These operations have different effects in the stated Terraform workflow.

Question 802

During one infrastructure delivery, the team must satisfy all of the following: (1) read a field from a configured data source in another expression; (2) use a short-lived runtime secret without saving its value in plan or state; (3) fail a plan or apply when a prerequisite property is unacceptable. Select THREE appropriate Terraform approaches. Choose THREE.

  1. No secrets in version control
  2. A data attribute reference
  3. Resource precondition
  4. Input validation versus check blocks
  5. A for_each instance address
  6. ephemeral = true on a variable

Explanation

Correct Answers

B:

The syntax data.TYPE.NAME.ATTRIBUTE accesses attributes returned by an existing-object query; this meets the requirement to read a field from a configured data source in another expression, while the other selected techniques address use a short-lived runtime secret without saving its value in plan or state and fail a plan or apply when a prerequisite property is unacceptable, which require their own distinct Terraform mechanisms.

C:

A precondition inside lifecycle requires a true predicate before Terraform can continue the relevant resource operation; this meets the requirement to fail a plan or apply when a prerequisite property is unacceptable, while the other selected techniques address read a field from a configured data source in another expression and use a short-lived runtime secret without saving its value in plan or state, which require their own distinct Terraform mechanisms.

F:

Terraform 1.10+ ephemeral variables can flow only into allowed ephemeral contexts and are omitted from persisted artifacts; this meets the requirement to use a short-lived runtime secret without saving its value in plan or state, while the other selected techniques address read a field from a configured data source in another expression and fail a plan or apply when a prerequisite property is unacceptable, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; it addresses keep API keys out of committed terraform.tfvars and .tf files, but this delivery instead requires read a field from a configured data source in another expression and use a short-lived runtime secret without saving its value in plan or state and fail a plan or apply when a prerequisite property is unacceptable. The required combination involves A data attribute reference and Resource precondition and ephemeral = true on a variable, not the behavior of No secrets in version control.

D:

Variable validation rejects unacceptable values, whereas failed check assertions are intended for diagnostic warnings; it addresses choose a blocking input constraint rather than a monitoring-style assertion, but this delivery instead requires read a field from a configured data source in another expression and use a short-lived runtime secret without saving its value in plan or state and fail a plan or apply when a prerequisite property is unacceptable. The required combination involves A data attribute reference and Resource precondition and ephemeral = true on a variable, not the behavior of Input validation versus check blocks.

E:

Instances made from a map or string set have addresses such as aws_instance.web["blue"], rather than an integer count index; it addresses identify a single managed object selected by a string key, but this delivery instead requires read a field from a configured data source in another expression and use a short-lived runtime secret without saving its value in plan or state and fail a plan or apply when a prerequisite property is unacceptable. The required combination involves A data attribute reference and Resource precondition and ephemeral = true on a variable, not the behavior of A for_each instance address.

Question 803

An engineer proposes “Avoiding hard-coded child credentials” to use a network module's subnet IDs inside an application module call. Which outcome does the proposed technique actually provide?

  1. Reusable modules normally declare provider requirements while callers supply provider configurations and credentials.
  2. Parent configurations can pass one child module's outputs into another child's inputs to compose larger infrastructure systems.
  3. All Terraform configuration files in a module directory are combined as one module; filenames do not define separate execution units.
  4. Module outputs provide explicit integration points between modules without relying on child resource addresses.

Explanation

Correct Answer

A:

Avoiding hard-coded child credentials is used when an operator needs to keep authentication and deployment-specific region choices outside a reusable child module. Consequently, this choice cannot meet the separate requirement to use a network module's subnet IDs inside an application module call. The intended action would instead require A module output reference.

Incorrect Answers

B:

This behavior belongs to Module composition, which helps engineers combine small modules into a root configuration without producing one giant module rather than satisfying the separate requirement to use a network module's subnet IDs inside an application module call. The attempted technique was Avoiding hard-coded child credentials; it would instead be used to keep authentication and deployment-specific region choices outside a reusable child module, not to produce the effect associated with Module composition.

C:

This behavior belongs to A module root directory, which helps engineers understand which source files Terraform loads as one module rather than satisfying the separate requirement to use a network module's subnet IDs inside an application module call. The attempted technique was Avoiding hard-coded child credentials; it would instead be used to keep authentication and deployment-specific region choices outside a reusable child module, not to produce the effect associated with A module root directory.

D:

That outcome belongs to A module output reference, the mechanism that can use a network module's subnet IDs inside an application module call. The question concerns the engineer’s actual proposal, Avoiding hard-coded child credentials; it is directed at keep authentication and deployment-specific region choices outside a reusable child module, not that result.

Question 804

During a design review, the requirement is to run Terraform in automation where prompting is not acceptable. Which option should the engineer select?

  1. Post-apply outputs
  2. Apply using current credentials
  3. Apply failure recovery
  4. Parallel graph execution
  5. Noninteractive apply settings

Explanation

Correct Answer

E:

The -input=false option prevents prompts for missing input, requiring all necessary values and approvals to be handled by automation; this directly meets the requirement to run Terraform in automation where prompting is not acceptable. By comparison, apply using current credentials is intended to determine which identity actually performs infrastructure changes, which is a different task from run Terraform in automation where prompting is not acceptable.

Incorrect Answers

A:

Root output blocks expose values Terraform calculates from the applied resource graph; output display is not an access-control boundary; this mechanism is useful when the job is to retrieve computed identifiers that can be used by deployment automation, whereas the current scenario requires the engineer to run Terraform in automation where prompting is not acceptable. These operations have different effects in the stated Terraform workflow.

B:

Provider API operations use the provider's configured credentials or supported ambient authentication, not the login name in a commit; this mechanism is useful when the job is to determine which identity actually performs infrastructure changes, whereas the current scenario requires the engineer to run Terraform in automation where prompting is not acceptable. These operations have different effects in the stated Terraform workflow.

C:

A partial apply may have changed some resources, so Terraform should refresh and build a new plan rather than blindly assuming a full rollback; this mechanism is useful when the job is to inspect state and re-plan when a provider operation fails partway through, whereas the current scenario requires the engineer to run Terraform in automation where prompting is not acceptable. These operations have different effects in the stated Terraform workflow.

D:

Terraform executes actions in graph order and can operate on independent nodes in parallel subject to provider and CLI limits; this mechanism is useful when the job is to allow independent resources to be applied concurrently, whereas the current scenario requires the engineer to run Terraform in automation where prompting is not acceptable. These operations have different effects in the stated Terraform workflow.

Question 805

A build job for a Terraform configuration requires a way to distinguish style-only issues from Terraform type and schema errors. Which Terraform approach most directly fulfills that request?

  1. terraform fmt -check
  2. terraform fmt -recursive
  3. Formatting versus validation
  4. Canonical HCL alignment

Explanation

Correct Answer

C:

terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; this directly meets the requirement to distinguish style-only issues from Terraform type and schema errors. By comparison, terraform fmt -check is intended to make a CI formatting gate detect source files that need formatting, which is a different task from distinguish style-only issues from Terraform type and schema errors.

Incorrect Answers

A:

Check mode verifies formatting and returns a failure when changes would be required instead of writing edited files; this mechanism is useful when the job is to make a CI formatting gate detect source files that need formatting, whereas the current scenario requires the engineer to distinguish style-only issues from Terraform type and schema errors. These operations have different effects in the stated Terraform workflow.

B:

The recursive switch extends formatting into subdirectories rather than limiting the operation to the current directory; this mechanism is useful when the job is to format Terraform files in nested directories under a module tree, whereas the current scenario requires the engineer to distinguish style-only issues from Terraform type and schema errors. These operations have different effects in the stated Terraform workflow.

D:

The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls; this mechanism is useful when the job is to keep spacing and indentation consistent between developers, whereas the current scenario requires the engineer to distinguish style-only issues from Terraform type and schema errors. These operations have different effects in the stated Terraform workflow.

Question 806

A Terraform change proposal names “terraform plan -refresh=false” to skip routine state refresh for a constrained preview. Which outcome can reviewers attribute to that particular mechanism?

  1. In human-readable plan diffs, ~ indicates that Terraform proposes updating existing resource attributes.
  2. Disabling refresh reduces remote reads but can hide drift and produce an inaccurate plan based on stale observations.
  3. Plans show replacement when the provider cannot update a changed property in place; create-before-destroy can change the replacement order.
  4. In human-readable plans, - denotes a planned destruction of a managed resource.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to skip routine state refresh for a constrained preview, so it produces the behavior described. In contrast, a resource action marked tilde serves a different goal: identify an in-place change rather than object recreation, not skip routine state refresh for a constrained preview.

Incorrect Answers

A:

The description applies to a resource action marked tilde when an engineer needs to identify an in-place change rather than object recreation; the named terraform plan -refresh=false instead handles the requirement to skip routine state refresh for a constrained preview, so this behavior does not describe terraform plan -refresh=false in the situation named.

C:

The description applies to a replacement action in the plan when an engineer needs to recognize a destroy-and-create operation for an immutable argument; the named terraform plan -refresh=false instead handles the requirement to skip routine state refresh for a constrained preview, so this behavior does not describe terraform plan -refresh=false in the situation named.

D:

The description applies to a resource action marked minus when an engineer needs to interpret a plan showing a resource that Terraform will destroy; the named terraform plan -refresh=false instead handles the requirement to skip routine state refresh for a constrained preview, so this behavior does not describe terraform plan -refresh=false in the situation named.

Question 807

A reusable infrastructure definition requires a way to build formatted text using placeholders for typed values. Which Terraform approach most directly fulfills that request?

  1. The cidrsubnet function
  2. The cidrhost function
  3. The ternary conditional operator
  4. The format function

Explanation

Correct Answer

D:

format interpolates arguments into a printf-style string template for predictable names or identifiers; this directly meets the requirement to build formatted text using placeholders for typed values. By comparison, the ternary conditional operator is intended to set a resource argument according to a boolean expression, which is a different task from build formatted text using placeholders for typed values.

Incorrect Answers

A:

cidrsubnet derives a subnet CIDR using additional prefix bits and a network number, without provisioning a network resource; this mechanism is useful when the job is to calculate a nested network prefix from a parent CIDR range, whereas the current scenario requires the engineer to build formatted text using placeholders for typed values. These operations have different effects in the stated Terraform workflow.

B:

cidrhost computes a host address inside the given prefix from a numeric host index; this mechanism is useful when the job is to calculate an IP address at an offset within a CIDR range, whereas the current scenario requires the engineer to build formatted text using placeholders for typed values. These operations have different effects in the stated Terraform workflow.

C:

The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks; this mechanism is useful when the job is to set a resource argument according to a boolean expression, whereas the current scenario requires the engineer to build formatted text using placeholders for typed values. These operations have different effects in the stated Terraform workflow.

Question 808

A team consuming shared Terraform modules needs to make a setting available inside a called module without creating a global variable. Which feature or operation is the most direct match?

  1. A child module output
  2. A local value confined to its module
  3. Child input variable scope
  4. Provider configuration inheritance

Explanation

Correct Answer

C:

Variables declared by a child module belong to that module and receive values via the caller's module block; this directly meets the requirement to make a setting available inside a called module without creating a global variable. By comparison, a local value confined to its module is intended to avoid assuming a local calculation is automatically visible in a parent module, which is a different task from make a setting available inside a called module without creating a global variable.

Incorrect Answers

A:

The output block defines a published module interface; the parent reads the value as module.NAME.OUTPUT; this mechanism is useful when the job is to expose a chosen internal attribute to the calling parent module, whereas the current scenario requires the engineer to make a setting available inside a called module without creating a global variable. These operations have different effects in the stated Terraform workflow.

B:

Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value; this mechanism is useful when the job is to avoid assuming a local calculation is automatically visible in a parent module, whereas the current scenario requires the engineer to make a setting available inside a called module without creating a global variable. These operations have different effects in the stated Terraform workflow.

D:

Default provider configurations can be inherited, while alternate aliases need explicit mapping and declared configuration aliases; this mechanism is useful when the job is to understand which provider settings a child module can use from its parent, whereas the current scenario requires the engineer to make a setting available inside a called module without creating a global variable. These operations have different effects in the stated Terraform workflow.

Question 809

During one infrastructure delivery, the team must satisfy all of the following: (1) target a particular HCP Terraform workspace from a root configuration; (2) supply a configuration input or environment value for HCP Terraform runs. Select TWO appropriate Terraform approaches. Choose TWO.

  1. A cloud workspaces name setting
  2. A run apply phase
  3. A workspace variable
  4. HCP Terraform VCS integration
  5. HCP Terraform execution agents
  6. terraform login

Explanation

Correct Answers

A:

The cloud block's workspaces name attribute identifies one workspace, rather than selecting an arbitrary state path; this meets the requirement to target a particular HCP Terraform workspace from a root configuration, while the other selected techniques address supply a configuration input or environment value for HCP Terraform runs, which require their own distinct Terraform mechanisms.

C:

HCP Terraform workspaces can hold Terraform input variables and environment variables for run-time use; this meets the requirement to supply a configuration input or environment value for HCP Terraform runs, while the other selected techniques address target a particular HCP Terraform workspace from a root configuration, which require their own distinct Terraform mechanisms.

Incorrect Answers

B:

HCP Terraform can run the apply stage after its configured approval, policy and workflow requirements are satisfied; it addresses execute approved resource changes within an HCP Terraform workspace, but this delivery instead requires target a particular HCP Terraform workspace from a root configuration and supply a configuration input or environment value for HCP Terraform runs. The required combination involves A workspace variable and A cloud workspaces name setting, not the behavior of A run apply phase.

D:

A VCS-connected workspace coordinates code changes, speculative plans and controlled applies through supported repository integration; it addresses connect reviewed repository commits to automated infrastructure plans, but this delivery instead requires target a particular HCP Terraform workspace from a root configuration and supply a configuration input or environment value for HCP Terraform runs. The required combination involves A workspace variable and A cloud workspaces name setting, not the behavior of HCP Terraform VCS integration.

E:

HCP Terraform agents can execute runs in customer-controlled networking while integrating with service orchestration; it addresses run Terraform in a private network where hosted workers cannot reach internal endpoints, but this delivery instead requires target a particular HCP Terraform workspace from a root configuration and supply a configuration input or environment value for HCP Terraform runs. The required combination involves A workspace variable and A cloud workspaces name setting, not the behavior of HCP Terraform execution agents.

F:

The login command stores a CLI API token for the selected service host so CLI-driven workflows can authenticate; it addresses authenticate the local Terraform CLI to an HCP Terraform or Terraform Enterprise hostname, but this delivery instead requires target a particular HCP Terraform workspace from a root configuration and supply a configuration input or environment value for HCP Terraform runs. The required combination involves A workspace variable and A cloud workspaces name setting, not the behavior of terraform login.

Question 810

During one infrastructure delivery, the team must satisfy all of the following: (1) wait for prerequisite objects before considering resources in another module; (2) coerce a suitable collection into a list for ordered operations. Select TWO appropriate Terraform approaches. Choose TWO.

  1. An object type
  2. ignore_changes on a tag
  3. tolist conversion
  4. depends_on for module calls
  5. Lifecycle ordering versus API support
  6. Dependency cycle resolution

Explanation

Correct Answers

C:

tolist converts compatible values to a list, but a source set's original order is not inherently meaningful; this meets the requirement to coerce a suitable collection into a list for ordered operations, while the other selected techniques address wait for prerequisite objects before considering resources in another module, which require their own distinct Terraform mechanisms.

D:

A module block can declare depends_on so all managed objects inside it observe the specified dependency relationship; this meets the requirement to wait for prerequisite objects before considering resources in another module, while the other selected techniques address coerce a suitable collection into a list for ordered operations, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

object({ name = string, size = number }) specifies per-attribute types for a structured input; it addresses require a named structure with typed attributes, but this delivery instead requires wait for prerequisite objects before considering resources in another module and coerce a suitable collection into a list for ordered operations. The required combination involves tolist conversion and depends_on for module calls, not the behavior of An object type.

B:

The lifecycle ignore_changes list excludes chosen attributes from later update comparisons while creation still considers configured values; it addresses allow another system to update selected attributes without Terraform reverting them, but this delivery instead requires wait for prerequisite objects before considering resources in another module and coerce a suitable collection into a list for ordered operations. The required combination involves tolist conversion and depends_on for module calls, not the behavior of ignore_changes on a tag.

E:

Terraform can request early replacement creation, but remote API constraints may disallow two objects with the same globally unique name; it addresses understand why create_before_destroy can still fail on a uniquely named object, but this delivery instead requires wait for prerequisite objects before considering resources in another module and coerce a suitable collection into a list for ordered operations. The required combination involves tolist conversion and depends_on for module calls, not the behavior of Lifecycle ordering versus API support.

F:

Dependency cycles cannot be topologically ordered and require restructuring the relationships or splitting responsibilities; it addresses correct a pair of modules that each require the other's output to initialize, but this delivery instead requires wait for prerequisite objects before considering resources in another module and coerce a suitable collection into a list for ordered operations. The required combination involves tolist conversion and depends_on for module calls, not the behavior of Dependency cycle resolution.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests