Question 890
A team compares Terraform mechanisms for the goal to reject an input value that violates an explicit business rule. Which stated consequence belongs specifically to “A variable validation block”?
- Validation uses a condition expression and error_message to provide a tailored error when the supplied input is unacceptable.
- Command-line -var assignments take high precedence and are useful for an explicit run-specific override.
- Marking an output sensitive redacts ordinary CLI presentation, but does not by itself prevent storage in state.
- Terraform automatically discovers terraform.tfvars and terraform.tfvars.json in the working directory.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to reject an input value that violates an explicit business rule, so it produces the behavior described. In contrast, the -var option serves a different goal: supply a single variable assignment when invoking plan or apply, not reject an input value that violates an explicit business rule.
Incorrect Answers
B:The description applies to the -var option when an engineer needs to supply a single variable assignment when invoking plan or apply; the named a variable validation block instead handles the requirement to reject an input value that violates an explicit business rule, so this behavior does not describe A variable validation block in the situation named.
C:The description applies to a sensitive output when an engineer needs to hide a secret-like output from Terraform's usual human-readable display; the named a variable validation block instead handles the requirement to reject an input value that violates an explicit business rule, so this behavior does not describe A variable validation block in the situation named.
D:The description applies to a terraform.tfvars file when an engineer needs to load a conventional set of root-module variable assignments automatically; the named a variable validation block instead handles the requirement to reject an input value that violates an explicit business rule, so this behavior does not describe A variable validation block in the situation named.
Question 891
A platform team separating infrastructure deployments needs to configure the local working directory to connect with the selected HCP workspace. Which feature or operation is the most direct match?
- HCP Terraform VCS integration
- An API token for CLI connectivity
- HCP Terraform run tasks integration
- terraform login
- terraform init after adding cloud integration
Explanation
Correct Answer
E:Running init processes the cloud block and configures workspace connectivity before plans or applies; this directly meets the requirement to configure the local working directory to connect with the selected HCP workspace. By comparison, terraform login is intended to authenticate the local Terraform CLI to an HCP Terraform or Terraform Enterprise hostname, which is a different task from configure the local working directory to connect with the selected HCP workspace.
Incorrect Answers
A:A VCS-connected workspace coordinates code changes, speculative plans and controlled applies through supported repository integration; this mechanism is useful when the job is to connect reviewed repository commits to automated infrastructure plans, whereas the current scenario requires the engineer to configure the local working directory to connect with the selected HCP workspace. These operations have different effects in the stated Terraform workflow.
B:The HCP service token controls platform API authentication and is distinct from provider credentials used to modify cloud infrastructure; this mechanism is useful when the job is to authorize a Terraform CLI workflow to access an HCP Terraform organization, whereas the current scenario requires the engineer to configure the local working directory to connect with the selected HCP workspace. These operations have different effects in the stated Terraform workflow.
C:Run tasks integrate external systems into workflow checkpoints without changing the Terraform resource graph directly; this mechanism is useful when the job is to send proposed changes to a third-party quality or security check service, whereas the current scenario requires the engineer to configure the local working directory to connect with the selected HCP workspace. These operations have different effects in the stated Terraform workflow.
D:The login command stores a CLI API token for the selected service host so CLI-driven workflows can authenticate; this mechanism is useful when the job is to authenticate the local Terraform CLI to an HCP Terraform or Terraform Enterprise hostname, whereas the current scenario requires the engineer to configure the local working directory to connect with the selected HCP workspace. These operations have different effects in the stated Terraform workflow.
Question 892
A team compares Terraform mechanisms for the goal to recognize a destroy-and-create operation for an immutable argument. Which stated consequence belongs specifically to “A replacement action in the plan”?
- The -json flag emits a structured JSON representation suitable for inspection by automation, with careful handling of sensitive output.
- Plans show replacement when the provider cannot update a changed property in place; create-before-destroy can change the replacement order.
- Terraform graph nodes can run concurrently when no dependency edge requires a particular order.
- Disabling refresh reduces remote reads but can hide drift and produce an inaccurate plan based on stale observations.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to recognize a destroy-and-create operation for an immutable argument, so it produces the behavior described. In contrast, terraform show -json on a plan serves a different goal: feed a saved plan to a machine-readable analysis tool, not recognize a destroy-and-create operation for an immutable argument.
Incorrect Answers
A:The description applies to terraform show -json on a plan when an engineer needs to feed a saved plan to a machine-readable analysis tool; the named a replacement action in the plan instead handles the requirement to recognize a destroy-and-create operation for an immutable argument, so this behavior does not describe A replacement action in the plan in the situation named.
C:The description applies to the dependency graph during planning when an engineer needs to explain why two unrelated resources can be planned and applied in parallel; the named a replacement action in the plan instead handles the requirement to recognize a destroy-and-create operation for an immutable argument, so this behavior does not describe A replacement action in the plan in the situation named.
D:The description applies to terraform plan -refresh=false when an engineer needs to skip routine state refresh for a constrained preview; the named a replacement action in the plan instead handles the requirement to recognize a destroy-and-create operation for an immutable argument, so this behavior does not describe A replacement action in the plan in the situation named.
Question 893
During an infrastructure design review about how to correct a pair of modules that each require the other's output to initialize, a maintainer asks what “Dependency cycle resolution” does. Which description is accurate?
- A terraform_data resource can expose input-related lifecycle actions for replace_triggered_by, which expects managed resource changes.
- A module block can declare depends_on so all managed objects inside it observe the specified dependency relationship.
- The depends_on edge can relate the whole counted resource block to an upstream resource, rather than computing one edge by list position.
- With all attributes ignored during updates, Terraform can still create and destroy the resource but does not reconcile field-level changes.
- Dependency cycles cannot be topologically ordered and require restructuring the relationships or splitting responsibilities.
Explanation
Correct Answer
E:The named mechanism is used when the objective is to correct a pair of modules that each require the other's output to initialize, so it produces the behavior described. In contrast, count and depends_on together serves a different goal: make multiple resource instances wait for a shared prerequisite, not correct a pair of modules that each require the other's output to initialize.
Incorrect Answers
A:The description applies to terraform_data as a replacement trigger when an engineer needs to trigger replacement from a plain variable value change; the named dependency cycle resolution instead handles the requirement to correct a pair of modules that each require the other's output to initialize, so this behavior does not describe Dependency cycle resolution in the situation named.
B:The description applies to depends_on for module calls when an engineer needs to wait for prerequisite objects before considering resources in another module; the named dependency cycle resolution instead handles the requirement to correct a pair of modules that each require the other's output to initialize, so this behavior does not describe Dependency cycle resolution in the situation named.
C:The description applies to count and depends_on together when an engineer needs to make multiple resource instances wait for a shared prerequisite; the named dependency cycle resolution instead handles the requirement to correct a pair of modules that each require the other's output to initialize, so this behavior does not describe Dependency cycle resolution in the situation named.
D:The description applies to ignore_changes = all when an engineer needs to disable updates to all managed resource attributes after creation; the named dependency cycle resolution instead handles the requirement to correct a pair of modules that each require the other's output to initialize, so this behavior does not describe Dependency cycle resolution in the situation named.
Question 894
A reusable infrastructure definition has a concrete implementation goal: repair an isolated broken dependency while acknowledging incomplete plan coverage. What is the most appropriate Terraform mechanism?
- replace_triggered_by
- count and depends_on together
- Explicit depends_on for side effects
- Resource targeting as an exception
Explanation
Correct Answer
D:The -target option narrows an operation to selected objects and prerequisites; routine selective deployment is not its intended model; this directly meets the requirement to repair an isolated broken dependency while acknowledging incomplete plan coverage. By comparison, count and depends_on together is intended to make multiple resource instances wait for a shared prerequisite, which is a different task from repair an isolated broken dependency while acknowledging incomplete plan coverage.
Incorrect Answers
A:This lifecycle rule uses planned resource actions as triggers for replacement and is not a general-purpose dependency selector; this mechanism is useful when the job is to replace one managed resource when another managed resource's attribute changes, whereas the current scenario requires the engineer to repair an isolated broken dependency while acknowledging incomplete plan coverage. These operations have different effects in the stated Terraform workflow.
B:The depends_on edge can relate the whole counted resource block to an upstream resource, rather than computing one edge by list position; this mechanism is useful when the job is to make multiple resource instances wait for a shared prerequisite, whereas the current scenario requires the engineer to repair an isolated broken dependency while acknowledging incomplete plan coverage. These operations have different effects in the stated Terraform workflow.
C:The depends_on meta-argument is suitable when a real dependency exists but no normal expression reference conveys it; this mechanism is useful when the job is to order a resource after a prerequisite that has no referenced attribute, whereas the current scenario requires the engineer to repair an isolated broken dependency while acknowledging incomplete plan coverage. These operations have different effects in the stated Terraform workflow.
Question 895
An engineer intends to represent the absence of an optional argument value and is reviewing “The null value”. What consequence follows from using it as intended?
- The bool primitive type represents logical truth values used in conditionals and comparisons.
- Terraform's condition ? true_value : false_value syntax chooses one branch while reconciling compatible result types.
- In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset.
- tuple([string, number]) enforces a position-specific sequence with different type constraints.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to represent the absence of an optional argument value, so it produces the behavior described. In contrast, a bool variable type serves a different goal: limit a feature toggle to true or false values, not represent the absence of an optional argument value.
Incorrect Answers
A:The description applies to a bool variable type when an engineer needs to limit a feature toggle to true or false values; the named the null value instead handles the requirement to represent the absence of an optional argument value, so this behavior does not describe The null value in the situation named.
B:The description applies to a conditional expression when an engineer needs to select between two expression results based on a boolean predicate; the named the null value instead handles the requirement to represent the absence of an optional argument value, so this behavior does not describe The null value in the situation named.
D:The description applies to a tuple type when an engineer needs to require a fixed sequence of potentially different element types; the named the null value instead handles the requirement to represent the absence of an optional argument value, so this behavior does not describe The null value in the situation named.
Question 896
During one infrastructure delivery, the team must satisfy all of the following: (1) reject a supplied input value that violates a custom validation rule; (2) remove the managed infrastructure described by the current Terraform configuration. Select TWO appropriate Terraform approaches. Choose TWO.
- Variable validation during planning
- Validate without live deployment
- terraform destroy
- Resource-specific delete restrictions
- Remove from state without deletion
Explanation
Correct Answers
A:Variable validation conditions evaluate against actual values when Terraform processes inputs, which is different from only checking syntax; this meets the requirement to reject a supplied input value that violates a custom validation rule, while the other selected techniques address remove the managed infrastructure described by the current Terraform configuration, which require their own distinct Terraform mechanisms.
C:The destroy command plans and applies removal of managed objects subject to lifecycle and provider constraints; this meets the requirement to remove the managed infrastructure described by the current Terraform configuration, while the other selected techniques address reject a supplied input value that violates a custom validation rule, which require their own distinct Terraform mechanisms.
Incorrect Answers
B:terraform validate runs offline-oriented configuration checks and does not deploy managed resources; it addresses detect invalid configuration even when no cloud changes should occur, but this delivery instead requires reject a supplied input value that violates a custom validation rule and remove the managed infrastructure described by the current Terraform configuration. The required combination involves Variable validation during planning and terraform destroy, not the behavior of Validate without live deployment.
D:Providers and remote APIs can reject deletion when dependencies, protection flags or permissions prevent removing the object; it addresses diagnose why destroy fails despite valid Terraform syntax, but this delivery instead requires reject a supplied input value that violates a custom validation rule and remove the managed infrastructure described by the current Terraform configuration. The required combination involves Variable validation during planning and terraform destroy, not the behavior of Resource-specific delete restrictions.
E:Removing a state association, for example with terraform state rm, makes Terraform forget the object without asking the provider to delete it; it addresses stop managing an existing object while preserving the real remote infrastructure, but this delivery instead requires reject a supplied input value that violates a custom validation rule and remove the managed infrastructure described by the current Terraform configuration. The required combination involves Variable validation during planning and terraform destroy, not the behavior of Remove from state without deletion.
Question 897
A declarative resource and expression design needs to reject malformed module inputs before provisioning resources. Which feature or operation is the most direct match?
- Input variable validation
- terraform validate versus runtime assertions
- Custom conditions with unknown values
- Postconditions for exported IDs
Explanation
Correct Answer
A:The validation block uses a condition and a custom error_message to enforce rules on caller-supplied values; this directly meets the requirement to reject malformed module inputs before provisioning resources. By comparison, terraform validate versus runtime assertions is intended to distinguish static configuration checks from conditions requiring actual resource values, which is a different task from reject malformed module inputs before provisioning resources.
Incorrect Answers
B:Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply; this mechanism is useful when the job is to distinguish static configuration checks from conditions requiring actual resource values, whereas the current scenario requires the engineer to reject malformed module inputs before provisioning resources. These operations have different effects in the stated Terraform workflow.
C:Terraform may defer condition evaluation to apply when required expression values are unknown during planning; this mechanism is useful when the job is to understand when a validation cannot yet be decided at planning time, whereas the current scenario requires the engineer to reject malformed module inputs before provisioning resources. These operations have different effects in the stated Terraform workflow.
D:Postconditions validate resultant resource or data-source attributes and prevent dependents from relying on invalid results; this mechanism is useful when the job is to guard a dependent consumer against a provider result that violates an invariant, whereas the current scenario requires the engineer to reject malformed module inputs before provisioning resources. These operations have different effects in the stated Terraform workflow.
Question 898
A Terraform change proposal names “Local state in CI” to recognize why ephemeral build agents should not rely on a machine-local state file. Which outcome can reviewers attribute to that particular mechanism?
- A temporary runner may lose its filesystem after a job, so durable shared state is usually needed for repeatable team automation.
- The local backend supports a path argument for where the state file is stored on disk.
- Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination.
- When local workspaces are used, nondefault state snapshots are placed under a terraform.tfstate.d directory structure.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to recognize why ephemeral build agents should not rely on a machine-local state file, so it produces the behavior described. In contrast, state migration from local storage serves a different goal: move an established project to remote state without abandoning resource identity, not recognize why ephemeral build agents should not rely on a machine-local state file.
Incorrect Answers
B:The description applies to a local backend path setting when an engineer needs to save the default workspace state to a nondefault local filename; the named local state in CI instead handles the requirement to recognize why ephemeral build agents should not rely on a machine-local state file, so this behavior does not describe Local state in CI in the situation named.
C:The description applies to state migration from local storage when an engineer needs to move an established project to remote state without abandoning resource identity; the named local state in CI instead handles the requirement to recognize why ephemeral build agents should not rely on a machine-local state file, so this behavior does not describe Local state in CI in the situation named.
D:The description applies to local workspace state directories when an engineer needs to identify how the local backend stores nondefault workspaces; the named local state in CI instead handles the requirement to recognize why ephemeral build agents should not rely on a machine-local state file, so this behavior does not describe Local state in CI in the situation named.
Question 899
A team compares Terraform mechanisms for the goal to instantiate a reusable configuration unit under a distinct local name. Which stated consequence belongs specifically to “A module call block”?
- The module block's source points to child configuration and its other arguments supply input variables and relevant meta-arguments.
- depends_on on a module call affects all resources and data sources inside that module and can constrain concurrency.
- Parent configurations can pass one child module's outputs into another child's inputs to compose larger infrastructure systems.
- An output-to-input reference establishes a natural dependency and avoids imposing broad depends_on edges unnecessarily.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to instantiate a reusable configuration unit under a distinct local name, so it produces the behavior described. In contrast, module-level depends_on serves a different goal: create an explicit ordering edge for module resources that have a real hidden dependency, not instantiate a reusable configuration unit under a distinct local name.
Incorrect Answers
B:The description applies to module-level depends_on when an engineer needs to create an explicit ordering edge for module resources that have a real hidden dependency; the named a module call block instead handles the requirement to instantiate a reusable configuration unit under a distinct local name, so this behavior does not describe A module call block in the situation named.
C:The description applies to module composition when an engineer needs to combine small modules into a root configuration without producing one giant module; the named a module call block instead handles the requirement to instantiate a reusable configuration unit under a distinct local name, so this behavior does not describe A module call block in the situation named.
D:The description applies to a module dependency interface when an engineer needs to connect two modules by declared output and input values; the named a module call block instead handles the requirement to instantiate a reusable configuration unit under a distinct local name, so this behavior does not describe A module call block in the situation named.
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.