Question 210
An operations handover for an existing Terraform deployment has a concrete implementation goal: check that Terraform configuration is structurally valid without planning resource changes. What is the most appropriate Terraform mechanism?
- terraform validate
- A type mismatch diagnosis
- terraform fmt -check
- terraform test
Explanation
Correct Answer
A:The validate command checks syntax and schema consistency in an initialized configuration without obtaining a full execution plan; this directly meets the requirement to check that Terraform configuration is structurally valid without planning resource changes. By comparison, a type mismatch diagnosis is intended to catch an argument whose expression does not match the provider schema, which is a different task from check that Terraform configuration is structurally valid without planning resource changes.
Incorrect Answers
B:Provider schemas and Terraform's type checking can make validate fail before an apply is attempted; this mechanism is useful when the job is to catch an argument whose expression does not match the provider schema, whereas the current scenario requires the engineer to check that Terraform configuration is structurally valid without planning resource changes. These operations have different effects in the stated Terraform workflow.
C:The fmt -check option exits with a failure status when source files would need formatting changes rather than altering them; this mechanism is useful when the job is to verify formatting without rewriting the files in a CI job, whereas the current scenario requires the engineer to check that Terraform configuration is structurally valid without planning resource changes. These operations have different effects in the stated Terraform workflow.
D:The Terraform test command executes defined test runs and assertions, which can exercise behavior beyond basic configuration validation; this mechanism is useful when the job is to run declarative module tests instead of only checking syntax, whereas the current scenario requires the engineer to check that Terraform configuration is structurally valid without planning resource changes. These operations have different effects in the stated Terraform workflow.
Question 211
A Terraform reviewer encounters “HCP Terraform run tasks” while assessing how to integrate external checks into a run before applying infrastructure changes. Which statement correctly describes its actual behavior?
- Run history records plan and apply activity to support team review and change tracking.
- HCP Terraform supports OPA-based policy sets for automated governance on applicable runs.
- Run tasks send run context to integrated systems and can participate in checks or approval workflows, depending on configuration.
- Sentinel policies can assess planned infrastructure and produce policy check outcomes before a run can apply when enforcement requires it.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to integrate external checks into a run before applying infrastructure changes, so it produces the behavior described. In contrast, sentinel policy enforcement serves a different goal: evaluate organizational infrastructure rules during HCP Terraform runs, not integrate external checks into a run before applying infrastructure changes.
Incorrect Answers
A:The description applies to workspace audit history when an engineer needs to review past runs and changes in a shared HCP organization; the named HCP Terraform run tasks instead handles the requirement to integrate external checks into a run before applying infrastructure changes, so this behavior does not describe HCP Terraform run tasks in the situation named.
B:The description applies to oPA policy enforcement when an engineer needs to check proposed infrastructure against rules expressed in Open Policy Agent policies; the named HCP Terraform run tasks instead handles the requirement to integrate external checks into a run before applying infrastructure changes, so this behavior does not describe HCP Terraform run tasks in the situation named.
D:The description applies to sentinel policy enforcement when an engineer needs to evaluate organizational infrastructure rules during HCP Terraform runs; the named HCP Terraform run tasks instead handles the requirement to integrate external checks into a run before applying infrastructure changes, so this behavior does not describe HCP Terraform run tasks in the situation named.
Question 212
A configuration review for an application stack has a concrete implementation goal: generate repeated nested blocks from a collection. What is the most appropriate Terraform mechanism?
- The dynamic block
- The templatefile function
- The lower function
- The jsondecode function
Explanation
Correct Answer
A:dynamic constructs blocks required by resource schemas; it does not create standalone Terraform resource declarations; this directly meets the requirement to generate repeated nested blocks from a collection. By comparison, the templatefile function is intended to render a file containing template expressions with an object of variables, which is a different task from generate repeated nested blocks from a collection.
Incorrect Answers
B:templatefile reads a template and evaluates placeholders using the supplied variable map; this mechanism is useful when the job is to render a file containing template expressions with an object of variables, whereas the current scenario requires the engineer to generate repeated nested blocks from a collection. 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 generate repeated nested blocks from a collection. These operations have different effects in the stated Terraform workflow.
D:jsondecode converts JSON input into native maps, objects, lists or primitives used in expressions; this mechanism is useful when the job is to parse a JSON document string into Terraform values, whereas the current scenario requires the engineer to generate repeated nested blocks from a collection. These operations have different effects in the stated Terraform workflow.
Question 213
A Terraform reviewer encounters “A data attribute reference” while assessing how to read a field from a configured data source in another expression. Which statement correctly describes its actual behavior?
- The syntax data.TYPE.NAME.ATTRIBUTE accesses attributes returned by an existing-object query.
- Count instances have numeric indexes such as aws_instance.web[1] for the second instance.
- Terraform cannot order a cycle of dependencies; restructure references or resource design to remove the circular edge.
- Instances made from a map or string set have addresses such as aws_instance.web["blue"], rather than an integer count index.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to read a field from a configured data source in another expression, so it produces the behavior described. In contrast, an instance address with count serves a different goal: refer specifically to the second object of a count-created resource, not read a field from a configured data source in another expression.
Incorrect Answers
B:The description applies to an instance address with count when an engineer needs to refer specifically to the second object of a count-created resource; the named a data attribute reference instead handles the requirement to read a field from a configured data source in another expression, so this behavior does not describe A data attribute reference in the situation named.
C:The description applies to avoiding dependency cycles when an engineer needs to resolve a graph where two resources each depend on the other; the named a data attribute reference instead handles the requirement to read a field from a configured data source in another expression, so this behavior does not describe A data attribute reference in the situation named.
D:The description applies to a for_each instance address when an engineer needs to identify a single managed object selected by a string key; the named a data attribute reference instead handles the requirement to read a field from a configured data source in another expression, so this behavior does not describe A data attribute reference in the situation named.
Question 214
A Terraform change proposal names “terraform state show ADDRESS” to view attributes for a specified state-tracked resource instance. Which outcome can reviewers attribute to that particular mechanism?
- State show presents one resource's stored attributes in human-readable form and may reveal secret values.
- The providers command displays provider requirements and their module relationships for dependency troubleshooting.
- The JSON representation supports automated inspection but must be protected because redacted display is not a security boundary.
- Workspace selection changes which workspace state namespace the root configuration uses; it does not select a cloud account automatically.
- State rm deletes the state association, not the object in the external system.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to view attributes for a specified state-tracked resource instance, so it produces the behavior described. In contrast, terraform state rm serves a different goal: stop tracking a resource without telling its provider to delete the remote object, not view attributes for a specified state-tracked resource instance.
Incorrect Answers
B:The description applies to terraform providers when an engineer needs to inspect which providers the current configuration requires; the named terraform state show ADDRESS instead handles the requirement to view attributes for a specified state-tracked resource instance, so this behavior does not describe terraform state show ADDRESS in the situation named.
C:The description applies to terraform show -json when an engineer needs to read plan or state information in a structured representation; the named terraform state show ADDRESS instead handles the requirement to view attributes for a specified state-tracked resource instance, so this behavior does not describe terraform state show ADDRESS in the situation named.
D:The description applies to terraform workspace select when an engineer needs to switch the currently selected Terraform CLI workspace; the named terraform state show ADDRESS instead handles the requirement to view attributes for a specified state-tracked resource instance, so this behavior does not describe terraform state show ADDRESS in the situation named.
E:The description applies to terraform state rm when an engineer needs to stop tracking a resource without telling its provider to delete the remote object; the named terraform state show ADDRESS instead handles the requirement to view attributes for a specified state-tracked resource instance, so this behavior does not describe terraform state show ADDRESS in the situation named.
Question 215
A Terraform reviewer encounters “State resource addresses” while assessing how to identify which remote object corresponds to a particular configuration resource. Which statement correctly describes its actual behavior?
- State maps Terraform instance addresses to remote object identifiers and remembered attributes for subsequent comparisons.
- A normal plan attempts to refresh state from providers before comparing objects to the current configuration.
- A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes.
- The state snapshot records managed instance data and metadata needed to plan future actions.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to identify which remote object corresponds to a particular configuration resource, so it produces the behavior described. In contrast, Terraform refresh during planning serves a different goal: detect actual resource attributes rather than relying only on historical saved values, not identify which remote object corresponds to a particular configuration resource.
Incorrect Answers
B:The description applies to Terraform refresh during planning when an engineer needs to detect actual resource attributes rather than relying only on historical saved values; the named state resource addresses instead handles the requirement to identify which remote object corresponds to a particular configuration resource, so this behavior does not describe State resource addresses in the situation named.
C:The description applies to state locking when an engineer needs to prevent concurrent state writers from overwriting each other's updates; the named state resource addresses instead handles the requirement to identify which remote object corresponds to a particular configuration resource, so this behavior does not describe State resource addresses in the situation named.
D:The description applies to state snapshots when an engineer needs to preserve Terraform's knowledge of managed infrastructure between CLI runs; the named state resource addresses instead handles the requirement to identify which remote object corresponds to a particular configuration resource, so this behavior does not describe State resource addresses in the situation named.
Question 216
A Terraform runbook prescribes “State snapshots” to inspect the addresses of instances currently tracked in state, but it does not meet the requirement. What does that step actually accomplish?
- The state snapshot records managed instance data and metadata needed to plan future actions.
- Distinct backends, workspaces or root configurations can isolate state, but the configuration must target the intended instance set.
- A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes.
- The state list command enumerates Terraform resource addresses without creating or deleting infrastructure.
Explanation
Correct Answer
A:State snapshots is used when an operator needs to preserve Terraform's knowledge of managed infrastructure between CLI runs. Consequently, this choice cannot meet the separate requirement to inspect the addresses of instances currently tracked in state. The intended action would instead require terraform state list.
Incorrect Answers
B:This behavior belongs to Separate state per environment, which helps engineers prevent staging changes from unintentionally sharing the production state mapping rather than satisfying the separate requirement to inspect the addresses of instances currently tracked in state. The attempted technique was State snapshots; it would instead be used to preserve Terraform's knowledge of managed infrastructure between CLI runs, not to produce the effect associated with Separate state per environment.
C:This behavior belongs to State locking, which helps engineers prevent concurrent state writers from overwriting each other's updates rather than satisfying the separate requirement to inspect the addresses of instances currently tracked in state. The attempted technique was State snapshots; it would instead be used to preserve Terraform's knowledge of managed infrastructure between CLI runs, not to produce the effect associated with State locking.
D:That outcome belongs to terraform state list, the mechanism that can inspect the addresses of instances currently tracked in state. The question concerns the engineer’s actual proposal, State snapshots; it is directed at preserve Terraform's knowledge of managed infrastructure between CLI runs, not that result.
Question 217
During one infrastructure delivery, the team must satisfy all of the following: (1) respond to a modified terraform backend block; (2) detect invalid configuration even when no cloud changes should occur. Select TWO appropriate Terraform approaches. Choose TWO.
- terraform init -upgrade for modules
- Validate after init
- Re-run init after a backend change
- Provider source change reinitialization
- Validate without live deployment
- The .terraform directory
Explanation
Correct Answers
C:Terraform requires reinitialization to adopt changed backend settings before normal operations continue; this meets the requirement to respond to a modified terraform backend block, while the other selected techniques address detect invalid configuration even when no cloud changes should occur, which require their own distinct Terraform mechanisms.
E:terraform validate runs offline-oriented configuration checks and does not deploy managed resources; this meets the requirement to detect invalid configuration even when no cloud changes should occur, while the other selected techniques address respond to a modified terraform backend block, which require their own distinct Terraform mechanisms.
Incorrect Answers
A:Upgrade tells init to reconsider prior module selections instead of simply reusing previously installed versions; it addresses fetch newer module releases permitted by version constraints, but this delivery instead requires respond to a modified terraform backend block and detect invalid configuration even when no cloud changes should occur. The required combination involves Re-run init after a backend change and Validate without live deployment, not the behavior of terraform init -upgrade for modules.
B:Because validate consults provider and module definitions, run init first to install referenced dependencies; it addresses resolve missing provider schemas before checking configuration, but this delivery instead requires respond to a modified terraform backend block and detect invalid configuration even when no cloud changes should occur. The required combination involves Re-run init after a backend change and Validate without live deployment, not the behavior of Validate after init.
D:A modified provider requirement can trigger a need to rerun init to resolve the newly declared plugin dependency; it addresses respond after changing the source address of a required provider, but this delivery instead requires respond to a modified terraform backend block and detect invalid configuration even when no cloud changes should occur. The required combination involves Re-run init after a backend change and Validate without live deployment, not the behavior of Provider source change reinitialization.
F:Terraform creates .terraform for module caches, provider installations and backend/workspace metadata; it is not a substitute for committed configuration; it addresses identify where a working directory keeps installed modules and initialization metadata, but this delivery instead requires respond to a modified terraform backend block and detect invalid configuration even when no cloud changes should occur. The required combination involves Re-run init after a backend change and Validate without live deployment, not the behavior of The .terraform directory.
Question 218
During one infrastructure delivery, the team must satisfy all of the following: (1) read command-line and tfvars input values for the root module; (2) consider newer published module releases already allowed by a version constraint. Select TWO appropriate Terraform approaches. Choose TWO.
- Init -upgrade for registry modules
- A local value confined to its module
- A Git tag pin for a module
- Child module outputs and sensitivity
- Root input variable scope
Explanation
Correct Answers
A:The upgrade mode reselects module versions subject to constraints instead of automatically keeping the previously installed copy; this meets the requirement to consider newer published module releases already allowed by a version constraint, while the other selected techniques address read command-line and tfvars input values for the root module, which require their own distinct Terraform mechanisms.
E:Root variables accept runtime assignments, whereas a child module normally receives its inputs through the parent's module call; this meets the requirement to read command-line and tfvars input values for the root module, while the other selected techniques address consider newer published module releases already allowed by a version constraint, which require their own distinct Terraform mechanisms.
Incorrect Answers
B:Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value; it addresses avoid assuming a local calculation is automatically visible in a parent module, but this delivery instead requires read command-line and tfvars input values for the root module and consider newer published module releases already allowed by a version constraint. The required combination involves Root input variable scope and Init -upgrade for registry modules, not the behavior of A local value confined to its module.
C:A Git module's ?ref= tag or commit selects a repository revision instead of a registry module version constraint; it addresses select a specific VCS module release without using a registry version argument, but this delivery instead requires read command-line and tfvars input values for the root module and consider newer published module releases already allowed by a version constraint. The required combination involves Root input variable scope and Init -upgrade for registry modules, not the behavior of A Git tag pin for a module.
D:A child output can be marked sensitive, but its underlying value may still reside in state unless it uses permitted ephemeral handling; it addresses limit ordinary display of a sensitive result exported from a reusable module, but this delivery instead requires read command-line and tfvars input values for the root module and consider newer published module releases already allowed by a version constraint. The required combination involves Root input variable scope and Init -upgrade for registry modules, not the behavior of Child module outputs and sensitivity.
Question 219
A provider configuration review requires a way to reproduce previously selected provider package versions on other machines. Which Terraform approach most directly fulfills that request?
- A major-series compatible constraint
- Lockfile source control
- A provider source address
- The dependency lock file
- A compatible provider constraint
- A provider mirror
Explanation
Correct Answer
D:The .terraform.lock.hcl file records selected provider versions and checksums to constrain subsequent installations; this directly meets the requirement to reproduce previously selected provider package versions on other machines. By comparison, a compatible provider constraint is intended to accept patch updates within a chosen minor line, which is a different task from reproduce previously selected provider package versions on other machines.
Incorrect Answers
A:The pessimistic constraint ~> 5.3 permits version 5.3 and later releases below 6.0.0; this mechanism is useful when the job is to accept minor and patch updates without crossing the next major version, whereas the current scenario requires the engineer to reproduce previously selected provider package versions on other machines. These operations have different effects in the stated Terraform workflow.
B:Checking .terraform.lock.hcl into version control preserves provider version selections and integrity hashes across workstations; this mechanism is useful when the job is to share repeatable plugin selections with a development team, whereas the current scenario requires the engineer to reproduce previously selected provider package versions on other machines. These operations have different effects in the stated Terraform workflow.
C:The source address identifies a provider by registry hostname, namespace and type; local names alone are insufficient to distinguish publishers; this mechanism is useful when the job is to distinguish a community plugin from the HashiCorp-maintained plugin with the same local name, whereas the current scenario requires the engineer to reproduce previously selected provider package versions on other machines. These operations have different effects in the stated Terraform workflow.
E:The pessimistic constraint ~> 5.3.0 admits versions at least 5.3.0 but below 5.4.0; this mechanism is useful when the job is to accept patch updates within a chosen minor line, whereas the current scenario requires the engineer to reproduce previously selected provider package versions on other machines. These operations have different effects in the stated Terraform workflow.
F:A CLI provider_installation configuration can direct provider package discovery to a network or filesystem mirror; this mechanism is useful when the job is to install approved plugins from an internal distribution location, whereas the current scenario requires the engineer to reproduce previously selected provider package versions on other machines. These operations have different effects in the stated Terraform workflow.
Question 220
The team evaluates “Drift detection during planning” for a requirement to notice remote infrastructure changes made outside Terraform. Which observed behavior belongs to that mechanism rather than a different Terraform feature?
- 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 policy or governance stage can inspect proposed infrastructure changes before allowing an apply to proceed.
- Terraform infers many dependencies from references and applies graph ordering to create or modify related resources safely.
- Version control and run history provide traceable context for what configuration changed and what Terraform planned or applied.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to notice remote infrastructure changes made outside Terraform, so it produces the behavior described. In contrast, policy checks before provisioning serves a different goal: enforce organizational infrastructure constraints consistently, not notice remote infrastructure changes made outside Terraform.
Incorrect Answers
B:The description applies to idempotent convergence when an engineer needs to run unchanged configuration repeatedly without inventing new infrastructure updates; the named drift detection during planning instead handles the requirement to notice remote infrastructure changes made outside Terraform, so this behavior does not describe Drift detection during planning in the situation named.
C:The description applies to policy checks before provisioning when an engineer needs to enforce organizational infrastructure constraints consistently; the named drift detection during planning instead handles the requirement to notice remote infrastructure changes made outside Terraform, so this behavior does not describe Drift detection during planning in the situation named.
D:The description applies to consistent dependency management when an engineer needs to avoid hand-sequencing every resource operation; the named drift detection during planning instead handles the requirement to notice remote infrastructure changes made outside Terraform, so this behavior does not describe Drift detection during planning in the situation named.
E:The description applies to reusable execution records when an engineer needs to audit the results of infrastructure changes across a team; the named drift detection during planning instead handles the requirement to notice remote infrastructure changes made outside Terraform, so this behavior does not describe Drift detection during planning in the situation named.