Question 900
An infrastructure drift investigation has a concrete implementation goal: accept current remote readings into Terraform's state through an apply operation. What is the most appropriate Terraform mechanism?
- Avoid direct state JSON editing
- Drift detection boundaries
- A removed block with destroy=false
- terraform apply -refresh-only
Explanation
Correct Answer
D:Refresh-only apply can update the recorded state to match observed remote attributes without modifying cloud resources; this directly meets the requirement to accept current remote readings into Terraform's state through an apply operation. By comparison, avoid direct state JSON editing is intended to make state changes through supported Terraform commands and declarative refactors, which is a different task from accept current remote readings into Terraform's state through an apply operation.
Incorrect Answers
A:Manual state-file changes can break address mappings or serial consistency; commands such as state mv and moved blocks are safer; this mechanism is useful when the job is to make state changes through supported Terraform commands and declarative refactors, whereas the current scenario requires the engineer to accept current remote readings into Terraform's state through an apply operation. These operations have different effects in the stated Terraform workflow.
B:A plan does not discover every unmanaged object in an account; its normal focus is tracked resources and configured data sources; this mechanism is useful when the job is to understand that Terraform only examines infrastructure represented in its configuration or state scope, whereas the current scenario requires the engineer to accept current remote readings into Terraform's state through an apply operation. These operations have different effects in the stated Terraform workflow.
C:A removed block can intentionally forget the previous resource address without a provider delete when lifecycle destroy is false; this mechanism is useful when the job is to declare that a resource should leave management while its actual object is retained, whereas the current scenario requires the engineer to accept current remote readings into Terraform's state through an apply operation. These operations have different effects in the stated Terraform workflow.
Question 901
During an infrastructure design review about how to run unchanged configuration repeatedly without inventing new infrastructure updates, a maintainer asks what “Idempotent convergence” does. Which description is accurate?
- A backend supporting remote storage and locking can centralize state and prevent conflicting concurrent changes.
- Version control and run history provide traceable context for what configuration changed and what Terraform planned or applied.
- Terraform can refresh managed objects during planning and flag differences between the observed infrastructure and configuration.
- With no configuration or remote drift requiring action, a new plan normally proposes no infrastructure changes.
- Terraform infers many dependencies from references and applies graph ordering to create or modify related resources safely.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to run unchanged configuration repeatedly without inventing new infrastructure updates, so it produces the behavior described. In contrast, consistent dependency management serves a different goal: avoid hand-sequencing every resource operation, not run unchanged configuration repeatedly without inventing new infrastructure updates.
Incorrect Answers
A:The description applies to collaboration through remote state when an engineer needs to allow authorized operators to use one shared source of Terraform state; the named idempotent convergence instead handles the requirement to run unchanged configuration repeatedly without inventing new infrastructure updates, so this behavior does not describe Idempotent convergence in the situation named.
B:The description applies to reusable execution records when an engineer needs to audit the results of infrastructure changes across a team; the named idempotent convergence instead handles the requirement to run unchanged configuration repeatedly without inventing new infrastructure updates, so this behavior does not describe Idempotent convergence in the situation named.
C:The description applies to drift detection during planning when an engineer needs to notice remote infrastructure changes made outside Terraform; the named idempotent convergence instead handles the requirement to run unchanged configuration repeatedly without inventing new infrastructure updates, so this behavior does not describe Idempotent convergence in the situation named.
E:The description applies to consistent dependency management when an engineer needs to avoid hand-sequencing every resource operation; the named idempotent convergence instead handles the requirement to run unchanged configuration repeatedly without inventing new infrastructure updates, so this behavior does not describe Idempotent convergence in the situation named.
Question 902
A pipeline responsible for the Terraform workflow has a concrete implementation goal: recognize a destroy-and-create operation for an immutable argument. What is the most appropriate Terraform mechanism?
- A replacement action in the plan
- terraform plan -out
- terraform plan -target
- An unknown value until apply
- terraform plan -refresh=false
- The dependency graph during planning
Explanation
Correct Answer
A:Plans show replacement when the provider cannot update a changed property in place; create-before-destroy can change the replacement order; this directly meets the requirement to recognize a destroy-and-create operation for an immutable argument. By comparison, the dependency graph during planning is intended to explain why two unrelated resources can be planned and applied in parallel, which is a different task from recognize a destroy-and-create operation for an immutable argument.
Incorrect Answers
B:The -out option writes a saved plan so the reviewed actions can be supplied to terraform apply without recomputing from modified inputs; this mechanism is useful when the job is to save an execution plan to a binary file for later application, whereas the current scenario requires the engineer to recognize a destroy-and-create operation for an immutable argument. These operations have different effects in the stated Terraform workflow.
C:Targeting narrows planning scope and can miss other required changes, so it is not the normal long-term workflow; this mechanism is useful when the job is to limit a recovery-oriented plan to a resource and its dependencies, whereas the current scenario requires the engineer to recognize a destroy-and-create operation for an immutable argument. These operations have different effects in the stated Terraform workflow.
D:Terraform may mark attributes as known after apply because a provider assigns their values only when creating or updating a real object; this mechanism is useful when the job is to understand why a computed attribute is unavailable in the preview, whereas the current scenario requires the engineer to recognize a destroy-and-create operation for an immutable argument. These operations have different effects in the stated Terraform workflow.
E:Disabling refresh reduces remote reads but can hide drift and produce an inaccurate plan based on stale observations; this mechanism is useful when the job is to skip routine state refresh for a constrained preview, whereas the current scenario requires the engineer to recognize a destroy-and-create operation for an immutable argument. These operations have different effects in the stated Terraform workflow.
F:Terraform graph nodes can run concurrently when no dependency edge requires a particular order; this mechanism is useful when the job is to explain why two unrelated resources can be planned and applied in parallel, whereas the current scenario requires the engineer to recognize a destroy-and-create operation for an immutable argument. These operations have different effects in the stated Terraform workflow.
Question 903
A diagnostic incident during Terraform execution has a concrete implementation goal: inspect which providers the current configuration requires. What is the most appropriate Terraform mechanism?
- terraform state pull
- terraform state replace-provider
- terraform state rm
- terraform workspace list
- terraform providers
Explanation
Correct Answer
E:The providers command displays provider requirements and their module relationships for dependency troubleshooting; this directly meets the requirement to inspect which providers the current configuration requires. By comparison, terraform state replace-provider is intended to update the provider source address recorded for affected state resources, which is a different task from inspect which providers the current configuration requires.
Incorrect Answers
A:State pull reads the current snapshot to standard output, including potentially sensitive provider attributes; this mechanism is useful when the job is to export a state snapshot from the configured backend for careful examination, whereas the current scenario requires the engineer to inspect which providers the current configuration requires. These operations have different effects in the stated Terraform workflow.
B:Replace-provider rewrites provider source references in state and creates a backup before the edit; this mechanism is useful when the job is to update the provider source address recorded for affected state resources, whereas the current scenario requires the engineer to inspect which providers the current configuration requires. These operations have different effects in the stated Terraform workflow.
C:State rm deletes the state association, not the object in the external system; this mechanism is useful when the job is to stop tracking a resource without telling its provider to delete the remote object, whereas the current scenario requires the engineer to inspect which providers the current configuration requires. These operations have different effects in the stated Terraform workflow.
D:Workspace list shows logical Terraform workspaces, which may correspond to separate state instances depending on backend support; this mechanism is useful when the job is to list the workspaces available through the initialized backend, whereas the current scenario requires the engineer to inspect which providers the current configuration requires. These operations have different effects in the stated Terraform workflow.
Question 904
A Terraform change proposal names “Apply with a .tfvars file” to supply a named collection of input assignments to Terraform. Which outcome can reviewers attribute to that particular mechanism?
- The -var-file option loads values from an input variables file, enabling separate environment assignments.
- The parallelism setting controls Terraform's concurrent resource operation count, which can mitigate API throttling.
- The auto-approve option allows the automatically created plan to proceed without interactive confirmation, so pipeline safeguards matter.
- Root output blocks expose values Terraform calculates from the applied resource graph; output display is not an access-control boundary.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to supply a named collection of input assignments to Terraform, so it produces the behavior described. In contrast, terraform apply -auto-approve serves a different goal: suppress Terraform's normal approval prompt in a controlled pipeline, not supply a named collection of input assignments to Terraform.
Incorrect Answers
B:The description applies to terraform apply -parallelism when an engineer needs to limit how many graph operations execute concurrently; the named apply with a .tfvars file instead handles the requirement to supply a named collection of input assignments to Terraform, so this behavior does not describe Apply with a .tfvars file in the situation named.
C:The description applies to terraform apply -auto-approve when an engineer needs to suppress Terraform's normal approval prompt in a controlled pipeline; the named apply with a .tfvars file instead handles the requirement to supply a named collection of input assignments to Terraform, so this behavior does not describe Apply with a .tfvars file in the situation named.
D:The description applies to post-apply outputs when an engineer needs to retrieve computed identifiers that can be used by deployment automation; the named apply with a .tfvars file instead handles the requirement to supply a named collection of input assignments to Terraform, so this behavior does not describe Apply with a .tfvars file in the situation named.
Question 905
During an infrastructure design review about how to avoid attaching two remote objects to the same Terraform resource address, a maintainer asks what “Separate resources for separate imports” does. Which description is accurate?
- The to argument points to an intended Terraform resource address rather than a provider account name or state backend.
- Each managed remote object should have its own appropriate resource instance address so state can map objects unambiguously.
- Provider documentation determines the required import identity; it may be an ID or compound identifier depending on resource type.
- Generated resource declarations are a starting point and can include computed or unsuitable attributes requiring manual cleanup.
- The experimental config-generation flag can write suggested resource declarations for review and correction before apply.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to avoid attaching two remote objects to the same Terraform resource address, so it produces the behavior described. In contrast, terraform plan -generate-config-out serves a different goal: produce draft HCL for resources named in import blocks without matching configuration, not avoid attaching two remote objects to the same Terraform resource address.
Incorrect Answers
A:The description applies to an import block's to argument when an engineer needs to specify which resource instance address should receive the imported object; the named separate resources for separate imports instead handles the requirement to avoid attaching two remote objects to the same Terraform resource address, so this behavior does not describe Separate resources for separate imports in the situation named.
C:The description applies to an import block's id argument when an engineer needs to supply the remote identifier in the format accepted by the resource's provider; the named separate resources for separate imports instead handles the requirement to avoid attaching two remote objects to the same Terraform resource address, so this behavior does not describe Separate resources for separate imports in the situation named.
D:The description applies to an import configuration review when an engineer needs to correct provider-generated HCL rather than trusting every inferred argument; the named separate resources for separate imports instead handles the requirement to avoid attaching two remote objects to the same Terraform resource address, so this behavior does not describe Separate resources for separate imports in the situation named.
E:The description applies to terraform plan -generate-config-out when an engineer needs to produce draft HCL for resources named in import blocks without matching configuration; the named separate resources for separate imports instead handles the requirement to avoid attaching two remote objects to the same Terraform resource address, so this behavior does not describe Separate resources for separate imports in the situation named.
Question 906
A Terraform change proposal names “Policy checks before provisioning” to enforce organizational infrastructure constraints consistently. Which outcome can reviewers attribute to that particular mechanism?
- Terraform can refresh managed objects during planning and flag differences between the observed infrastructure and configuration.
- With no configuration or remote drift requiring action, a new plan normally proposes no infrastructure changes.
- A version-control pull request can expose infrastructure edits to peer review, policy checks and automated validation.
- A policy or governance stage can inspect proposed infrastructure changes before allowing an apply to proceed.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to enforce organizational infrastructure constraints consistently, so it produces the behavior described. In contrast, drift detection during planning serves a different goal: notice remote infrastructure changes made outside Terraform, not enforce organizational infrastructure constraints consistently.
Incorrect Answers
A:The description applies to drift detection during planning when an engineer needs to notice remote infrastructure changes made outside Terraform; the named policy checks before provisioning instead handles the requirement to enforce organizational infrastructure constraints consistently, so this behavior does not describe Policy checks before provisioning in the situation named.
B:The description applies to idempotent convergence when an engineer needs to run unchanged configuration repeatedly without inventing new infrastructure updates; the named policy checks before provisioning instead handles the requirement to enforce organizational infrastructure constraints consistently, so this behavior does not describe Policy checks before provisioning in the situation named.
C:The description applies to code review of infrastructure when an engineer needs to catch undesirable configuration changes before deployment; the named policy checks before provisioning instead handles the requirement to enforce organizational infrastructure constraints consistently, so this behavior does not describe Policy checks before provisioning in the situation named.
Question 907
An engineer troubleshooting a .tf configuration requires a way to use a short-lived runtime secret without saving its value in plan or state. Which Terraform approach most directly fulfills that request?
- No secrets in version control
- Vault-backed secret retrieval
- ephemeral = true on a variable
- Environment-based provider credentials
Explanation
Correct Answer
C:Terraform 1.10+ ephemeral variables can flow only into allowed ephemeral contexts and are omitted from persisted artifacts; this directly meets the requirement to use a short-lived runtime secret without saving its value in plan or state. By comparison, no secrets in version control is intended to keep API keys out of committed terraform.tfvars and .tf files, which is a different task from use a short-lived runtime secret without saving its value in plan or state.
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 use a short-lived runtime secret without saving its value in plan or state. These operations have different effects in the stated Terraform workflow.
B: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 use a short-lived runtime secret without saving its value in plan or state. These operations have different effects in the stated Terraform workflow.
D:Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL; this mechanism is useful when the job is to avoid putting provider access tokens directly in configuration source, whereas the current scenario requires the engineer to use a short-lived runtime secret without saving its value in plan or state. These operations have different effects in the stated Terraform workflow.
Question 908
An engineer troubleshooting a .tf configuration needs to remove nested list layers to obtain a flat sequence. Which feature or operation is the most direct match?
- The dynamic block
- The flatten function
- The lower function
- The length function
Explanation
Correct Answer
B:flatten recursively replaces nested lists with their constituent elements, while preserving ordered traversal; this directly meets the requirement to remove nested list layers to obtain a flat sequence. By comparison, the dynamic block is intended to generate repeated nested blocks from a collection, which is a different task from remove nested list layers to obtain a flat sequence.
Incorrect Answers
A: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 remove nested list layers to obtain a flat sequence. These operations have different effects in the stated Terraform workflow.
C:lower converts letters to lowercase and is often used in consistent name expressions; this mechanism is useful when the job is to normalize a string identifier to lowercase, whereas the current scenario requires the engineer to remove nested list layers to obtain a flat sequence. These operations have different effects in the stated Terraform workflow.
D:length returns the collection size or string character count; it does not find an element's index; this mechanism is useful when the job is to count elements in a collection or characters in a string, whereas the current scenario requires the engineer to remove nested list layers to obtain a flat sequence. These operations have different effects in the stated Terraform workflow.
Question 909
A change request asks an engineer to accept values without imposing a specific static input shape. Which choice best implements the requested behavior?
- An unknown plan-time value
- tomap conversion
- tolist conversion
- The any type constraint
- toset conversion
Explanation
Correct Answer
D:The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts; this directly meets the requirement to accept values without imposing a specific static input shape. By comparison, an unknown plan-time value is intended to identify a computed attribute that Terraform cannot determine until apply, which is a different task from accept values without imposing a specific static input shape.
Incorrect Answers
A:An unknown value represents future information and can propagate through expressions until a provider supplies the result; this mechanism is useful when the job is to identify a computed attribute that Terraform cannot determine until apply, whereas the current scenario requires the engineer to accept values without imposing a specific static input shape. These operations have different effects in the stated Terraform workflow.
B:tomap attempts to convert an input value into a map whose values share a compatible element type; this mechanism is useful when the job is to turn a compatible collection into a uniform-keyed map, whereas the current scenario requires the engineer to accept values without imposing a specific static input shape. These operations have different effects in the stated Terraform workflow.
C:tolist converts compatible values to a list, but a source set's original order is not inherently meaningful; this mechanism is useful when the job is to coerce a suitable collection into a list for ordered operations, whereas the current scenario requires the engineer to accept values without imposing a specific static input shape. These operations have different effects in the stated Terraform workflow.
E:toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved; this mechanism is useful when the job is to deduplicate a collection of string identifiers for keyed iteration, whereas the current scenario requires the engineer to accept values without imposing a specific static input shape. These operations have different effects in the stated Terraform workflow.
Question 910
During a design review, the requirement is to identify which root-module-managed resources will be affected before a cleanup. Which option should the engineer select?
- terraform apply -destroy
- Dependency-aware deletion
- An explicit prevent_destroy rule
- Destroy plan risk review
Explanation
Correct Answer
D:Reviewing a destroy plan is essential because a command can remove every managed instance within the relevant state scope; this directly meets the requirement to identify which root-module-managed resources will be affected before a cleanup. By comparison, terraform apply -destroy is intended to execute a destroy-mode apply within a controlled workflow, which is a different task from identify which root-module-managed resources will be affected before a cleanup.
Incorrect Answers
A:The destroy mode tells apply to plan removal of managed resources rather than ordinary convergence to resource declarations; this mechanism is useful when the job is to execute a destroy-mode apply within a controlled workflow, whereas the current scenario requires the engineer to identify which root-module-managed resources will be affected before a cleanup. These operations have different effects in the stated Terraform workflow.
B:Terraform generally reverses dependency order when destroying managed resources so dependent objects are removed first; this mechanism is useful when the job is to remove dependent resources before objects they rely on, whereas the current scenario requires the engineer to identify which root-module-managed resources will be affected before a cleanup. These operations have different effects in the stated Terraform workflow.
C:The lifecycle prevent_destroy setting rejects a plan that destroys or replaces a configured resource while the rule remains present; this mechanism is useful when the job is to block a destructive plan for a protected configured resource, whereas the current scenario requires the engineer to identify which root-module-managed resources will be affected before a cleanup. These operations have different effects in the stated Terraform workflow.