Question 340
The team evaluates “Lock release after completion” for a requirement to understand why a normal Terraform operation frees the lock. Which observed behavior belongs to that mechanism rather than a different Terraform feature?
- A state backend with locking helps serialize competing changes, complemented by pipeline approval and run coordination.
- The -lock=false option bypasses locking safeguards and increases the risk of two runs writing inconsistent state.
- A lock may belong to another active run, so check its identity and run status rather than immediately forcing removal.
- Terraform obtains and releases supported backend locks around state-sensitive operations; a crash can sometimes leave manual recovery necessary.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to understand why a normal Terraform operation frees the lock, so it produces the behavior described. In contrast, lock ownership verification serves a different goal: confirm that a held lock is stale before attempting manual removal, not understand why a normal Terraform operation frees the lock.
Incorrect Answers
A:The description applies to state consistency during CI when an engineer needs to keep two pipelines from changing the same infrastructure state simultaneously; the named lock release after completion instead handles the requirement to understand why a normal Terraform operation frees the lock, so this behavior does not describe Lock release after completion in the situation named.
B:The description applies to not disabling locking for speed when an engineer needs to avoid conflicting state updates during concurrent deployments; the named lock release after completion instead handles the requirement to understand why a normal Terraform operation frees the lock, so this behavior does not describe Lock release after completion in the situation named.
C:The description applies to lock ownership verification when an engineer needs to confirm that a held lock is stale before attempting manual removal; the named lock release after completion instead handles the requirement to understand why a normal Terraform operation frees the lock, so this behavior does not describe Lock release after completion in the situation named.
Question 341
During an infrastructure design review about how to replace standing cloud keys with short-lived run identities, a maintainer asks what “HCP provider dynamic credentials” does. Which description is accurate?
- HCP Terraform permissions differentiate viewing configuration and runs from authorized apply or administration operations.
- HCP Terraform can use supported dynamic provider credentials that are generated for runs rather than stored as permanent workspace secrets.
- Run triggers coordinate dependent HCP Terraform workspaces through an event relationship without merging their states.
- Policy sets organize policy rules and their workspace or project applicability rather than modifying provider schemas directly.
- HCP Terraform supports OPA-based policy sets for automated governance on applicable runs.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to replace standing cloud keys with short-lived run identities, so it produces the behavior described. In contrast, workspace access separation serves a different goal: prevent a developer with read access from automatically applying production changes, not replace standing cloud keys with short-lived run identities.
Incorrect Answers
A:The description applies to workspace access separation when an engineer needs to prevent a developer with read access from automatically applying production changes; the named HCP provider dynamic credentials instead handles the requirement to replace standing cloud keys with short-lived run identities, so this behavior does not describe HCP provider dynamic credentials in the situation named.
C:The description applies to run triggers when an engineer needs to start downstream workspace runs after upstream workspace changes complete; the named HCP provider dynamic credentials instead handles the requirement to replace standing cloud keys with short-lived run identities, so this behavior does not describe HCP provider dynamic credentials in the situation named.
D:The description applies to policy sets when an engineer needs to attach a shared governance policy collection to selected workspace scopes; the named HCP provider dynamic credentials instead handles the requirement to replace standing cloud keys with short-lived run identities, so this behavior does not describe HCP provider dynamic credentials in the situation named.
E: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 provider dynamic credentials instead handles the requirement to replace standing cloud keys with short-lived run identities, so this behavior does not describe HCP provider dynamic credentials in the situation named.
Question 342
A Terraform runbook prescribes “Variable validation during planning” to resolve missing provider schemas before checking configuration, but it does not meet the requirement. What does that step actually accomplish?
- The Terraform test command executes defined test runs and assertions, which can exercise behavior beyond basic configuration validation.
- Variable validation conditions evaluate against actual values when Terraform processes inputs, which is different from only checking syntax.
- Validation compares configuration with provider schemas and reports missing required fields.
- Because validate consults provider and module definitions, run init first to install referenced dependencies.
Explanation
Correct Answer
B:Variable validation during planning is used when an operator needs to reject a supplied input value that violates a custom validation rule. Consequently, this choice cannot meet the separate requirement to resolve missing provider schemas before checking configuration. The intended action would instead require Validate after init.
Incorrect Answers
A:This behavior belongs to terraform test, which helps engineers run declarative module tests instead of only checking syntax rather than satisfying the separate requirement to resolve missing provider schemas before checking configuration. The attempted technique was Variable validation during planning; it would instead be used to reject a supplied input value that violates a custom validation rule, not to produce the effect associated with terraform test.
C:This behavior belongs to Missing required argument detection, which helps engineers catch a resource block lacking a mandatory argument rather than satisfying the separate requirement to resolve missing provider schemas before checking configuration. The attempted technique was Variable validation during planning; it would instead be used to reject a supplied input value that violates a custom validation rule, not to produce the effect associated with Missing required argument detection.
D:That outcome belongs to Validate after init, the mechanism that can resolve missing provider schemas before checking configuration. The question concerns the engineer’s actual proposal, Variable validation during planning; it is directed at reject a supplied input value that violates a custom validation rule, not that result.
Question 343
A Terraform reviewer encounters “terraform fmt -recursive” while assessing how to format Terraform files in nested directories under a module tree. Which statement correctly describes its actual behavior?
- The diff switch displays textual differences between current file formatting and the canonical formatting result.
- The recursive switch extends formatting into subdirectories rather than limiting the operation to the current directory.
- terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable.
- The fmt command rewrites HCL source according to Terraform's formatting conventions without provisioning resources.
- The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to format Terraform files in nested directories under a module tree, so it produces the behavior described. In contrast, terraform fmt serves a different goal: apply Terraform's canonical formatting to local .tf source files, not format Terraform files in nested directories under a module tree.
Incorrect Answers
A:The description applies to terraform fmt -diff when an engineer needs to show which HCL formatting edits Terraform would make; the named terraform fmt -recursive instead handles the requirement to format Terraform files in nested directories under a module tree, so this behavior does not describe terraform fmt -recursive in the situation named.
C:The description applies to formatting versus validation when an engineer needs to distinguish style-only issues from Terraform type and schema errors; the named terraform fmt -recursive instead handles the requirement to format Terraform files in nested directories under a module tree, so this behavior does not describe terraform fmt -recursive in the situation named.
D:The description applies to terraform fmt when an engineer needs to apply Terraform's canonical formatting to local .tf source files; the named terraform fmt -recursive instead handles the requirement to format Terraform files in nested directories under a module tree, so this behavior does not describe terraform fmt -recursive in the situation named.
E:The description applies to canonical HCL alignment when an engineer needs to keep spacing and indentation consistent between developers; the named terraform fmt -recursive instead handles the requirement to format Terraform files in nested directories under a module tree, so this behavior does not describe terraform fmt -recursive in the situation named.
Question 344
An engineering checklist calls for separate outcomes: (1) isolate state and runs for two deployment environments; (2) run Terraform in a private network where hosted workers cannot reach internal endpoints. Which TWO options implement the requested outcomes? Choose TWO.
- Project membership changes
- Distinct production and staging workspaces
- A run plan phase
- Project-level variable sets
- HCP Terraform execution agents
Explanation
Correct Answers
B:Each HCP Terraform workspace has its own state and run configuration so changes in one do not automatically update the other; this meets the requirement to isolate state and runs for two deployment environments, while the other selected techniques address run Terraform in a private network where hosted workers cannot reach internal endpoints, which require their own distinct Terraform mechanisms.
E:HCP Terraform agents can execute runs in customer-controlled networking while integrating with service orchestration; this meets the requirement to run Terraform in a private network where hosted workers cannot reach internal endpoints, while the other selected techniques address isolate state and runs for two deployment environments, which require their own distinct Terraform mechanisms.
Incorrect Answers
A:A project is a grouping and access construct; changing project assignment does not turn two workspaces into one state; it addresses move a workspace to a different organizational group without merging infrastructure state, but this delivery instead requires isolate state and runs for two deployment environments and run Terraform in a private network where hosted workers cannot reach internal endpoints. The required combination involves HCP Terraform execution agents and Distinct production and staging workspaces, not the behavior of Project membership changes.
C:HCP Terraform runs have plan stages where proposed infrastructure operations can be inspected and checked; it addresses review infrastructure differences before applying a workspace change, but this delivery instead requires isolate state and runs for two deployment environments and run Terraform in a private network where hosted workers cannot reach internal endpoints. The required combination involves HCP Terraform execution agents and Distinct production and staging workspaces, not the behavior of A run plan phase.
D:Variable sets can be scoped to projects to share configuration while avoiding repetitive per-workspace assignments; it addresses assign common environment values to a group of workspaces, but this delivery instead requires isolate state and runs for two deployment environments and run Terraform in a private network where hosted workers cannot reach internal endpoints. The required combination involves HCP Terraform execution agents and Distinct production and staging workspaces, not the behavior of Project-level variable sets.
Question 345
An application stack composed of modules requires a way to reproduce a vetted module release without automatically selecting a newer one. Which Terraform approach most directly fulfills that request?
- Reviewing module upgrade changes
- A registry module version constraint
- A strict registry module pin
- A pessimistic module version constraint
Explanation
Correct Answer
C:A module version constraint such as = 2.1.3 selects only that published version until the requirement changes; this directly meets the requirement to reproduce a vetted module release without automatically selecting a newer one. By comparison, a pessimistic module version constraint is intended to allow compatible patch updates within a module's minor release series, which is a different task from reproduce a vetted module release without automatically selecting a newer one.
Incorrect Answers
A:A module upgrade can change resource definitions and outputs, so the consumer should inspect the new source and resulting Terraform plan; this mechanism is useful when the job is to control behavioral changes after moving to a new module release, whereas the current scenario requires the engineer to reproduce a vetted module release without automatically selecting a newer one. These operations have different effects in the stated Terraform workflow.
B:The module version argument accepts version constraints for registry sources and Terraform resolves compatible published releases during init; this mechanism is useful when the job is to select a supported module release range from the registry, whereas the current scenario requires the engineer to reproduce a vetted module release without automatically selecting a newer one. These operations have different effects in the stated Terraform workflow.
D:A module version ~> 2.1.0 permits 2.1.x releases but excludes 2.2.0 and later; this mechanism is useful when the job is to allow compatible patch updates within a module's minor release series, whereas the current scenario requires the engineer to reproduce a vetted module release without automatically selecting a newer one. These operations have different effects in the stated Terraform workflow.
Question 346
A team compares Terraform mechanisms for the goal to associate one existing remote object with a configured resource address. Which stated consequence belongs specifically to “terraform import ADDRESS ID”?
- Provider documentation determines the required import identity; it may be an ID or compound identifier depending on resource type.
- The import CLI command records a provider-defined remote ID at a Terraform address but does not automatically write a complete resource block.
- A top-level import block identifies a target resource address and import identity so the operation participates in plan and apply.
- The import workflow adds an existing remote object to state and can manage it through later plans instead of creating a replacement automatically.
- Each managed remote object should have its own appropriate resource instance address so state can map objects unambiguously.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to associate one existing remote object with a configured resource address, so it produces the behavior described. In contrast, an import block's id argument serves a different goal: supply the remote identifier in the format accepted by the resource's provider, not associate one existing remote object with a configured resource address.
Incorrect Answers
A:The description applies to an import block's id argument when an engineer needs to supply the remote identifier in the format accepted by the resource's provider; the named terraform import ADDRESS ID instead handles the requirement to associate one existing remote object with a configured resource address, so this behavior does not describe terraform import ADDRESS ID in the situation named.
C:The description applies to the import block when an engineer needs to declare a managed import operation in configuration for planning and applying; the named terraform import ADDRESS ID instead handles the requirement to associate one existing remote object with a configured resource address, so this behavior does not describe terraform import ADDRESS ID in the situation named.
D:The description applies to importing without creating new infrastructure when an engineer needs to take ownership of an existing object rather than duplicating it; the named terraform import ADDRESS ID instead handles the requirement to associate one existing remote object with a configured resource address, so this behavior does not describe terraform import ADDRESS ID in the situation named.
E:The description applies to separate resources for separate imports when an engineer needs to avoid attaching two remote objects to the same Terraform resource address; the named terraform import ADDRESS ID instead handles the requirement to associate one existing remote object with a configured resource address, so this behavior does not describe terraform import ADDRESS ID in the situation named.
Question 347
A reusable infrastructure definition requires a way to publish a computed result after applying a root module. Which Terraform approach most directly fulfills that request?
- A nullable variable setting
- The -var-file option
- A root output block
- The -var option
Explanation
Correct Answer
C:An output block exposes an expression value to CLI users and supported automation or cross-configuration consumers; this directly meets the requirement to publish a computed result after applying a root module. By comparison, the -var option is intended to supply a single variable assignment when invoking plan or apply, which is a different task from publish a computed result after applying a root module.
Incorrect Answers
A:The nullable argument on a variable declaration determines whether null is a valid override of its normal value; this mechanism is useful when the job is to control whether a caller can intentionally pass null to an input variable, whereas the current scenario requires the engineer to publish a computed result after applying a root module. These operations have different effects in the stated Terraform workflow.
B:The -var-file flag explicitly selects a variables file rather than relying on auto-loaded naming conventions; this mechanism is useful when the job is to load a nonstandard variable file selected for one environment, whereas the current scenario requires the engineer to publish a computed result after applying a root module. These operations have different effects in the stated Terraform workflow.
D:Command-line -var assignments take high precedence and are useful for an explicit run-specific override; this mechanism is useful when the job is to supply a single variable assignment when invoking plan or apply, whereas the current scenario requires the engineer to publish a computed result after applying a root module. These operations have different effects in the stated Terraform workflow.
Question 348
The team evaluates “A post-import plan” for a requirement to review whether Terraform intends to change imported infrastructure unexpectedly. Which observed behavior belongs to that mechanism rather than a different Terraform feature?
- Generated resource declarations are a starting point and can include computed or unsuitable attributes requiring manual cleanup.
- Provider documentation determines the required import identity; it may be an ID or compound identifier depending on resource type.
- After import, planning reveals mismatches between the declared resource arguments and the discovered remote object's attributes.
- Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to review whether Terraform intends to change imported infrastructure unexpectedly, so it produces the behavior described. In contrast, an import configuration review serves a different goal: correct provider-generated HCL rather than trusting every inferred argument, not review whether Terraform intends to change imported infrastructure unexpectedly.
Incorrect Answers
A:The description applies to an import configuration review when an engineer needs to correct provider-generated HCL rather than trusting every inferred argument; the named a post-import plan instead handles the requirement to review whether Terraform intends to change imported infrastructure unexpectedly, so this behavior does not describe A post-import plan in the situation named.
B:The description applies to an import block's id argument when an engineer needs to supply the remote identifier in the format accepted by the resource's provider; the named a post-import plan instead handles the requirement to review whether Terraform intends to change imported infrastructure unexpectedly, so this behavior does not describe A post-import plan in the situation named.
D:The description applies to provider permissions during import when an engineer needs to read an existing cloud object so Terraform can associate it with state; the named a post-import plan instead handles the requirement to review whether Terraform intends to change imported infrastructure unexpectedly, so this behavior does not describe A post-import plan in the situation named.
Question 349
A reusable module interface review requires a way to understand which source files Terraform loads as one module. Which Terraform approach most directly fulfills that request?
- Module provider mappings
- A module with count
- Avoiding hard-coded child credentials
- A module root directory
Explanation
Correct Answer
D:All Terraform configuration files in a module directory are combined as one module; filenames do not define separate execution units; this directly meets the requirement to understand which source files Terraform loads as one module. By comparison, avoiding hard-coded child credentials is intended to keep authentication and deployment-specific region choices outside a reusable child module, which is a different task from understand which source files Terraform loads as one module.
Incorrect Answers
A:The providers map on the module call maps child provider names to selected provider configurations from the root module; this mechanism is useful when the job is to send the correct region-specific provider into a reusable child module, whereas the current scenario requires the engineer to understand which source files Terraform loads as one module. These operations have different effects in the stated Terraform workflow.
B:The count meta-argument creates numerically indexed module instances such as module.worker[0]; this mechanism is useful when the job is to instantiate a fixed number of child module copies, whereas the current scenario requires the engineer to understand which source files Terraform loads as one module. These operations have different effects in the stated Terraform workflow.
C:Reusable modules normally declare provider requirements while callers supply provider configurations and credentials; this mechanism is useful when the job is to keep authentication and deployment-specific region choices outside a reusable child module, whereas the current scenario requires the engineer to understand which source files Terraform loads as one module. These operations have different effects in the stated Terraform workflow.
Question 350
A Terraform reviewer encounters “terraform init -reconfigure” while assessing how to switch backend settings without performing automatic state migration. Which statement correctly describes its actual behavior?
- Backend config arguments supplied at init time fill required values, but sensitive content can still be cached in local metadata or plans.
- The reconfigure flag discards cached previous backend settings and does not copy the prior state snapshot.
- The S3 backend uses configured bucket and key settings, plus suitable authentication and optional locking support.
- Encryption is controlled by the chosen backend service; Terraform's remote backend abstraction does not supply one universal encryption mechanism.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to switch backend settings without performing automatic state migration, so it produces the behavior described. In contrast, the S3 backend serves a different goal: store Terraform state as an object in an S3 bucket, not switch backend settings without performing automatic state migration.
Incorrect Answers
A:The description applies to partial backend configuration when an engineer needs to provide environment-specific backend details at initialization rather than hard-coding them; the named terraform init -reconfigure instead handles the requirement to switch backend settings without performing automatic state migration, so this behavior does not describe terraform init -reconfigure in the situation named.
C:The description applies to the S3 backend when an engineer needs to store Terraform state as an object in an S3 bucket; the named terraform init -reconfigure instead handles the requirement to switch backend settings without performing automatic state migration, so this behavior does not describe terraform init -reconfigure in the situation named.
D:The description applies to remote state encryption at rest when an engineer needs to protect stored state contents from unauthorized storage-layer access; the named terraform init -reconfigure instead handles the requirement to switch backend settings without performing automatic state migration, so this behavior does not describe terraform init -reconfigure in the situation named.