Question 1000
A change-control meeting for a root module has a concrete implementation goal: execute a destroy-mode apply within a controlled workflow. What is the most appropriate Terraform mechanism?
- terraform apply -destroy
- Resource-specific delete restrictions
- terraform plan -destroy
- Remove from state without deletion
- terraform destroy
- Destroy plan risk review
Explanation
Correct Answer
A:The destroy mode tells apply to plan removal of managed resources rather than ordinary convergence to resource declarations; this directly meets the requirement to execute a destroy-mode apply within a controlled workflow. By comparison, remove from state without deletion is intended to stop managing an existing object while preserving the real remote infrastructure, which is a different task from execute a destroy-mode apply within a controlled workflow.
Incorrect Answers
B:Providers and remote APIs can reject deletion when dependencies, protection flags or permissions prevent removing the object; this mechanism is useful when the job is to diagnose why destroy fails despite valid Terraform syntax, whereas the current scenario requires the engineer to execute a destroy-mode apply within a controlled workflow. These operations have different effects in the stated Terraform workflow.
C:Destroy planning shows the deletion proposal without carrying out the deletion until apply; this mechanism is useful when the job is to review an all-destroy plan before approving resource deletion, whereas the current scenario requires the engineer to execute a destroy-mode apply within a controlled workflow. These operations have different effects in the stated Terraform workflow.
D:Removing a state association, for example with terraform state rm, makes Terraform forget the object without asking the provider to delete it; this mechanism is useful when the job is to stop managing an existing object while preserving the real remote infrastructure, whereas the current scenario requires the engineer to execute a destroy-mode apply within a controlled workflow. These operations have different effects in the stated Terraform workflow.
E:The destroy command plans and applies removal of managed objects subject to lifecycle and provider constraints; this mechanism is useful when the job is to remove the managed infrastructure described by the current Terraform configuration, whereas the current scenario requires the engineer to execute a destroy-mode apply within a controlled workflow. These operations have different effects in the stated Terraform workflow.
F:Reviewing a destroy plan is essential because a command can remove every managed instance within the relevant state scope; this mechanism is useful when the job is to identify which root-module-managed resources will be affected before a cleanup, whereas the current scenario requires the engineer to execute a destroy-mode apply within a controlled workflow. These operations have different effects in the stated Terraform workflow.
Question 1001
A Terraform reviewer encounters “Re-run init after a backend change” while assessing how to respond to a modified terraform backend block. Which statement correctly describes its actual behavior?
- Reconfigure tells init to treat the supplied backend configuration as new, rather than performing a state migration.
- Upgrade tells init to reconsider prior module selections instead of simply reusing previously installed versions.
- Terraform requires reinitialization to adopt changed backend settings before normal operations continue.
- Initialization installs required providers and modules and establishes the working directory's backend configuration.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to respond to a modified terraform backend block, 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 respond to a modified terraform backend block.
Incorrect Answers
A:The description applies to terraform init -reconfigure when an engineer needs to discard the previously cached backend connection without copying existing state; the named re-run init after a backend change instead handles the requirement to respond to a modified terraform backend block, so this behavior does not describe Re-run init after a backend change in the situation named.
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 re-run init after a backend change instead handles the requirement to respond to a modified terraform backend block, so this behavior does not describe Re-run init after a backend change in the situation named.
D:The description applies to terraform init for a new directory when an engineer needs to prepare a folder containing fresh .tf configuration files; the named re-run init after a backend change instead handles the requirement to respond to a modified terraform backend block, so this behavior does not describe Re-run init after a backend change in the situation named.
Question 1002
A team compares Terraform mechanisms for the goal to confirm deployed outputs and state match the expected result. Which stated consequence belongs specifically to “Check infrastructure after apply”?
- Running terraform init configures backend access, child modules and required providers before plans can run.
- The plan stage compares desired configuration with observed resource state and shows the proposed operations for review.
- Following apply, output values and state inspection can reveal created identifiers while a new plan can test for remaining drift.
- Teams can make planning a review step and reserve apply execution for an authorized operator or HCP Terraform run.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to confirm deployed outputs and state match the expected result, so it produces the behavior described. In contrast, review a plan before apply serves a different goal: inspect predicted create, update and delete actions prior to making changes, not confirm deployed outputs and state match the expected result.
Incorrect Answers
A:The description applies to initialize after checkout when an engineer needs to prepare a newly cloned root module for local Terraform operations; the named check infrastructure after apply instead handles the requirement to confirm deployed outputs and state match the expected result, so this behavior does not describe Check infrastructure after apply in the situation named.
B:The description applies to review a plan before apply when an engineer needs to inspect predicted create, update and delete actions prior to making changes; the named check infrastructure after apply instead handles the requirement to confirm deployed outputs and state match the expected result, so this behavior does not describe Check infrastructure after apply in the situation named.
D:The description applies to separate plan and apply privileges when an engineer needs to require approval before an infrastructure change executes; the named check infrastructure after apply instead handles the requirement to confirm deployed outputs and state match the expected result, so this behavior does not describe Check infrastructure after apply in the situation named.
Question 1003
A build job for a Terraform configuration requires a way to make Terraform execute the planned operations against managed infrastructure. Which Terraform approach most directly fulfills that request?
- terraform apply
- Apply with a .tfvars file
- terraform apply -auto-approve
- Post-apply outputs
- Apply failure recovery
Explanation
Correct Answer
A:Applying a configuration obtains a plan, requests approval when appropriate and invokes provider operations to change objects and state; this directly meets the requirement to make Terraform execute the planned operations against managed infrastructure. By comparison, post-apply outputs is intended to retrieve computed identifiers that can be used by deployment automation, which is a different task from make Terraform execute the planned operations against managed infrastructure.
Incorrect Answers
B:The -var-file option loads values from an input variables file, enabling separate environment assignments; this mechanism is useful when the job is to supply a named collection of input assignments to Terraform, whereas the current scenario requires the engineer to make Terraform execute the planned operations against managed infrastructure. These operations have different effects in the stated Terraform workflow.
C:The auto-approve option allows the automatically created plan to proceed without interactive confirmation, so pipeline safeguards matter; this mechanism is useful when the job is to suppress Terraform's normal approval prompt in a controlled pipeline, whereas the current scenario requires the engineer to make Terraform execute the planned operations against managed infrastructure. These operations have different effects in the stated Terraform workflow.
D:Root output blocks expose values Terraform calculates from the applied resource graph; output display is not an access-control boundary; this mechanism is useful when the job is to retrieve computed identifiers that can be used by deployment automation, whereas the current scenario requires the engineer to make Terraform execute the planned operations against managed infrastructure. These operations have different effects in the stated Terraform workflow.
E: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 make Terraform execute the planned operations against managed infrastructure. These operations have different effects in the stated Terraform workflow.
Question 1004
A Terraform operations troubleshooting session requires a way to list the workspaces available through the initialized backend. Which Terraform approach most directly fulfills that request?
- terraform show -json
- terraform workspace list
- terraform providers
- terraform state show ADDRESS
Explanation
Correct Answer
B:Workspace list shows logical Terraform workspaces, which may correspond to separate state instances depending on backend support; this directly meets the requirement to list the workspaces available through the initialized backend. By comparison, terraform show -json is intended to read plan or state information in a structured representation, which is a different task from list the workspaces available through the initialized backend.
Incorrect Answers
A:The JSON representation supports automated inspection but must be protected because redacted display is not a security boundary; this mechanism is useful when the job is to read plan or state information in a structured representation, whereas the current scenario requires the engineer to list the workspaces available through the initialized backend. These operations have different effects in the stated Terraform workflow.
C:The providers command displays provider requirements and their module relationships for dependency troubleshooting; this mechanism is useful when the job is to inspect which providers the current configuration requires, whereas the current scenario requires the engineer to list the workspaces available through the initialized backend. These operations have different effects in the stated Terraform workflow.
D:State show presents one resource's stored attributes in human-readable form and may reveal secret values; this mechanism is useful when the job is to view attributes for a specified state-tracked resource instance, whereas the current scenario requires the engineer to list the workspaces available through the initialized backend. These operations have different effects in the stated Terraform workflow.
Question 1005
An engineer intends to obtain module code from a repository that requires SSH-based access and is reviewing “A Git SSH module source”. What consequence follows from using it as intended?
- HCP Terraform's private registry can distribute approved modules with access control and supported version metadata.
- Terraform can load a module from a local filesystem path, though absolute paths make configurations less portable.
- A git::ssh:// module source delegates repository authentication to Git and SSH rather than a Terraform registry token.
- Registry module sources use the namespace/name/provider address form and can support a separate version argument.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to obtain module code from a repository that requires SSH-based access, so it produces the behavior described. In contrast, a private registry module source serves a different goal: reuse an internally published module available to authorized organization members, not obtain module code from a repository that requires SSH-based access.
Incorrect Answers
A:The description applies to a private registry module source when an engineer needs to reuse an internally published module available to authorized organization members; the named a Git SSH module source instead handles the requirement to obtain module code from a repository that requires SSH-based access, so this behavior does not describe A Git SSH module source in the situation named.
B:The description applies to an absolute local module source when an engineer needs to call a child module from an explicit filesystem path; the named a Git SSH module source instead handles the requirement to obtain module code from a repository that requires SSH-based access, so this behavior does not describe A Git SSH module source in the situation named.
D:The description applies to a public registry module source when an engineer needs to download a community module published with an official registry address; the named a Git SSH module source instead handles the requirement to obtain module code from a repository that requires SSH-based access, so this behavior does not describe A Git SSH module source in the situation named.
Question 1006
A team proposes “Backend state key separation” to avoid embedding cloud backend access keys into tracked Terraform source. If they proceed with that technique, which result should they anticipate instead?
- Using distinct backend keys or workspaces creates separate state namespaces instead of letting unrelated root configurations share one snapshot.
- Supported backends can discover authentication from environment settings or identity mechanisms rather than inline key literals.
- Backend configuration is processed at initialization, before ordinary input expressions are evaluated, so it cannot use regular variables or locals.
- The reconfigure flag discards cached previous backend settings and does not copy the prior state snapshot.
Explanation
Correct Answer
A:Backend state key separation is used when an operator needs to store different applications' state snapshots at distinct object paths. Consequently, this choice cannot meet the separate requirement to avoid embedding cloud backend access keys into tracked Terraform source. The intended action would instead require Backend credentials from the environment.
Incorrect Answers
B:That outcome belongs to Backend credentials from the environment, the mechanism that can avoid embedding cloud backend access keys into tracked Terraform source. The question concerns the engineer’s actual proposal, Backend state key separation; it is directed at store different applications' state snapshots at distinct object paths, not that result.
C:This behavior belongs to No input variable interpolation in a backend block, which helps engineers avoid expecting var.region or local.name to populate backend settings rather than satisfying the separate requirement to avoid embedding cloud backend access keys into tracked Terraform source. The attempted technique was Backend state key separation; it would instead be used to store different applications' state snapshots at distinct object paths, not to produce the effect associated with No input variable interpolation in a backend block.
D:This behavior belongs to terraform init -reconfigure, which helps engineers switch backend settings without performing automatic state migration rather than satisfying the separate requirement to avoid embedding cloud backend access keys into tracked Terraform source. The attempted technique was Backend state key separation; it would instead be used to store different applications' state snapshots at distinct object paths, not to produce the effect associated with terraform init -reconfigure.
Question 1007
A team compares Terraform mechanisms for the goal to avoid permanent trace logs in normal automated runs. Which stated consequence belongs specifically to “Verbose logging only during diagnosis”?
- INFO logging provides operational context with less detail than DEBUG and TRACE.
- High verbosity creates large logs and greater secret-exposure risk; enable it for a specific incident and disable it afterward.
- The TF_LOG_PROVIDER setting controls provider log verbosity and can help locate failures involving provider communication.
- Terraform logging set to TRACE emits highly verbose diagnostic detail and may contain sensitive information.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to avoid permanent trace logs in normal automated runs, 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 avoid permanent trace logs in normal automated runs.
Incorrect Answers
A:The description applies to TF_LOG=INFO when an engineer needs to record higher-level operational messages during troubleshooting; the named verbose logging only during diagnosis instead handles the requirement to avoid permanent trace logs in normal automated runs, so this behavior does not describe Verbose logging only during diagnosis in the situation named.
C:The description applies to TF_LOG_PROVIDER when an engineer needs to isolate provider-related diagnostic output during API troubleshooting; the named verbose logging only during diagnosis instead handles the requirement to avoid permanent trace logs in normal automated runs, so this behavior does not describe Verbose logging only during diagnosis in the situation named.
D:The description applies to TF_LOG=TRACE when an engineer needs to obtain detailed Terraform core and provider diagnostic output while troubleshooting; the named verbose logging only during diagnosis instead handles the requirement to avoid permanent trace logs in normal automated runs, so this behavior does not describe Verbose logging only during diagnosis in the situation named.
Question 1008
A Terraform reviewer encounters “Review a plan before apply” while assessing how to inspect predicted create, update and delete actions prior to making changes. Which statement correctly describes its actual behavior?
- Committing root module files allows the team to relate plans and runs to a specific version of intended infrastructure.
- Running terraform init configures backend access, child modules and required providers before plans can run.
- The plan stage compares desired configuration with observed resource state and shows the proposed operations for review.
- A revised configuration must be planned again because a prior plan does not automatically incorporate later edits.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to inspect predicted create, update and delete actions prior to making changes, so it produces the behavior described. In contrast, initialize after checkout serves a different goal: prepare a newly cloned root module for local Terraform operations, not inspect predicted create, update and delete actions prior to making changes.
Incorrect Answers
A:The description applies to keep configuration in version control when an engineer needs to tie an approved infrastructure change to a reviewed commit; the named review a plan before apply instead handles the requirement to inspect predicted create, update and delete actions prior to making changes, so this behavior does not describe Review a plan before apply in the situation named.
B:The description applies to initialize after checkout when an engineer needs to prepare a newly cloned root module for local Terraform operations; the named review a plan before apply instead handles the requirement to inspect predicted create, update and delete actions prior to making changes, so this behavior does not describe Review a plan before apply in the situation named.
D:The description applies to iterate after feedback when an engineer needs to modify and re-plan after a change request is rejected; the named review a plan before apply instead handles the requirement to inspect predicted create, update and delete actions prior to making changes, so this behavior does not describe Review a plan before apply in the situation named.
Question 1009
A Terraform reviewer encounters “Validate without live deployment” while assessing how to detect invalid configuration even when no cloud changes should occur. Which statement correctly describes its actual behavior?
- The fmt -check option exits with a failure status when source files would need formatting changes rather than altering them.
- Variable validation conditions evaluate against actual values when Terraform processes inputs, which is different from only checking syntax.
- terraform validate runs offline-oriented configuration checks and does not deploy managed resources.
- Because validate consults provider and module definitions, run init first to install referenced dependencies.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to detect invalid configuration even when no cloud changes should occur, so it produces the behavior described. In contrast, variable validation during planning serves a different goal: reject a supplied input value that violates a custom validation rule, not detect invalid configuration even when no cloud changes should occur.
Incorrect Answers
A:The description applies to terraform fmt -check when an engineer needs to verify formatting without rewriting the files in a CI job; the named validate without live deployment instead handles the requirement to detect invalid configuration even when no cloud changes should occur, so this behavior does not describe Validate without live deployment in the situation named.
B:The description applies to variable validation during planning when an engineer needs to reject a supplied input value that violates a custom validation rule; the named validate without live deployment instead handles the requirement to detect invalid configuration even when no cloud changes should occur, so this behavior does not describe Validate without live deployment in the situation named.
D:The description applies to validate after init when an engineer needs to resolve missing provider schemas before checking configuration; the named validate without live deployment instead handles the requirement to detect invalid configuration even when no cloud changes should occur, so this behavior does not describe Validate without live deployment in the situation named.
Question 1010
An engineer troubleshooting a .tf configuration needs to turn a compatible collection into a uniform-keyed map. Which feature or operation is the most direct match?
- tomap conversion
- The null value
- A conditional expression
- count with a number
Explanation
Correct Answer
A:tomap attempts to convert an input value into a map whose values share a compatible element type; this directly meets the requirement to turn a compatible collection into a uniform-keyed map. By comparison, count with a number is intended to create a specified number of similarly configured resource instances, which is a different task from turn a compatible collection into a uniform-keyed map.
Incorrect Answers
B:In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset; this mechanism is useful when the job is to represent the absence of an optional argument value, whereas the current scenario requires the engineer to turn a compatible collection into a uniform-keyed map. These operations have different effects in the stated Terraform workflow.
C:Terraform's condition ? true_value : false_value syntax chooses one branch while reconciling compatible result types; this mechanism is useful when the job is to select between two expression results based on a boolean predicate, whereas the current scenario requires the engineer to turn a compatible collection into a uniform-keyed map. These operations have different effects in the stated Terraform workflow.
D:The count meta-argument uses an integer expression and creates zero-based numeric instance addresses; this mechanism is useful when the job is to create a specified number of similarly configured resource instances, whereas the current scenario requires the engineer to turn a compatible collection into a uniform-keyed map. These operations have different effects in the stated Terraform workflow.