Question 60
During an infrastructure design review about how to check proposed infrastructure against rules expressed in Open Policy Agent policies, a maintainer asks what “OPA policy enforcement” does. Which description is accurate?
- Projects group workspaces and support scoped access management for organizational teams.
- HCP Terraform supports OPA-based policy sets for automated governance on applicable runs.
- Team access controls define which users may perform supported workspace operations rather than relying only on provider credentials.
- Registry access and publishing permissions help centralize reusable module governance across teams.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to check proposed infrastructure against rules expressed in Open Policy Agent policies, so it produces the behavior described. In contrast, project-based permission boundaries serves a different goal: delegate administration of grouped HCP Terraform workspaces, not check proposed infrastructure against rules expressed in Open Policy Agent policies.
Incorrect Answers
A:The description applies to project-based permission boundaries when an engineer needs to delegate administration of grouped HCP Terraform workspaces; the named oPA policy enforcement instead handles the requirement to check proposed infrastructure against rules expressed in Open Policy Agent policies, so this behavior does not describe OPA policy enforcement in the situation named.
C:The description applies to HCP team permissions when an engineer needs to grant operators different abilities to view, plan or apply workspace changes; the named oPA policy enforcement instead handles the requirement to check proposed infrastructure against rules expressed in Open Policy Agent policies, so this behavior does not describe OPA policy enforcement in the situation named.
D:The description applies to a restricted private registry when an engineer needs to let approved teams discover modules while controlling publication rights; the named oPA policy enforcement instead handles the requirement to check proposed infrastructure against rules expressed in Open Policy Agent policies, so this behavior does not describe OPA policy enforcement in the situation named.
Question 61
A Terraform reviewer encounters “Resource local names” while assessing how to distinguish two managed instances of the same provider-defined resource type. Which statement correctly describes its actual behavior?
- The built-in terraform_data resource can represent input changes and trigger replacement behavior without managing a cloud API resource.
- A resource block represents an object Terraform manages through a provider, with its identity and attributes tracked in state.
- A resource block has a type and a local label; together they form its address within the module.
- Data source reads can be deferred during planning when their inputs depend on values not known until apply.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to distinguish two managed instances of the same provider-defined resource type, so it produces the behavior described. In contrast, a data source that depends on a resource serves a different goal: delay a lookup until a prerequisite object is available, not distinguish two managed instances of the same provider-defined resource type.
Incorrect Answers
A:The description applies to the terraform_data resource when an engineer needs to model a Terraform-managed lifecycle value without requiring an external service object; the named resource local names instead handles the requirement to distinguish two managed instances of the same provider-defined resource type, so this behavior does not describe Resource local names in the situation named.
B:The description applies to a managed resource block when an engineer needs to declare that Terraform should create and maintain a new infrastructure object; the named resource local names instead handles the requirement to distinguish two managed instances of the same provider-defined resource type, so this behavior does not describe Resource local names in the situation named.
D:The description applies to a data source that depends on a resource when an engineer needs to delay a lookup until a prerequisite object is available; the named resource local names instead handles the requirement to distinguish two managed instances of the same provider-defined resource type, so this behavior does not describe Resource local names in the situation named.
Question 62
During one infrastructure delivery, the team must satisfy all of the following: (1) supply the remote identifier in the format accepted by the resource's provider; (2) obtain detailed Terraform core and provider diagnostic output while troubleshooting. Select TWO appropriate Terraform approaches. Choose TWO.
- A post-import plan
- An import block's id argument
- TF_LOG=TRACE
- terraform plan -generate-config-out
- TF_LOG_PATH
Explanation
Correct Answers
B:Provider documentation determines the required import identity; it may be an ID or compound identifier depending on resource type; this meets the requirement to supply the remote identifier in the format accepted by the resource's provider, while the other selected techniques address obtain detailed Terraform core and provider diagnostic output while troubleshooting, which require their own distinct Terraform mechanisms.
C:Terraform logging set to TRACE emits highly verbose diagnostic detail and may contain sensitive information; this meets the requirement to obtain detailed Terraform core and provider diagnostic output while troubleshooting, while the other selected techniques address supply the remote identifier in the format accepted by the resource's provider, which require their own distinct Terraform mechanisms.
Incorrect Answers
A:After import, planning reveals mismatches between the declared resource arguments and the discovered remote object's attributes; it addresses review whether Terraform intends to change imported infrastructure unexpectedly, but this delivery instead requires supply the remote identifier in the format accepted by the resource's provider and obtain detailed Terraform core and provider diagnostic output while troubleshooting. The required combination involves An import block's id argument and TF_LOG=TRACE, not the behavior of A post-import plan.
D:The experimental config-generation flag can write suggested resource declarations for review and correction before apply; it addresses produce draft HCL for resources named in import blocks without matching configuration, but this delivery instead requires supply the remote identifier in the format accepted by the resource's provider and obtain detailed Terraform core and provider diagnostic output while troubleshooting. The required combination involves An import block's id argument and TF_LOG=TRACE, not the behavior of terraform plan -generate-config-out.
E:TF_LOG_PATH directs log output to a file and should be combined with an enabled TF_LOG level; it addresses save enabled Terraform diagnostic logs to a designated file, but this delivery instead requires supply the remote identifier in the format accepted by the resource's provider and obtain detailed Terraform core and provider diagnostic output while troubleshooting. The required combination involves An import block's id argument and TF_LOG=TRACE, not the behavior of TF_LOG_PATH.
Question 63
During one infrastructure delivery, the team must satisfy all of the following: (1) understand which provider settings a child module can use from its parent; (2) create an explicit ordering edge for module resources that have a real hidden dependency. Select TWO appropriate Terraform approaches. Choose TWO.
- Nested module output propagation
- Module-level depends_on
- Variable validation inside a module
- Provider configuration inheritance
- Multiple calls to one module
Explanation
Correct Answers
B:depends_on on a module call affects all resources and data sources inside that module and can constrain concurrency; this meets the requirement to create an explicit ordering edge for module resources that have a real hidden dependency, while the other selected techniques address understand which provider settings a child module can use from its parent, which require their own distinct Terraform mechanisms.
D:Default provider configurations can be inherited, while alternate aliases need explicit mapping and declared configuration aliases; this meets the requirement to understand which provider settings a child module can use from its parent, while the other selected techniques address create an explicit ordering edge for module resources that have a real hidden dependency, which require their own distinct Terraform mechanisms.
Incorrect Answers
A:Each module boundary needs an output passthrough because the root cannot directly access an arbitrary grandchild's private resources; it addresses make a value from a grandchild module visible to the root module, but this delivery instead requires understand which provider settings a child module can use from its parent and create an explicit ordering edge for module resources that have a real hidden dependency. The required combination involves Provider configuration inheritance and Module-level depends_on, not the behavior of Nested module output propagation.
C:A child module may validate its input variables using conditions and errors independent of the parent's variable definitions; it addresses enforce a reusable module's own input contract, but this delivery instead requires understand which provider settings a child module can use from its parent and create an explicit ordering edge for module resources that have a real hidden dependency. The required combination involves Provider configuration inheritance and Module-level depends_on, not the behavior of Variable validation inside a module.
E:Two module blocks that use the same source create separate module instances and separate resource addresses; it addresses deploy two independently managed stacks from the same module definition, but this delivery instead requires understand which provider settings a child module can use from its parent and create an explicit ordering edge for module resources that have a real hidden dependency. The required combination involves Provider configuration inheritance and Module-level depends_on, not the behavior of Multiple calls to one module.
Question 64
A configuration review for an application stack requires a way to make a subnet wait for the network resource it references. Which Terraform approach most directly fulfills that request?
- Explicit depends_on for side effects
- prevent_destroy
- Lifecycle ordering versus API support
- Resource targeting as an exception
- create_before_destroy
- An implicit dependency through an ID
Explanation
Correct Answer
F:Using the network object's ID in the subnet argument automatically creates a dependency edge in the graph; this directly meets the requirement to make a subnet wait for the network resource it references. By comparison, prevent_destroy is intended to reject an execution plan that deletes a protected configured object, which is a different task from make a subnet wait for the network resource it references.
Incorrect Answers
A: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 make a subnet wait for the network resource it references. These operations have different effects in the stated Terraform workflow.
B:The lifecycle rule prevents destruction or replacement while it remains declared on the resource; removing its block removes that protection; this mechanism is useful when the job is to reject an execution plan that deletes a protected configured object, whereas the current scenario requires the engineer to make a subnet wait for the network resource it references. These operations have different effects in the stated Terraform workflow.
C:Terraform can request early replacement creation, but remote API constraints may disallow two objects with the same globally unique name; this mechanism is useful when the job is to understand why create_before_destroy can still fail on a uniquely named object, whereas the current scenario requires the engineer to make a subnet wait for the network resource it references. These operations have different effects in the stated Terraform workflow.
D:The -target option narrows an operation to selected objects and prerequisites; routine selective deployment is not its intended model; this mechanism is useful when the job is to repair an isolated broken dependency while acknowledging incomplete plan coverage, whereas the current scenario requires the engineer to make a subnet wait for the network resource it references. These operations have different effects in the stated Terraform workflow.
E:This lifecycle setting changes replacement order, but requires names and quotas to permit temporary coexistence; this mechanism is useful when the job is to create a replacement object before deleting the previous instance, whereas the current scenario requires the engineer to make a subnet wait for the network resource it references. These operations have different effects in the stated Terraform workflow.
Question 65
In a Terraform configuration, what value does the HCL expression coalesce(null, "west", "east") evaluate to?
- null
- "west"
- ["west", "east"]
- "east"
Explanation
Correct Answer
B:The expression coalesce(null, "west", "east") evaluates to "west" because coalesce skips the initial null and returns the first usable nonempty string. This is Terraform's direct evaluation of the supplied literal arguments in coalesce(null, "west", "east"), not an external provider lookup.
Incorrect Answers
A:The null is skipped because a non-null fallback follows. In this specific evaluation, coalesce skips the initial null and returns the first usable nonempty string, which rules out the proposed alternative.
C:Coalesce returns one selected value instead of collecting the non-null arguments. HCL evaluates coalesce(null, "west", "east") using the supplied arguments: coalesce skips the initial null and returns the first usable nonempty string; the listed result is therefore incorrect.
D:The function returns the first usable argument, not the last one. For coalesce(null, "west", "east"), coalesce skips the initial null and returns the first usable nonempty string; consequently this candidate is not the value Terraform computes.
Question 66
A team compares Terraform mechanisms for the goal to save the default workspace state to a nondefault local filename. Which stated consequence belongs specifically to “A local backend path setting”?
- Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter.
- The local backend supports a path argument for where the state file is stored on disk.
- Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state.
- Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to save the default workspace state to a nondefault local filename, so it produces the behavior described. In contrast, state file confidentiality serves a different goal: protect a workstation's local state file even when output values are hidden, not save the default workspace state to a nondefault local filename.
Incorrect Answers
A:The description applies to state file confidentiality when an engineer needs to protect a workstation's local state file even when output values are hidden; the named a local backend path setting instead handles the requirement to save the default workspace state to a nondefault local filename, so this behavior does not describe A local backend path setting in the situation named.
C:The description applies to backend configuration only in a root module when an engineer needs to choose where a root deployment's state will be stored; the named a local backend path setting instead handles the requirement to save the default workspace state to a nondefault local filename, so this behavior does not describe A local backend path setting in the situation named.
D: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 a local backend path setting instead handles the requirement to save the default workspace state to a nondefault local filename, so this behavior does not describe A local backend path setting in the situation named.
Question 67
A change request asks an engineer to diagnose why destroy fails despite valid Terraform syntax. Which choice best implements the requested behavior?
- Resource-specific delete restrictions
- An explicit prevent_destroy rule
- terraform destroy
- terraform apply -destroy
- Remove from state without deletion
Explanation
Correct Answer
A:Providers and remote APIs can reject deletion when dependencies, protection flags or permissions prevent removing the object; this directly meets the requirement to diagnose why destroy fails despite valid Terraform syntax. 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 diagnose why destroy fails despite valid Terraform syntax.
Incorrect Answers
B: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 diagnose why destroy fails despite valid Terraform syntax. These operations have different effects in the stated Terraform workflow.
C: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 diagnose why destroy fails despite valid Terraform syntax. These operations have different effects in the stated Terraform workflow.
D: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 diagnose why destroy fails despite valid Terraform syntax. These operations have different effects in the stated Terraform workflow.
E: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 diagnose why destroy fails despite valid Terraform syntax. These operations have different effects in the stated Terraform workflow.
Question 68
A change request asks an engineer to define which configuration branch or directory produces automatic runs. Which choice best implements the requested behavior?
- A workspace's VCS repository settings
- One state per independently owned system
- Workspace-specific variables
- Project membership changes
Explanation
Correct Answer
A:VCS connection details identify the source code changes that should trigger a workspace's Terraform run; this directly meets the requirement to define which configuration branch or directory produces automatic runs. By comparison, workspace-specific variables is intended to override or tailor values used by one particular stack, which is a different task from define which configuration branch or directory produces automatic runs.
Incorrect Answers
B:Separate workspaces allow independent state lifecycles for services that are changed and approved separately; this mechanism is useful when the job is to avoid coupling different teams' deploys into a single state and blast radius, whereas the current scenario requires the engineer to define which configuration branch or directory produces automatic runs. These operations have different effects in the stated Terraform workflow.
C:Workspace settings store variables for that workspace's execution; global sets should not replace environment-specific data blindly; this mechanism is useful when the job is to override or tailor values used by one particular stack, whereas the current scenario requires the engineer to define which configuration branch or directory produces automatic runs. These operations have different effects in the stated Terraform workflow.
D:A project is a grouping and access construct; changing project assignment does not turn two workspaces into one state; this mechanism is useful when the job is to move a workspace to a different organizational group without merging infrastructure state, whereas the current scenario requires the engineer to define which configuration branch or directory produces automatic runs. These operations have different effects in the stated Terraform workflow.
Question 69
A Terraform module author has a concrete implementation goal: refer to the stable key of a for_each resource instance. What is the most appropriate Terraform mechanism?
- Output dependency metadata
- each.key
- A module output reference
- An implicit attribute dependency
Explanation
Correct Answer
B:In a for_each resource block, each.key identifies the current map key or set element for that instance; this directly meets the requirement to refer to the stable key of a for_each resource instance. By comparison, output dependency metadata is intended to delay the visibility of an output until additional required operations finish, which is a different task from refer to the stable key of a for_each resource instance.
Incorrect Answers
A:An output block can use depends_on for dependencies that are not evident from its value expression; this mechanism is useful when the job is to delay the visibility of an output until additional required operations finish, whereas the current scenario requires the engineer to refer to the stable key of a for_each resource instance. These operations have different effects in the stated Terraform workflow.
C:Parent configurations access child outputs using module.CHILD.OUTPUT; private child resource addresses are not automatically exported; this mechanism is useful when the job is to use a child module's published value in a parent resource, whereas the current scenario requires the engineer to refer to the stable key of a for_each resource instance. These operations have different effects in the stated Terraform workflow.
D:Referencing another managed resource's attribute creates an implicit dependency in Terraform's graph; this mechanism is useful when the job is to ensure a dependent resource waits for the object whose ID it needs, whereas the current scenario requires the engineer to refer to the stable key of a for_each resource instance. These operations have different effects in the stated Terraform workflow.
Question 70
A declarative resource and expression design requires a way to look up an already existing object without taking ownership of its lifecycle. Which Terraform approach most directly fulfills that request?
- Importing an existing object
- Resource removal without deletion
- A data source block
- Provider resource type prefixes
- Resource local names
Explanation
Correct Answer
C:A data block asks a provider to read information and does not make Terraform create or destroy the referenced remote object; this directly meets the requirement to look up an already existing object without taking ownership of its lifecycle. By comparison, importing an existing object is intended to bring a previously unmanaged remote object under a resource block's lifecycle, which is a different task from look up an already existing object without taking ownership of its lifecycle.
Incorrect Answers
A:Import associates a configured resource address with an existing remote object's provider identity in Terraform state; this mechanism is useful when the job is to bring a previously unmanaged remote object under a resource block's lifecycle, whereas the current scenario requires the engineer to look up an already existing object without taking ownership of its lifecycle. These operations have different effects in the stated Terraform workflow.
B:A removed block with destroy = false can express a configuration-driven removal from state while leaving the infrastructure object intact; this mechanism is useful when the job is to retain a remote object but stop Terraform from managing it, whereas the current scenario requires the engineer to look up an already existing object without taking ownership of its lifecycle. These operations have different effects in the stated Terraform workflow.
D:A resource type name usually starts with its provider local name, such as aws_instance for the AWS provider; this mechanism is useful when the job is to identify which provider implements a resource's API operations, whereas the current scenario requires the engineer to look up an already existing object without taking ownership of its lifecycle. These operations have different effects in the stated Terraform workflow.
E:A resource block has a type and a local label; together they form its address within the module; this mechanism is useful when the job is to distinguish two managed instances of the same provider-defined resource type, whereas the current scenario requires the engineer to look up an already existing object without taking ownership of its lifecycle. These operations have different effects in the stated Terraform workflow.