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

Question 640

During an infrastructure design review about how to call a child module from an explicit filesystem path, a maintainer asks what “An absolute local module source” does. Which description is accurate?

  1. Terraform can load a module from a local filesystem path, though absolute paths make configurations less portable.
  2. Published module documentation and metadata describe the module interface and help consumers understand required arguments.
  3. Initialization retrieves module sources and populates .terraform/modules while preparing other required dependencies.
  4. A source address ending in ?ref=... selects a Git revision; it does not use the registry-specific module version argument.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to call a child module from an explicit filesystem path, so it produces the behavior described. In contrast, a Git ref query parameter serves a different goal: pin a VCS module to a specific Git branch, tag or commit, not call a child module from an explicit filesystem path.

Incorrect Answers

B:

The description applies to registry module documentation when an engineer needs to determine a module's declared inputs, outputs, providers and usage examples; the named an absolute local module source instead handles the requirement to call a child module from an explicit filesystem path, so this behavior does not describe An absolute local module source in the situation named.

C:

The description applies to terraform init for modules when an engineer needs to install all referenced remote child modules before planning; the named an absolute local module source instead handles the requirement to call a child module from an explicit filesystem path, so this behavior does not describe An absolute local module source in the situation named.

D:

The description applies to a Git ref query parameter when an engineer needs to pin a VCS module to a specific Git branch, tag or commit; the named an absolute local module source instead handles the requirement to call a child module from an explicit filesystem path, so this behavior does not describe An absolute local module source in the situation named.

Question 641

A pipeline responsible for the Terraform workflow requires a way to retrieve computed identifiers that can be used by deployment automation. Which Terraform approach most directly fulfills that request?

  1. Apply failure recovery
  2. Post-apply outputs
  3. Apply a saved plan
  4. Refresh during apply planning

Explanation

Correct Answer

B:

Root output blocks expose values Terraform calculates from the applied resource graph; output display is not an access-control boundary; this directly meets the requirement to retrieve computed identifiers that can be used by deployment automation. By comparison, apply a saved plan is intended to execute exactly the plan artifact that was reviewed, which is a different task from retrieve computed identifiers that can be used by deployment automation.

Incorrect Answers

A:

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 retrieve computed identifiers that can be used by deployment automation. These operations have different effects in the stated Terraform workflow.

C:

Passing the saved plan file to terraform apply uses its recorded choices; applying a plan file does not start a new interactive replanning step; this mechanism is useful when the job is to execute exactly the plan artifact that was reviewed, whereas the current scenario requires the engineer to retrieve computed identifiers that can be used by deployment automation. These operations have different effects in the stated Terraform workflow.

D:

For a normal fresh apply, Terraform plans with current provider observations unless refresh is explicitly disabled; saved plan behavior differs; this mechanism is useful when the job is to avoid applying from stale remembered attributes after remote drift, whereas the current scenario requires the engineer to retrieve computed identifiers that can be used by deployment automation. These operations have different effects in the stated Terraform workflow.

Question 642

An operations team replacing ad-hoc scripts has a concrete implementation goal: allow authorized operators to use one shared source of Terraform state. What is the most appropriate Terraform mechanism?

  1. Drift detection during planning
  2. Reusable execution records
  3. Environment parametrization
  4. Collaboration through remote state

Explanation

Correct Answer

D:

A backend supporting remote storage and locking can centralize state and prevent conflicting concurrent changes; this directly meets the requirement to allow authorized operators to use one shared source of Terraform state. By comparison, reusable execution records is intended to audit the results of infrastructure changes across a team, which is a different task from allow authorized operators to use one shared source of Terraform state.

Incorrect Answers

A:

Terraform can refresh managed objects during planning and flag differences between the observed infrastructure and configuration; this mechanism is useful when the job is to notice remote infrastructure changes made outside Terraform, whereas the current scenario requires the engineer to allow authorized operators to use one shared source of Terraform state. These operations have different effects in the stated Terraform workflow.

B:

Version control and run history provide traceable context for what configuration changed and what Terraform planned or applied; this mechanism is useful when the job is to audit the results of infrastructure changes across a team, whereas the current scenario requires the engineer to allow authorized operators to use one shared source of Terraform state. These operations have different effects in the stated Terraform workflow.

C:

Terraform input variables permit different values for capacity, names and endpoints without copying the entire resource definition; this mechanism is useful when the job is to deploy similarly structured stacks with environment-specific settings, whereas the current scenario requires the engineer to allow authorized operators to use one shared source of Terraform state. These operations have different effects in the stated Terraform workflow.

Question 643

A reusable infrastructure definition requires a way to avoid putting provider access tokens directly in configuration source. Which Terraform approach most directly fulfills that request?

  1. No secrets in version control
  2. Environment-based provider credentials
  3. Vault-backed secret retrieval
  4. Remote state access controls

Explanation

Correct Answer

B:

Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL; this directly meets the requirement to avoid putting provider access tokens directly in configuration source. By comparison, vault-backed secret retrieval is intended to retrieve an operational credential from a dedicated secret manager rather than committing it, which is a different task from avoid putting provider access tokens directly in configuration source.

Incorrect Answers

A:

Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; this mechanism is useful when the job is to keep API keys out of committed terraform.tfvars and .tf files, whereas the current scenario requires the engineer to avoid putting provider access tokens directly in configuration source. These operations have different effects in the stated Terraform workflow.

C:

Vault can centralize secret lifecycle, policies and auditability, but provider and state-handling choices still determine whether a retrieved value is persisted; this mechanism is useful when the job is to retrieve an operational credential from a dedicated secret manager rather than committing it, whereas the current scenario requires the engineer to avoid putting provider access tokens directly in configuration source. These operations have different effects in the stated Terraform workflow.

D:

Protecting state requires backend encryption, identity-based authorization and controlled access because state can store raw secret values; this mechanism is useful when the job is to prevent unauthorized operators from reading sensitive resource attributes, whereas the current scenario requires the engineer to avoid putting provider access tokens directly in configuration source. These operations have different effects in the stated Terraform workflow.

Question 644

A module author evaluates the expression keys({z=1, a=2}) with the literal inputs shown. What is the resulting Terraform value?

  1. ["a", "z", "1"]
  2. [1, 2]
  3. ["a", "z"]
  4. ["z", "a"]

Explanation

Correct Answer

C:

The expression keys({z=1, a=2}) evaluates to ["a", "z"] because keys returns map key names in lexical key order, not their numeric values. This is Terraform's direct evaluation of the supplied literal arguments in keys({z=1, a=2}), not an external provider lookup.

Incorrect Answers

A:

Numbers used as values do not create additional keys. HCL evaluates keys({z=1, a=2}) using the supplied arguments: keys returns map key names in lexical key order, not their numeric values; the listed result is therefore incorrect.

B:

The function returns names of attributes, not associated values. In this specific evaluation, keys returns map key names in lexical key order, not their numeric values, which rules out the proposed alternative.

D:

Terraform returns keys sorted, regardless of textual entry order. For keys({z=1, a=2}), keys returns map key names in lexical key order, not their numeric values; consequently this candidate is not the value Terraform computes.

Question 645

A change request asks an engineer to resolve missing provider schemas before checking configuration. Which choice best implements the requested behavior?

  1. terraform fmt -check
  2. Validate without live deployment
  3. Validate after init
  4. A type mismatch diagnosis

Explanation

Correct Answer

C:

Because validate consults provider and module definitions, run init first to install referenced dependencies; this directly meets the requirement to resolve missing provider schemas before checking configuration. By comparison, terraform fmt -check is intended to verify formatting without rewriting the files in a CI job, which is a different task from resolve missing provider schemas before checking configuration.

Incorrect Answers

A:

The fmt -check option exits with a failure status when source files would need formatting changes rather than altering them; this mechanism is useful when the job is to verify formatting without rewriting the files in a CI job, whereas the current scenario requires the engineer to resolve missing provider schemas before checking configuration. These operations have different effects in the stated Terraform workflow.

B:

terraform validate runs offline-oriented configuration checks and does not deploy managed resources; this mechanism is useful when the job is to detect invalid configuration even when no cloud changes should occur, whereas the current scenario requires the engineer to resolve missing provider schemas before checking configuration. These operations have different effects in the stated Terraform workflow.

D:

Provider schemas and Terraform's type checking can make validate fail before an apply is attempted; this mechanism is useful when the job is to catch an argument whose expression does not match the provider schema, whereas the current scenario requires the engineer to resolve missing provider schemas before checking configuration. These operations have different effects in the stated Terraform workflow.

Question 646

An HCP Terraform workspace design has a concrete implementation goal: share credentials only with selected approved infrastructure scopes. What is the most appropriate Terraform mechanism?

  1. An HCP Terraform project
  2. One state per independently owned system
  3. Variable sets scoped to workspaces
  4. Workspace-specific variables

Explanation

Correct Answer

C:

A variable set may apply to selected workspaces instead of every workspace in an organization; this directly meets the requirement to share credentials only with selected approved infrastructure scopes. By comparison, workspace-specific variables is intended to override or tailor values used by one particular stack, which is a different task from share credentials only with selected approved infrastructure scopes.

Incorrect Answers

A:

Projects organize workspaces by application, team or environment, simplifying scope and access administration; this mechanism is useful when the job is to group related workspaces under one organizational and permissions boundary, whereas the current scenario requires the engineer to share credentials only with selected approved infrastructure scopes. These operations have different effects in the stated Terraform workflow.

B:

Separate workspaces allow independent state lifecycles for services that are changed and approved separately; this mechanism is useful when the job is to avoid coupling different teams' deploys into a single state and blast radius, whereas the current scenario requires the engineer to share credentials only with selected approved infrastructure scopes. These operations have different effects in the stated Terraform workflow.

D:

Workspace settings store variables for that workspace's execution; global sets should not replace environment-specific data blindly; this mechanism is useful when the job is to override or tailor values used by one particular stack, whereas the current scenario requires the engineer to share credentials only with selected approved infrastructure scopes. These operations have different effects in the stated Terraform workflow.

Question 647

A Terraform deployment has independent requirements: (1) distinguish static configuration checks from conditions requiring actual resource values; (2) build formatted text using placeholders for typed values. Which TWO mechanisms directly address these needs? Choose TWO.

  1. The dynamic block
  2. terraform validate versus runtime assertions
  3. The cidrhost function
  4. The format function
  5. Resource postcondition

Explanation

Correct Answers

B:

Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply; this meets the requirement to distinguish static configuration checks from conditions requiring actual resource values, while the other selected techniques address build formatted text using placeholders for typed values, which require their own distinct Terraform mechanisms.

D:

format interpolates arguments into a printf-style string template for predictable names or identifiers; this meets the requirement to build formatted text using placeholders for typed values, while the other selected techniques address distinguish static configuration checks from conditions requiring actual resource values, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

dynamic constructs blocks required by resource schemas; it does not create standalone Terraform resource declarations; it addresses generate repeated nested blocks from a collection, but this delivery instead requires distinguish static configuration checks from conditions requiring actual resource values and build formatted text using placeholders for typed values. The required combination involves The format function and terraform validate versus runtime assertions, not the behavior of The dynamic block.

C:

cidrhost computes a host address inside the given prefix from a numeric host index; it addresses calculate an IP address at an offset within a CIDR range, but this delivery instead requires distinguish static configuration checks from conditions requiring actual resource values and build formatted text using placeholders for typed values. The required combination involves The format function and terraform validate versus runtime assertions, not the behavior of The cidrhost function.

E:

A postcondition evaluates a condition concerning resource results and blocks downstream use when its assertion fails; it addresses verify an invariant about a resource after reading or managing it, but this delivery instead requires distinguish static configuration checks from conditions requiring actual resource values and build formatted text using placeholders for typed values. The required combination involves The format function and terraform validate versus runtime assertions, not the behavior of Resource postcondition.

Question 648

A Terraform reviewer encounters “State snapshots” while assessing how to preserve Terraform's knowledge of managed infrastructure between CLI runs. Which statement correctly describes its actual behavior?

  1. The state snapshot records managed instance data and metadata needed to plan future actions.
  2. State may contain secret values even when CLI output is redacted, so storage encryption and access controls matter.
  3. State can retain dependency information needed to correctly destroy objects no longer declared in configuration.
  4. Distinct backends, workspaces or root configurations can isolate state, but the configuration must target the intended instance set.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to preserve Terraform's knowledge of managed infrastructure between CLI runs, so it produces the behavior described. In contrast, state-backed dependency links serves a different goal: maintain dependencies for resources that have been removed from configuration, not preserve Terraform's knowledge of managed infrastructure between CLI runs.

Incorrect Answers

B:

The description applies to state access protection when an engineer needs to treat a Terraform state file as potentially sensitive data; the named state snapshots instead handles the requirement to preserve Terraform's knowledge of managed infrastructure between CLI runs, so this behavior does not describe State snapshots in the situation named.

C:

The description applies to state-backed dependency links when an engineer needs to maintain dependencies for resources that have been removed from configuration; the named state snapshots instead handles the requirement to preserve Terraform's knowledge of managed infrastructure between CLI runs, so this behavior does not describe State snapshots in the situation named.

D:

The description applies to separate state per environment when an engineer needs to prevent staging changes from unintentionally sharing the production state mapping; the named state snapshots instead handles the requirement to preserve Terraform's knowledge of managed infrastructure between CLI runs, so this behavior does not describe State snapshots in the situation named.

Question 649

An engineer proposes “The local backend's lack of team collaboration features” to recover from a state change without relying solely on an unversioned primary file. Which outcome does the proposed technique actually provide?

  1. Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state.
  2. Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination.
  3. Local files do not provide an organization-wide shared state or distributed locking comparable to an appropriately configured remote backend.
  4. Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter.

Explanation

Correct Answer

C:

The local backend's lack of team collaboration features is used when an operator needs to avoid concurrent writes from multiple operators on different machines. Consequently, this choice cannot meet the separate requirement to recover from a state change without relying solely on an unversioned primary file. The intended action would instead require A local state backup file.

Incorrect Answers

A:

That outcome belongs to A local state backup file, the mechanism that can recover from a state change without relying solely on an unversioned primary file. The question concerns the engineer’s actual proposal, The local backend's lack of team collaboration features; it is directed at avoid concurrent writes from multiple operators on different machines, not that result.

B:

This behavior belongs to State migration from local storage, which helps engineers move an established project to remote state without abandoning resource identity rather than satisfying the separate requirement to recover from a state change without relying solely on an unversioned primary file. The attempted technique was The local backend's lack of team collaboration features; it would instead be used to avoid concurrent writes from multiple operators on different machines, not to produce the effect associated with State migration from local storage.

D:

This behavior belongs to State file confidentiality, which helps engineers protect a workstation's local state file even when output values are hidden rather than satisfying the separate requirement to recover from a state change without relying solely on an unversioned primary file. The attempted technique was The local backend's lack of team collaboration features; it would instead be used to avoid concurrent writes from multiple operators on different machines, not to produce the effect associated with State file confidentiality.

Question 650

A release pipeline preparing provider access has a concrete implementation goal: declare which alternate provider configurations a child module is allowed to receive. What is the most appropriate Terraform mechanism?

  1. An aliased provider instance
  2. Separate required provider names
  3. configuration_aliases in required_providers
  4. Provider-local name mapping

Explanation

Correct Answer

C:

A child module's required_providers entry uses configuration_aliases to advertise provider aliases referenced inside the module; this directly meets the requirement to declare which alternate provider configurations a child module is allowed to receive. By comparison, a resource's provider meta-argument is intended to route a particular managed object to the named alternate provider configuration, which is a different task from declare which alternate provider configurations a child module is allowed to receive.

Incorrect Answers

A:

Declare an aliased provider configuration and assign provider = provider_name.alias on resources that need the alternate region; this mechanism is useful when the job is to create resources in a second region using the same provider type, whereas the current scenario requires the engineer to declare which alternate provider configurations a child module is allowed to receive. These operations have different effects in the stated Terraform workflow.

B:

List both plugins under required_providers and configure each service's provider independently as needed; this concerns the task to use two unrelated service APIs in one root configuration, not the current need to declare which alternate provider configurations a child module is allowed to receive. A configuration_aliases in required_providers approach is appropriate here; the substituted Separate required provider names option does not supply the specified Terraform capability.

D:

The required_providers entry maps the chosen local name to a specific fully qualified provider source address; this mechanism is useful when the job is to reuse a provider whose source address differs from its short local identifier, whereas the current scenario requires the engineer to declare which alternate provider configurations a child module is allowed to receive. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests