Question 140
A Terraform reviewer encounters “Preconditions for external assumptions” while assessing how to guard a resource against prerequisites outside the provider's basic schema. Which statement correctly describes its actual behavior?
- Validation, precondition and postcondition definitions use error_message to tell the operator why a rule failed.
- Variable validation rejects unacceptable values, whereas failed check assertions are intended for diagnostic warnings.
- A precondition can express a domain requirement such as a selected image having an expected property before using it.
- Check blocks contain assert blocks with condition and error_message to describe an unsuccessful assertion.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to guard a resource against prerequisites outside the provider's basic schema, so it produces the behavior described. In contrast, the error_message field serves a different goal: present a meaningful explanation when a custom condition evaluates false, not guard a resource against prerequisites outside the provider's basic schema.
Incorrect Answers
A:The description applies to the error_message field when an engineer needs to present a meaningful explanation when a custom condition evaluates false; the named preconditions for external assumptions instead handles the requirement to guard a resource against prerequisites outside the provider's basic schema, so this behavior does not describe Preconditions for external assumptions in the situation named.
B:The description applies to input validation versus check blocks when an engineer needs to choose a blocking input constraint rather than a monitoring-style assertion; the named preconditions for external assumptions instead handles the requirement to guard a resource against prerequisites outside the provider's basic schema, so this behavior does not describe Preconditions for external assumptions in the situation named.
D:The description applies to an assert block inside check when an engineer needs to define a specific boolean statement for a nonblocking Terraform health check; the named preconditions for external assumptions instead handles the requirement to guard a resource against prerequisites outside the provider's basic schema, so this behavior does not describe Preconditions for external assumptions in the situation named.
Question 141
During an infrastructure design review about how to verify formatting without rewriting the files in a CI job, a maintainer asks what “terraform fmt -check” does. Which description is accurate?
- Because validate consults provider and module definitions, run init first to install referenced dependencies.
- terraform validate runs offline-oriented configuration checks and does not deploy managed resources.
- The fmt -check option exits with a failure status when source files would need formatting changes rather than altering them.
- The validate command checks syntax and schema consistency in an initialized configuration without obtaining a full execution plan.
- Validation compares configuration with provider schemas and reports missing required fields.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to verify formatting without rewriting the files in a CI job, so it produces the behavior described. In contrast, terraform validate serves a different goal: check that Terraform configuration is structurally valid without planning resource changes, not verify formatting without rewriting the files in a CI job.
Incorrect Answers
A:The description applies to validate after init when an engineer needs to resolve missing provider schemas before checking configuration; the named terraform fmt -check instead handles the requirement to verify formatting without rewriting the files in a CI job, so this behavior does not describe terraform fmt -check in the situation named.
B:The description applies to validate without live deployment when an engineer needs to detect invalid configuration even when no cloud changes should occur; the named terraform fmt -check instead handles the requirement to verify formatting without rewriting the files in a CI job, so this behavior does not describe terraform fmt -check in the situation named.
D:The description applies to terraform validate when an engineer needs to check that Terraform configuration is structurally valid without planning resource changes; the named terraform fmt -check instead handles the requirement to verify formatting without rewriting the files in a CI job, so this behavior does not describe terraform fmt -check in the situation named.
E:The description applies to missing required argument detection when an engineer needs to catch a resource block lacking a mandatory argument; the named terraform fmt -check instead handles the requirement to verify formatting without rewriting the files in a CI job, so this behavior does not describe terraform fmt -check in the situation named.
Question 142
An engineer troubleshooting a .tf configuration needs to substitute matching substrings within a value. Which feature or operation is the most direct match?
- The base64encode function
- The dynamic block
- The replace function
- The for expression
Explanation
Correct Answer
C:replace searches a string for a matching substring or pattern and replaces matches with a new string; this directly meets the requirement to substitute matching substrings within a value. By comparison, the for expression is intended to transform a collection's elements into a new list or map, which is a different task from substitute matching substrings within a value.
Incorrect Answers
A:base64encode applies a reversible encoding and should not be mistaken for encryption of secrets; this mechanism is useful when the job is to turn ordinary string content into Base64 text, whereas the current scenario requires the engineer to substitute matching substrings within a value. These operations have different effects in the stated Terraform workflow.
B:dynamic constructs blocks required by resource schemas; it does not create standalone Terraform resource declarations; this mechanism is useful when the job is to generate repeated nested blocks from a collection, whereas the current scenario requires the engineer to substitute matching substrings within a value. These operations have different effects in the stated Terraform workflow.
D:A for expression builds derived collection values, optionally filtering with an if clause and transforming keys or values; this mechanism is useful when the job is to transform a collection's elements into a new list or map, whereas the current scenario requires the engineer to substitute matching substrings within a value. These operations have different effects in the stated Terraform workflow.
Question 143
A change-control meeting for a root module needs to understand why a computed attribute is unavailable in the preview. Which feature or operation is the most direct match?
- An unknown value until apply
- terraform plan -target
- terraform show -json on a plan
- terraform plan -refresh-only
Explanation
Correct Answer
A:Terraform may mark attributes as known after apply because a provider assigns their values only when creating or updating a real object; this directly meets the requirement to understand why a computed attribute is unavailable in the preview. By comparison, terraform plan -target is intended to limit a recovery-oriented plan to a resource and its dependencies, which is a different task from understand why a computed attribute is unavailable in the preview.
Incorrect Answers
B:Targeting narrows planning scope and can miss other required changes, so it is not the normal long-term workflow; this mechanism is useful when the job is to limit a recovery-oriented plan to a resource and its dependencies, whereas the current scenario requires the engineer to understand why a computed attribute is unavailable in the preview. These operations have different effects in the stated Terraform workflow.
C:The -json flag emits a structured JSON representation suitable for inspection by automation, with careful handling of sensitive output; this mechanism is useful when the job is to feed a saved plan to a machine-readable analysis tool, whereas the current scenario requires the engineer to understand why a computed attribute is unavailable in the preview. These operations have different effects in the stated Terraform workflow.
D:Refresh-only planning proposes changes to Terraform state or root outputs based on remote observations, without proposing ordinary resource updates; this mechanism is useful when the job is to propose updating state or root outputs to reflect remote changes without planning infrastructure remediation, whereas the current scenario requires the engineer to understand why a computed attribute is unavailable in the preview. These operations have different effects in the stated Terraform workflow.
Question 144
A team compares Terraform mechanisms for the goal to show which HCL formatting edits Terraform would make. Which stated consequence belongs specifically to “terraform fmt -diff”?
- Check mode verifies formatting and returns a failure when changes would be required instead of writing edited files.
- The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls.
- terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable.
- 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.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to show which HCL formatting edits Terraform would make, so it produces the behavior described. In contrast, terraform fmt -recursive serves a different goal: format Terraform files in nested directories under a module tree, not show which HCL formatting edits Terraform would make.
Incorrect Answers
A:The description applies to terraform fmt -check when an engineer needs to make a CI formatting gate detect source files that need formatting; the named terraform fmt -diff instead handles the requirement to show which HCL formatting edits Terraform would make, so this behavior does not describe terraform fmt -diff in the situation named.
B:The description applies to canonical HCL alignment when an engineer needs to keep spacing and indentation consistent between developers; the named terraform fmt -diff instead handles the requirement to show which HCL formatting edits Terraform would make, so this behavior does not describe terraform fmt -diff 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 -diff instead handles the requirement to show which HCL formatting edits Terraform would make, so this behavior does not describe terraform fmt -diff in the situation named.
E:The description applies to terraform fmt -recursive when an engineer needs to format Terraform files in nested directories under a module tree; the named terraform fmt -diff instead handles the requirement to show which HCL formatting edits Terraform would make, so this behavior does not describe terraform fmt -diff in the situation named.
Question 145
A change request asks an engineer to switch the currently selected Terraform CLI workspace. Which choice best implements the requested behavior?
- terraform state rm
- terraform state show ADDRESS
- terraform workspace select
- terraform state replace-provider
Explanation
Correct Answer
C:Workspace selection changes which workspace state namespace the root configuration uses; it does not select a cloud account automatically; this directly meets the requirement to switch the currently selected Terraform CLI workspace. By comparison, terraform state rm is intended to stop tracking a resource without telling its provider to delete the remote object, which is a different task from switch the currently selected Terraform CLI workspace.
Incorrect Answers
A:State rm deletes the state association, not the object in the external system; this mechanism is useful when the job is to stop tracking a resource without telling its provider to delete the remote object, whereas the current scenario requires the engineer to switch the currently selected Terraform CLI workspace. These operations have different effects in the stated Terraform workflow.
B:State show presents one resource's stored attributes in human-readable form and may reveal secret values; this mechanism is useful when the job is to view attributes for a specified state-tracked resource instance, whereas the current scenario requires the engineer to switch the currently selected Terraform CLI workspace. These operations have different effects in the stated Terraform workflow.
D:Replace-provider rewrites provider source references in state and creates a backup before the edit; this mechanism is useful when the job is to update the provider source address recorded for affected state resources, whereas the current scenario requires the engineer to switch the currently selected Terraform CLI workspace. These operations have different effects in the stated Terraform workflow.
Question 146
A Terraform reviewer encounters “Provider aliases” while assessing how to configure two connections to the same service for different regions or accounts. Which statement correctly describes its actual behavior?
- A provider configuration with alias defines a named alternate that resources or modules can explicitly select.
- The provider declares accepted resource arguments and computed attributes; Terraform validates configuration against that schema.
- Providers retrieve object details so Terraform can compare observed infrastructure against desired configuration and prior state.
- Terraform checks downloaded provider package checksums against lock information where hashes are available.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to configure two connections to the same service for different regions or accounts, so it produces the behavior described. In contrast, provider-defined resource schemas serves a different goal: determine which arguments a resource type accepts, not configure two connections to the same service for different regions or accounts.
Incorrect Answers
B:The description applies to provider-defined resource schemas when an engineer needs to determine which arguments a resource type accepts; the named provider aliases instead handles the requirement to configure two connections to the same service for different regions or accounts, so this behavior does not describe Provider aliases in the situation named.
C:The description applies to provider data refresh when an engineer needs to read current attributes of managed remote objects during planning; the named provider aliases instead handles the requirement to configure two connections to the same service for different regions or accounts, so this behavior does not describe Provider aliases in the situation named.
D:The description applies to provider integrity hashes when an engineer needs to detect a mismatched plugin distribution package; the named provider aliases instead handles the requirement to configure two connections to the same service for different regions or accounts, so this behavior does not describe Provider aliases in the situation named.
Question 147
During a design review, the requirement is to understand that Terraform only examines infrastructure represented in its configuration or state scope. Which option should the engineer select?
- terraform state pull
- Serial and lineage checks
- Drift detection boundaries
- A moved block
Explanation
Correct Answer
C:A plan does not discover every unmanaged object in an account; its normal focus is tracked resources and configured data sources; this directly meets the requirement to understand that Terraform only examines infrastructure represented in its configuration or state scope. By comparison, a moved block is intended to rename or relocate a managed resource address without recreating the remote object, which is a different task from understand that Terraform only examines infrastructure represented in its configuration or state scope.
Incorrect Answers
A:The state pull command retrieves state from the configured backend and prints a snapshot that may contain secrets; this mechanism is useful when the job is to obtain the current state snapshot for inspection or controlled backup, whereas the current scenario requires the engineer to understand that Terraform only examines infrastructure represented in its configuration or state scope. These operations have different effects in the stated Terraform workflow.
B:State metadata such as lineage and serial helps protect against incompatible or stale state updates; this mechanism is useful when the job is to detect that a state snapshot belongs to a different history or older generation, whereas the current scenario requires the engineer to understand that Terraform only examines infrastructure represented in its configuration or state scope. These operations have different effects in the stated Terraform workflow.
D:A moved block maps an old Terraform address to a new one so state follows the refactor rather than planning destruction and creation; this mechanism is useful when the job is to rename or relocate a managed resource address without recreating the remote object, whereas the current scenario requires the engineer to understand that Terraform only examines infrastructure represented in its configuration or state scope. These operations have different effects in the stated Terraform workflow.
Question 148
A Terraform change proposal names “A lock identifier” to ensure a force-unlock targets the correct held state lock. Which outcome can reviewers attribute to that particular mechanism?
- Backend state locking behavior depends on the backend implementation; remote storage alone does not guarantee safe locking.
- The lock-timeout option lets Terraform retry lock acquisition for a specified duration before returning an error.
- Terraform obtains and releases supported backend locks around state-sensitive operations; a crash can sometimes leave manual recovery necessary.
- Terraform uses lock information to distinguish a specific operation's lock from unrelated lock holders.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to ensure a force-unlock targets the correct held state lock, so it produces the behavior described. In contrast, lock release after completion serves a different goal: understand why a normal Terraform operation frees the lock, not ensure a force-unlock targets the correct held state lock.
Incorrect Answers
A:The description applies to backend-specific lock support when an engineer needs to check whether a chosen remote backend actually offers state locking; the named a lock identifier instead handles the requirement to ensure a force-unlock targets the correct held state lock, so this behavior does not describe A lock identifier in the situation named.
B:The description applies to terraform plan -lock-timeout when an engineer needs to wait for a temporary state lock instead of failing immediately; the named a lock identifier instead handles the requirement to ensure a force-unlock targets the correct held state lock, so this behavior does not describe A lock identifier in the situation named.
C:The description applies to lock release after completion when an engineer needs to understand why a normal Terraform operation frees the lock; the named a lock identifier instead handles the requirement to ensure a force-unlock targets the correct held state lock, so this behavior does not describe A lock identifier in the situation named.
Question 149
A Terraform change proposal names “The for expression” to transform a collection's elements into a new list or map. Which outcome can reviewers attribute to that particular mechanism?
- lower converts letters to lowercase and is often used in consistent name expressions.
- substr returns characters starting at an offset with the specified length rather than splitting on a delimiter.
- A for expression builds derived collection values, optionally filtering with an if clause and transforming keys or values.
- sha256 computes a one-way hash of a string, not an encrypted recoverable secret or random credential.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to transform a collection's elements into a new list or map, so it produces the behavior described. In contrast, the sha256 function serves a different goal: create a deterministic SHA-256 digest for content comparison, not transform a collection's elements into a new list or map.
Incorrect Answers
A:The description applies to the lower function when an engineer needs to normalize a string identifier to lowercase; the named the for expression instead handles the requirement to transform a collection's elements into a new list or map, so this behavior does not describe The for expression in the situation named.
B:The description applies to the substr function when an engineer needs to extract a specific range of characters from a string; the named the for expression instead handles the requirement to transform a collection's elements into a new list or map, so this behavior does not describe The for expression in the situation named.
D:The description applies to the sha256 function when an engineer needs to create a deterministic SHA-256 digest for content comparison; the named the for expression instead handles the requirement to transform a collection's elements into a new list or map, so this behavior does not describe The for expression in the situation named.
Question 150
During one infrastructure delivery, the team must satisfy all of the following: (1) consume a module managed by the organization's HCP private registry; (2) delegate administration of one team's project without granting universal organization access. Select TWO appropriate Terraform approaches. Choose TWO.
- An HCP private registry module source
- HCP Terraform VCS integration
- Project-scoped team access
- Distinct production and staging workspaces
- HCP Terraform run tasks integration
- Dynamic provider credential integration
Explanation
Correct Answers
A:A module source can reference a private registry hostname and namespace after the client has appropriate authentication; this meets the requirement to consume a module managed by the organization's HCP private registry, while the other selected techniques address delegate administration of one team's project without granting universal organization access, which require their own distinct Terraform mechanisms.
C:Project-level access scopes workspace capabilities for teams based on organizational boundaries; this meets the requirement to delegate administration of one team's project without granting universal organization access, while the other selected techniques address consume a module managed by the organization's HCP private registry, which require their own distinct Terraform mechanisms.
Incorrect Answers
B:A VCS-connected workspace coordinates code changes, speculative plans and controlled applies through supported repository integration; it addresses connect reviewed repository commits to automated infrastructure plans, but this delivery instead requires consume a module managed by the organization's HCP private registry and delegate administration of one team's project without granting universal organization access. The required combination involves Project-scoped team access and An HCP private registry module source, not the behavior of HCP Terraform VCS integration.
D:Each HCP Terraform workspace has its own state and run configuration so changes in one do not automatically update the other; it addresses isolate state and runs for two deployment environments, but this delivery instead requires consume a module managed by the organization's HCP private registry and delegate administration of one team's project without granting universal organization access. The required combination involves Project-scoped team access and An HCP private registry module source, not the behavior of Distinct production and staging workspaces.
E:Run tasks integrate external systems into workflow checkpoints without changing the Terraform resource graph directly; it addresses send proposed changes to a third-party quality or security check service, but this delivery instead requires consume a module managed by the organization's HCP private registry and delegate administration of one team's project without granting universal organization access. The required combination involves Project-scoped team access and An HCP private registry module source, not the behavior of HCP Terraform run tasks integration.
F:Dynamic credentials integrate HCP Terraform with supported identity federation to obtain scoped run credentials; it addresses grant HCP runs temporary cloud authorization instead of long-lived static secrets, but this delivery instead requires consume a module managed by the organization's HCP private registry and delegate administration of one team's project without granting universal organization access. The required combination involves Project-scoped team access and An HCP private registry module source, not the behavior of Dynamic provider credential integration.