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

Question 40

A Terraform reviewer encounters “Version-controlled infrastructure definition” while assessing how to review a proposed infrastructure change before team members deploy it. Which statement correctly describes its actual behavior?

  1. Infrastructure configuration can be committed and reviewed in version control so the intended change is traceable before a Terraform run.
  2. Terraform Core evaluates configuration while provider plugins implement the provider-specific API operations.
  3. Terraform state records mappings and attributes needed to compare future plans without rediscovering every object's identity from scratch.
  4. Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations.
  5. IaC configuration provides repeatable definitions; variables and isolated state allow environments to differ without independently hand-building each object.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to review a proposed infrastructure change before team members deploy it, so it produces the behavior described. In contrast, a resource graph serves a different goal: determine a safe sequence for creating objects with references between them, not review a proposed infrastructure change before team members deploy it.

Incorrect Answers

B:

The description applies to provider-mediated API operations when an engineer needs to manage infrastructure services through a shared declarative workflow; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

C:

The description applies to state-backed object tracking when an engineer needs to retain the association between a configuration address and its actual managed object; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

D:

The description applies to a resource graph when an engineer needs to determine a safe sequence for creating objects with references between them; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

E:

The description applies to repeatable environment definition when an engineer needs to recreate the same logical infrastructure design across test and production; the named version-controlled infrastructure definition instead handles the requirement to review a proposed infrastructure change before team members deploy it, so this behavior does not describe Version-controlled infrastructure definition in the situation named.

Question 41

A team compares Terraform mechanisms for the goal to record higher-level operational messages during troubleshooting. Which stated consequence belongs specifically to “TF_LOG=INFO”?

  1. INFO logging provides operational context with less detail than DEBUG and TRACE.
  2. High verbosity creates large logs and greater secret-exposure risk; enable it for a specific incident and disable it afterward.
  3. Terraform logging set to TRACE emits highly verbose diagnostic detail and may contain sensitive information.
  4. The TF_LOG_PROVIDER setting controls provider log verbosity and can help locate failures involving provider communication.
  5. TF_LOG_PATH directs log output to a file and should be combined with an enabled TF_LOG level.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to record higher-level operational messages during troubleshooting, so it produces the behavior described. In contrast, TF_LOG=TRACE serves a different goal: obtain detailed Terraform core and provider diagnostic output while troubleshooting, not record higher-level operational messages during troubleshooting.

Incorrect Answers

B:

The description applies to verbose logging only during diagnosis when an engineer needs to avoid permanent trace logs in normal automated runs; the named TF_LOG=INFO instead handles the requirement to record higher-level operational messages during troubleshooting, so this behavior does not describe TF_LOG=INFO in the situation named.

C:

The description applies to TF_LOG=TRACE when an engineer needs to obtain detailed Terraform core and provider diagnostic output while troubleshooting; the named TF_LOG=INFO instead handles the requirement to record higher-level operational messages during troubleshooting, so this behavior does not describe TF_LOG=INFO in the situation named.

D:

The description applies to TF_LOG_PROVIDER when an engineer needs to isolate provider-related diagnostic output during API troubleshooting; the named TF_LOG=INFO instead handles the requirement to record higher-level operational messages during troubleshooting, so this behavior does not describe TF_LOG=INFO in the situation named.

E:

The description applies to TF_LOG_PATH when an engineer needs to save enabled Terraform diagnostic logs to a designated file; the named TF_LOG=INFO instead handles the requirement to record higher-level operational messages during troubleshooting, so this behavior does not describe TF_LOG=INFO in the situation named.

Question 42

The team evaluates “terraform providers” for a requirement to inspect which providers the current configuration requires. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. State mv updates address mapping within state and does not move the real infrastructure object between regions or accounts.
  2. The providers command displays provider requirements and their module relationships for dependency troubleshooting.
  3. Workspace selection changes which workspace state namespace the root configuration uses; it does not select a cloud account automatically.
  4. The JSON representation supports automated inspection but must be protected because redacted display is not a security boundary.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to inspect which providers the current configuration requires, so it produces the behavior described. In contrast, terraform workspace select serves a different goal: switch the currently selected Terraform CLI workspace, not inspect which providers the current configuration requires.

Incorrect Answers

A:

The description applies to terraform state mv when an engineer needs to change a tracked object's resource address after an intentional refactor; the named terraform providers instead handles the requirement to inspect which providers the current configuration requires, so this behavior does not describe terraform providers in the situation named.

C:

The description applies to terraform workspace select when an engineer needs to switch the currently selected Terraform CLI workspace; the named terraform providers instead handles the requirement to inspect which providers the current configuration requires, so this behavior does not describe terraform providers in the situation named.

D:

The description applies to terraform show -json when an engineer needs to read plan or state information in a structured representation; the named terraform providers instead handles the requirement to inspect which providers the current configuration requires, so this behavior does not describe terraform providers in the situation named.

Question 43

The team evaluates “A public registry module source” for a requirement to download a community module published with an official registry address. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. Published module documentation and metadata describe the module interface and help consumers understand required arguments.
  2. Registry module sources use the namespace/name/provider address form and can support a separate version argument.
  3. A source address ending in ?ref=... selects a Git revision; it does not use the registry-specific module version argument.
  4. Keeping reusable child modules separately versioned allows independent adoption and maintenance by different Terraform root modules.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to download a community module published with an official registry address, 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 download a community module published with an official registry address.

Incorrect Answers

A:

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 a public registry module source instead handles the requirement to download a community module published with an official registry address, so this behavior does not describe A public registry module source in the situation named.

C:

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 a public registry module source instead handles the requirement to download a community module published with an official registry address, so this behavior does not describe A public registry module source in the situation named.

D:

The description applies to a separate module repository when an engineer needs to share reusable Terraform configuration with multiple root projects; the named a public registry module source instead handles the requirement to download a community module published with an official registry address, so this behavior does not describe A public registry module source in the situation named.

Question 44

During an infrastructure design review about how to create an explicit ordering edge for module resources that have a real hidden dependency, a maintainer asks what “Module-level depends_on” does. Which description is accurate?

  1. depends_on on a module call affects all resources and data sources inside that module and can constrain concurrency.
  2. Reusable modules normally declare provider requirements while callers supply provider configurations and credentials.
  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:

The named mechanism is used when the objective is to create an explicit ordering edge for module resources that have a real hidden dependency, so it produces the behavior described. In contrast, a module root directory serves a different goal: understand which source files Terraform loads as one module, not create an explicit ordering edge for module resources that have a real hidden dependency.

Incorrect Answers

B:

The description applies to avoiding hard-coded child credentials when an engineer needs to keep authentication and deployment-specific region choices outside a reusable child module; the named module-level depends_on instead handles the requirement to create an explicit ordering edge for module resources that have a real hidden dependency, so this behavior does not describe Module-level depends_on in the situation named.

C:

The description applies to a module root directory when an engineer needs to understand which source files Terraform loads as one module; the named module-level depends_on instead handles the requirement to create an explicit ordering edge for module resources that have a real hidden dependency, so this behavior does not describe Module-level depends_on in the situation named.

D:

The description applies to a module output reference when an engineer needs to use a network module's subnet IDs inside an application module call; the named module-level depends_on instead handles the requirement to create an explicit ordering edge for module resources that have a real hidden dependency, so this behavior does not describe Module-level depends_on in the situation named.

Question 45

A Terraform runbook prescribes “Reusing modules” to see intended infrastructure changes without immediately creating them, but it does not meet the requirement. What does that step actually accomplish?

  1. A policy or governance stage can inspect proposed infrastructure changes before allowing an apply to proceed.
  2. Terraform input variables permit different values for capacity, names and endpoints without copying the entire resource definition.
  3. A Terraform plan is a reviewable proposed set of actions; execution occurs only when an apply runs against the chosen plan.
  4. A module packages input variables, resources and outputs so callers can reuse a consistent infrastructure design.

Explanation

Correct Answer

D:

Reusing modules is used when an operator needs to standardize a reusable network pattern across multiple applications. Consequently, this choice cannot meet the separate requirement to see intended infrastructure changes without immediately creating them. The intended action would instead require Plan-before-apply reviews.

Incorrect Answers

A:

This behavior belongs to Policy checks before provisioning, which helps engineers enforce organizational infrastructure constraints consistently rather than satisfying the separate requirement to see intended infrastructure changes without immediately creating them. The attempted technique was Reusing modules; it would instead be used to standardize a reusable network pattern across multiple applications, not to produce the effect associated with Policy checks before provisioning.

B:

This behavior belongs to Environment parametrization, which helps engineers deploy similarly structured stacks with environment-specific settings rather than satisfying the separate requirement to see intended infrastructure changes without immediately creating them. The attempted technique was Reusing modules; it would instead be used to standardize a reusable network pattern across multiple applications, not to produce the effect associated with Environment parametrization.

C:

That outcome belongs to Plan-before-apply reviews, the mechanism that can see intended infrastructure changes without immediately creating them. The question concerns the engineer’s actual proposal, Reusing modules; it is directed at standardize a reusable network pattern across multiple applications, not that result.

Question 46

A Terraform deployment has independent requirements: (1) keep API keys out of committed terraform.tfvars and .tf files; (2) reject use of queried data when it violates a required invariant. Which TWO mechanisms directly address these needs? Choose TWO.

  1. Vault-backed secret retrieval
  2. Data source postcondition
  3. An assert block inside check
  4. No secrets in version control
  5. The check block

Explanation

Correct Answers

B:

A postcondition on a data block can validate attributes returned from a provider before downstream resources rely on them; this meets the requirement to reject use of queried data when it violates a required invariant, while the other selected techniques address keep API keys out of committed terraform.tfvars and .tf files, which require their own distinct Terraform mechanisms.

D:

Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; this meets the requirement to keep API keys out of committed terraform.tfvars and .tf files, while the other selected techniques address reject use of queried data when it violates a required invariant, which require their own distinct Terraform mechanisms.

Incorrect Answers

A:

Vault can centralize secret lifecycle, policies and auditability, but provider and state-handling choices still determine whether a retrieved value is persisted; it addresses retrieve an operational credential from a dedicated secret manager rather than committing it, but this delivery instead requires keep API keys out of committed terraform.tfvars and .tf files and reject use of queried data when it violates a required invariant. The required combination involves Data source postcondition and No secrets in version control, not the behavior of Vault-backed secret retrieval.

C:

Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion; it addresses define a specific boolean statement for a nonblocking Terraform health check, but this delivery instead requires keep API keys out of committed terraform.tfvars and .tf files and reject use of queried data when it violates a required invariant. The required combination involves Data source postcondition and No secrets in version control, not the behavior of An assert block inside check.

E:

Check assertions evaluate health expectations and normally report warning diagnostics rather than blocking deployment on a false condition; it addresses report a failed ongoing infrastructure assertion without ordinarily blocking the apply, but this delivery instead requires keep API keys out of committed terraform.tfvars and .tf files and reject use of queried data when it violates a required invariant. The required combination involves Data source postcondition and No secrets in version control, not the behavior of The check block.

Question 47

During a design review, the requirement is to inject a caller-supplied input into a resource argument. Which option should the engineer select?

  1. A variable reference
  2. A for_each instance address
  3. The resource address format
  4. Avoiding dependency cycles
  5. Explicit depends_on

Explanation

Correct Answer

A:

var.NAME reads a declared input variable in the module where the variable block is defined; this directly meets the requirement to inject a caller-supplied input into a resource argument. By comparison, a for_each instance address is intended to identify a single managed object selected by a string key, which is a different task from inject a caller-supplied input into a resource argument.

Incorrect Answers

B:

Instances made from a map or string set have addresses such as aws_instance.web["blue"], rather than an integer count index; this mechanism is useful when the job is to identify a single managed object selected by a string key, whereas the current scenario requires the engineer to inject a caller-supplied input into a resource argument. These operations have different effects in the stated Terraform workflow.

C:

A resource address inside a module ordinarily uses TYPE.NAME, with optional instance indexing when count or for_each is used; this mechanism is useful when the job is to identify a resource instance by its type and local name, whereas the current scenario requires the engineer to inject a caller-supplied input into a resource argument. These operations have different effects in the stated Terraform workflow.

D:

Terraform cannot order a cycle of dependencies; restructure references or resource design to remove the circular edge; this mechanism is useful when the job is to resolve a graph where two resources each depend on the other, whereas the current scenario requires the engineer to inject a caller-supplied input into a resource argument. These operations have different effects in the stated Terraform workflow.

E:

The depends_on meta-argument adds dependency edges for a known relationship that Terraform cannot otherwise infer; this mechanism is useful when the job is to order resources when there is a dependency not expressed by attribute references, whereas the current scenario requires the engineer to inject a caller-supplied input into a resource argument. These operations have different effects in the stated Terraform workflow.

Question 48

A Terraform reviewer encounters “each.key” while assessing how to refer to the stable key of a for_each resource instance. Which statement correctly describes its actual behavior?

  1. An output block can use depends_on for dependencies that are not evident from its value expression.
  2. In a for_each resource block, each.key identifies the current map key or set element for that instance.
  3. Referencing another managed resource's attribute creates an implicit dependency in Terraform's graph.
  4. The syntax data.TYPE.NAME.ATTRIBUTE accesses attributes returned by an existing-object query.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to refer to the stable key of a for_each resource instance, so it produces the behavior described. In contrast, an implicit attribute dependency serves a different goal: ensure a dependent resource waits for the object whose ID it needs, not refer to the stable key of a for_each resource instance.

Incorrect Answers

A:

The description applies to output dependency metadata when an engineer needs to delay the visibility of an output until additional required operations finish; the named each.key instead handles the requirement to refer to the stable key of a for_each resource instance, so this behavior does not describe each.key in the situation named.

C:

The description applies to an implicit attribute dependency when an engineer needs to ensure a dependent resource waits for the object whose ID it needs; the named each.key instead handles the requirement to refer to the stable key of a for_each resource instance, so this behavior does not describe each.key in the situation named.

D:

The description applies to a data attribute reference when an engineer needs to read a field from a configured data source in another expression; the named each.key instead handles the requirement to refer to the stable key of a for_each resource instance, so this behavior does not describe each.key in the situation named.

Question 49

During an infrastructure design review about how to skip backend initialization during a specialized init operation, a maintainer asks what “terraform init -backend=false” does. Which description is accurate?

  1. The backend=false switch suppresses backend setup; commands needing backend access may then be unable to proceed.
  2. Upgrade tells init to reconsider prior module selections instead of simply reusing previously installed versions.
  3. Terraform creates .terraform for module caches, provider installations and backend/workspace metadata; it is not a substitute for committed configuration.
  4. The migrate-state flag attempts to copy prior state into the new backend and can prompt for migration confirmation.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to skip backend initialization during a specialized init operation, so it produces the behavior described. In contrast, terraform init -upgrade for modules serves a different goal: fetch newer module releases permitted by version constraints, not skip backend initialization during a specialized init operation.

Incorrect Answers

B:

The description applies to terraform init -upgrade for modules when an engineer needs to fetch newer module releases permitted by version constraints; the named terraform init -backend=false instead handles the requirement to skip backend initialization during a specialized init operation, so this behavior does not describe terraform init -backend=false in the situation named.

C:

The description applies to the .terraform directory when an engineer needs to identify where a working directory keeps installed modules and initialization metadata; the named terraform init -backend=false instead handles the requirement to skip backend initialization during a specialized init operation, so this behavior does not describe terraform init -backend=false in the situation named.

D:

The description applies to terraform init -migrate-state when an engineer needs to move existing state to a newly configured backend; the named terraform init -backend=false instead handles the requirement to skip backend initialization during a specialized init operation, so this behavior does not describe terraform init -backend=false in the situation named.

Question 50

A Terraform operations troubleshooting session has a concrete implementation goal: read an existing cloud object so Terraform can associate it with state. What is the most appropriate Terraform mechanism?

  1. An import block's to argument
  2. A matching resource declaration
  3. Provider permissions during import
  4. The import block

Explanation

Correct Answer

C:

Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID; this directly meets the requirement to read an existing cloud object so Terraform can associate it with state. By comparison, a matching resource declaration is intended to avoid unintended changes immediately after importing a remote object, which is a different task from read an existing cloud object so Terraform can associate it with state.

Incorrect Answers

A:

The to argument points to an intended Terraform resource address rather than a provider account name or state backend; this mechanism is useful when the job is to specify which resource instance address should receive the imported object, whereas the current scenario requires the engineer to read an existing cloud object so Terraform can associate it with state. These operations have different effects in the stated Terraform workflow.

B:

Imported infrastructure should have a corresponding resource block with configuration matching the desired attributes so the next plan is safe; this mechanism is useful when the job is to avoid unintended changes immediately after importing a remote object, whereas the current scenario requires the engineer to read an existing cloud object so Terraform can associate it with state. These operations have different effects in the stated Terraform workflow.

D:

A top-level import block identifies a target resource address and import identity so the operation participates in plan and apply; this mechanism is useful when the job is to declare a managed import operation in configuration for planning and applying, whereas the current scenario requires the engineer to read an existing cloud object so Terraform can associate it with state. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests