Question 230
A runbook lists “Drift detection boundaries” for the task to understand that Terraform only examines infrastructure represented in its configuration or state scope. Which technical effect should its description include?
- The lifecycle ignore_changes rule suppresses post-creation update plans for selected attributes while leaving other attributes managed.
- A plan does not discover every unmanaged object in an account; its normal focus is tracked resources and configured data sources.
- Refresh-only apply can update the recorded state to match observed remote attributes without modifying cloud resources.
- State metadata such as lineage and serial helps protect against incompatible or stale state updates.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to understand that Terraform only examines infrastructure represented in its configuration or state scope, so it produces the behavior described. In contrast, serial and lineage checks serves a different goal: detect that a state snapshot belongs to a different history or older generation, not understand that Terraform only examines infrastructure represented in its configuration or state scope.
Incorrect Answers
A:The description applies to ignore_changes for shared ownership when an engineer needs to stop Terraform from overwriting a field delegated to an external controller; the named drift detection boundaries instead handles the requirement to understand that Terraform only examines infrastructure represented in its configuration or state scope, so this behavior does not describe Drift detection boundaries in the situation named.
C:The description applies to terraform apply -refresh-only when an engineer needs to accept current remote readings into Terraform's state through an apply operation; the named drift detection boundaries instead handles the requirement to understand that Terraform only examines infrastructure represented in its configuration or state scope, so this behavior does not describe Drift detection boundaries in the situation named.
D:The description applies to serial and lineage checks when an engineer needs to detect that a state snapshot belongs to a different history or older generation; the named drift detection boundaries instead handles the requirement to understand that Terraform only examines infrastructure represented in its configuration or state scope, so this behavior does not describe Drift detection boundaries in the situation named.
Question 231
A team proposes “Backend-specific lock support” to release a stale lock when the original process is definitively gone. If they proceed with that technique, which result should they anticipate instead?
- The force-unlock command removes a lock by its identifier; using it during an active operation can cause state corruption.
- A lock may belong to another active run, so check its identity and run status rather than immediately forcing removal.
- Backend state locking behavior depends on the backend implementation; remote storage alone does not guarantee safe locking.
- Terraform obtains and releases supported backend locks around state-sensitive operations; a crash can sometimes leave manual recovery necessary.
Explanation
Correct Answer
C:Backend-specific lock support is used when an operator needs to check whether a chosen remote backend actually offers state locking. Consequently, this choice cannot meet the separate requirement to release a stale lock when the original process is definitively gone. The intended action would instead require terraform force-unlock.
Incorrect Answers
A:That outcome belongs to terraform force-unlock, the mechanism that can release a stale lock when the original process is definitively gone. The question concerns the engineer’s actual proposal, Backend-specific lock support; it is directed at check whether a chosen remote backend actually offers state locking, not that result.
B:This behavior belongs to Lock ownership verification, which helps engineers confirm that a held lock is stale before attempting manual removal rather than satisfying the separate requirement to release a stale lock when the original process is definitively gone. The attempted technique was Backend-specific lock support; it would instead be used to check whether a chosen remote backend actually offers state locking, not to produce the effect associated with Lock ownership verification.
D:This behavior belongs to Lock release after completion, which helps engineers understand why a normal Terraform operation frees the lock rather than satisfying the separate requirement to release a stale lock when the original process is definitively gone. The attempted technique was Backend-specific lock support; it would instead be used to check whether a chosen remote backend actually offers state locking, not to produce the effect associated with Lock release after completion.
Question 232
A Terraform module author has a concrete implementation goal: authenticate a provider using a transient secret that should not persist. What is the most appropriate Terraform mechanism?
- Vault-backed secret retrieval
- No secrets in version control
- Remote state access controls
- Passing ephemeral values to providers
Explanation
Correct Answer
D:Provider configuration is an allowed reference context for ephemeral variables, enabling runtime-only authentication values; this directly meets the requirement to authenticate a provider using a transient secret that should not persist. 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 authenticate a provider using a transient secret that should not persist.
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; 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 authenticate a provider using a transient secret that should not persist. These operations have different effects in the stated Terraform workflow.
B: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 authenticate a provider using a transient secret that should not persist. These operations have different effects in the stated Terraform workflow.
C: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 authenticate a provider using a transient secret that should not persist. These operations have different effects in the stated Terraform workflow.
Question 233
A remote-state operations review requires a way to protect a workstation's local state file even when output values are hidden. Which Terraform approach most directly fulfills that request?
- A local backend path setting
- Backend configuration only in a root module
- Local state in CI
- State file confidentiality
Explanation
Correct Answer
D:Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter; this directly meets the requirement to protect a workstation's local state file even when output values are hidden. By comparison, a local backend path setting is intended to save the default workspace state to a nondefault local filename, which is a different task from protect a workstation's local state file even when output values are hidden.
Incorrect Answers
A:The local backend supports a path argument for where the state file is stored on disk; this mechanism is useful when the job is to save the default workspace state to a nondefault local filename, whereas the current scenario requires the engineer to protect a workstation's local state file even when output values are hidden. These operations have different effects in the stated Terraform workflow.
B:Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state; this mechanism is useful when the job is to choose where a root deployment's state will be stored, whereas the current scenario requires the engineer to protect a workstation's local state file even when output values are hidden. These operations have different effects in the stated Terraform workflow.
C:A temporary runner may lose its filesystem after a job, so durable shared state is usually needed for repeatable team automation; this mechanism is useful when the job is to recognize why ephemeral build agents should not rely on a machine-local state file, whereas the current scenario requires the engineer to protect a workstation's local state file even when output values are hidden. These operations have different effects in the stated Terraform workflow.
Question 234
During an infrastructure design review about how to make a CI formatting gate detect source files that need formatting, a maintainer asks what “terraform fmt -check” does. Which description is accurate?
- Check mode verifies formatting and returns a failure when changes would be required instead of writing edited files.
- terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable.
- Applying formatter conventions consistently makes code review focus on meaningful resource and expression edits.
- The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to make a CI formatting gate detect source files that need formatting, so it produces the behavior described. In contrast, canonical HCL alignment serves a different goal: keep spacing and indentation consistent between developers, not make a CI formatting gate detect source files that need formatting.
Incorrect Answers
B:The description applies to formatting versus validation when an engineer needs to distinguish style-only issues from Terraform type and schema errors; the named terraform fmt -check instead handles the requirement to make a CI formatting gate detect source files that need formatting, so this behavior does not describe terraform fmt -check in the situation named.
C:This describes Format before source review and its job to reduce whitespace-only churn in infrastructure pull requests, whereas the question asks about terraform fmt -check. The latter is the mechanism used to make a CI formatting gate detect source files that need formatting; the proposed effect belongs to a different Terraform feature.
D:The description applies to canonical HCL alignment when an engineer needs to keep spacing and indentation consistent between developers; the named terraform fmt -check instead handles the requirement to make a CI formatting gate detect source files that need formatting, so this behavior does not describe terraform fmt -check in the situation named.
Question 235
A Terraform change proposal names “A resource action marked minus” to interpret a plan showing a resource that Terraform will destroy. Which outcome can reviewers attribute to that particular mechanism?
- Detailed exit codes are 0 for no diff, 2 for a nonempty successful plan and 1 for an error.
- In human-readable plans, - denotes a planned destruction of a managed resource.
- Terraform may mark attributes as known after apply because a provider assigns their values only when creating or updating a real object.
- Planning calculates an execution proposal after reading configuration and usually refreshing managed resource data.
- Refresh-only planning proposes changes to Terraform state or root outputs based on remote observations, without proposing ordinary resource updates.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to interpret a plan showing a resource that Terraform will destroy, so it produces the behavior described. In contrast, terraform plan serves a different goal: preview resource actions implied by the current configuration and state, not interpret a plan showing a resource that Terraform will destroy.
Incorrect Answers
A:The description applies to terraform plan -detailed-exitcode when an engineer needs to distinguish no changes from proposed changes in automation; the named a resource action marked minus instead handles the requirement to interpret a plan showing a resource that Terraform will destroy, so this behavior does not describe A resource action marked minus in the situation named.
C:The description applies to an unknown value until apply when an engineer needs to understand why a computed attribute is unavailable in the preview; the named a resource action marked minus instead handles the requirement to interpret a plan showing a resource that Terraform will destroy, so this behavior does not describe A resource action marked minus in the situation named.
D:The description applies to terraform plan when an engineer needs to preview resource actions implied by the current configuration and state; the named a resource action marked minus instead handles the requirement to interpret a plan showing a resource that Terraform will destroy, so this behavior does not describe A resource action marked minus in the situation named.
E:The description applies to terraform plan -refresh-only when an engineer needs to propose updating state or root outputs to reflect remote changes without planning infrastructure remediation; the named a resource action marked minus instead handles the requirement to interpret a plan showing a resource that Terraform will destroy, so this behavior does not describe A resource action marked minus in the situation named.
Question 236
In a Terraform configuration, what value does the HCL expression distinct(["a", "b", "a", "c"]) evaluate to?
- ["a", "b", "c"]
- ["a", "b", "a", "c"]
- ["b", "c"]
- ["a", "c", "b"]
Explanation
Correct Answer
A:The expression distinct(["a", "b", "a", "c"]) evaluates to ["a", "b", "c"] because distinct keeps the first occurrence of each value and drops later duplicates. This is Terraform's direct evaluation of the supplied literal arguments in distinct(["a", "b", "a", "c"]), not an external provider lookup.
Incorrect Answers
B:The repeated second a is removed by distinct. For distinct(["a", "b", "a", "c"]), distinct keeps the first occurrence of each value and drops later duplicates; consequently this candidate is not the value Terraform computes.
C:The first a remains valid and is not eliminated with its duplicate. HCL evaluates distinct(["a", "b", "a", "c"]) using the supplied arguments: distinct keeps the first occurrence of each value and drops later duplicates; the listed result is therefore incorrect.
D:Distinct preserves first-occurrence order instead of sorting values anew. In this specific evaluation, distinct keeps the first occurrence of each value and drops later duplicates, which rules out the proposed alternative.
Question 237
A Terraform reviewer encounters “A tagged cloud workspaces block” while assessing how to select workspaces using Terraform cloud configuration rather than a single explicit name. Which statement correctly describes its actual behavior?
- A run trigger can initiate a downstream plan when its designated upstream workspace completes the relevant run.
- The cloud block can select a workspace set by supported tags, which differs from specifying one workspace name.
- Variable sets can be scoped to projects to share configuration while avoiding repetitive per-workspace assignments.
- Project-level access scopes workspace capabilities for teams based on organizational boundaries.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to select workspaces using Terraform cloud configuration rather than a single explicit name, so it produces the behavior described. In contrast, HCP Terraform run triggers between workspaces serves a different goal: coordinate a dependent app deployment following an upstream network workspace apply, not select workspaces using Terraform cloud configuration rather than a single explicit name.
Incorrect Answers
A:The description applies to HCP Terraform run triggers between workspaces when an engineer needs to coordinate a dependent app deployment following an upstream network workspace apply; the named a tagged cloud workspaces block instead handles the requirement to select workspaces using Terraform cloud configuration rather than a single explicit name, so this behavior does not describe A tagged cloud workspaces block in the situation named.
C:The description applies to project-level variable sets when an engineer needs to assign common environment values to a group of workspaces; the named a tagged cloud workspaces block instead handles the requirement to select workspaces using Terraform cloud configuration rather than a single explicit name, so this behavior does not describe A tagged cloud workspaces block in the situation named.
D:The description applies to project-scoped team access when an engineer needs to delegate administration of one team's project without granting universal organization access; the named a tagged cloud workspaces block instead handles the requirement to select workspaces using Terraform cloud configuration rather than a single explicit name, so this behavior does not describe A tagged cloud workspaces block in the situation named.
Question 238
An engineer intends to load a conventional set of root-module variable assignments automatically and is reviewing “A terraform.tfvars file”. What consequence follows from using it as intended?
- The -raw output mode prints a single string, number or boolean value in a script-friendly form and may reveal sensitive data.
- A child module must explicitly export an output for its parent to access it through module.CHILD.OUTPUT.
- Terraform automatically discovers terraform.tfvars and terraform.tfvars.json in the working directory.
- The default argument supplies a value when the caller provides no other assignment for that variable.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to load a conventional set of root-module variable assignments automatically, so it produces the behavior described. In contrast, a child module output block serves a different goal: make a child module's private resource attribute available to its caller, not load a conventional set of root-module variable assignments automatically.
Incorrect Answers
A:The description applies to terraform output -raw when an engineer needs to extract a primitive output without the surrounding formatted representation; the named a terraform.tfvars file instead handles the requirement to load a conventional set of root-module variable assignments automatically, so this behavior does not describe A terraform.tfvars file in the situation named.
B:The description applies to a child module output block when an engineer needs to make a child module's private resource attribute available to its caller; the named a terraform.tfvars file instead handles the requirement to load a conventional set of root-module variable assignments automatically, so this behavior does not describe A terraform.tfvars file in the situation named.
D:The description applies to a variable default value when an engineer needs to make a module input optional for callers using a common baseline; the named a terraform.tfvars file instead handles the requirement to load a conventional set of root-module variable assignments automatically, so this behavior does not describe A terraform.tfvars file in the situation named.
Question 239
During a design review, the requirement is to declare a managed import operation in configuration for planning and applying. Which option should the engineer select?
- The import block
- terraform import ADDRESS ID
- Importing without creating new infrastructure
- Separate resources for separate imports
Explanation
Correct Answer
A:A top-level import block identifies a target resource address and import identity so the operation participates in plan and apply; this directly meets the requirement to declare a managed import operation in configuration for planning and applying. By comparison, importing without creating new infrastructure is intended to take ownership of an existing object rather than duplicating it, which is a different task from declare a managed import operation in configuration for planning and applying.
Incorrect Answers
B:The import CLI command records a provider-defined remote ID at a Terraform address but does not automatically write a complete resource block; this mechanism is useful when the job is to associate one existing remote object with a configured resource address, whereas the current scenario requires the engineer to declare a managed import operation in configuration for planning and applying. These operations have different effects in the stated Terraform workflow.
C:The import workflow adds an existing remote object to state and can manage it through later plans instead of creating a replacement automatically; this mechanism is useful when the job is to take ownership of an existing object rather than duplicating it, whereas the current scenario requires the engineer to declare a managed import operation in configuration for planning and applying. These operations have different effects in the stated Terraform workflow.
D:Each managed remote object should have its own appropriate resource instance address so state can map objects unambiguously; this mechanism is useful when the job is to avoid attaching two remote objects to the same Terraform resource address, whereas the current scenario requires the engineer to declare a managed import operation in configuration for planning and applying. These operations have different effects in the stated Terraform workflow.
Question 240
A state migration and recovery exercise needs to declare that a resource should leave management while its actual object is retained. Which feature or operation is the most direct match?
- A removed block with destroy=false
- Serial and lineage checks
- ignore_changes for shared ownership
- A state import workflow
- terraform apply -refresh-only
Explanation
Correct Answer
A:A removed block can intentionally forget the previous resource address without a provider delete when lifecycle destroy is false; this directly meets the requirement to declare that a resource should leave management while its actual object is retained. By comparison, terraform apply -refresh-only is intended to accept current remote readings into Terraform's state through an apply operation, which is a different task from declare that a resource should leave management while its actual object is retained.
Incorrect Answers
B:State metadata such as lineage and serial helps protect against incompatible or stale state updates; this mechanism is useful when the job is to detect that a state snapshot belongs to a different history or older generation, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.
C:The lifecycle ignore_changes rule suppresses post-creation update plans for selected attributes while leaving other attributes managed; this mechanism is useful when the job is to stop Terraform from overwriting a field delegated to an external controller, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.
D:Importing attaches the remote object's identity to state; compatible configuration is still needed to avoid unwanted changes afterward; this mechanism is useful when the job is to associate existing infrastructure with a newly declared Terraform resource address, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.
E:Refresh-only apply can update the recorded state to match observed remote attributes without modifying cloud resources; this mechanism is useful when the job is to accept current remote readings into Terraform's state through an apply operation, whereas the current scenario requires the engineer to declare that a resource should leave management while its actual object is retained. These operations have different effects in the stated Terraform workflow.