Question 750
During a design review, the requirement is to remove empty string elements from a list. Which option should the engineer select?
- The file function
- The cidrsubnet function
- The ternary conditional operator
- The compact function
Explanation
Correct Answer
D:compact filters out null or empty-string members from a string list, preserving usable elements; this directly meets the requirement to remove empty string elements from a list. By comparison, the ternary conditional operator is intended to set a resource argument according to a boolean expression, which is a different task from remove empty string elements from a list.
Incorrect Answers
A:file reads existing local text; it does not wait for a provisioner to create the file during apply; this mechanism is useful when the job is to read UTF-8 content already present in a local file during evaluation, whereas the current scenario requires the engineer to remove empty string elements from a list. These operations have different effects in the stated Terraform workflow.
B:cidrsubnet derives a subnet CIDR using additional prefix bits and a network number, without provisioning a network resource; this mechanism is useful when the job is to calculate a nested network prefix from a parent CIDR range, whereas the current scenario requires the engineer to remove empty string elements from a list. These operations have different effects in the stated Terraform workflow.
C:The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks; this mechanism is useful when the job is to set a resource argument according to a boolean expression, whereas the current scenario requires the engineer to remove empty string elements from a list. These operations have different effects in the stated Terraform workflow.
Question 751
During a design review, the requirement is to avoid assuming a local calculation is automatically visible in a parent module. Which option should the engineer select?
- Different values for two module calls
- A local value confined to its module
- Child input variable scope
- Variable validation inside a module
Explanation
Correct Answer
B:Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value; this directly meets the requirement to avoid assuming a local calculation is automatically visible in a parent module. By comparison, child input variable scope is intended to make a setting available inside a called module without creating a global variable, which is a different task from avoid assuming a local calculation is automatically visible in a parent module.
Incorrect Answers
A:Each call has its own variable assignments and resource instances, even when both calls reference the same module source directory; this mechanism is useful when the job is to instantiate the same module with distinct environment inputs, whereas the current scenario requires the engineer to avoid assuming a local calculation is automatically visible in a parent module. These operations have different effects in the stated Terraform workflow.
C:Variables declared by a child module belong to that module and receive values via the caller's module block; this mechanism is useful when the job is to make a setting available inside a called module without creating a global variable, whereas the current scenario requires the engineer to avoid assuming a local calculation is automatically visible in a parent module. These operations have different effects in the stated Terraform workflow.
D:A child module may validate its input variables using conditions and errors independent of the parent's variable definitions; this mechanism is useful when the job is to enforce a reusable module's own input contract, whereas the current scenario requires the engineer to avoid assuming a local calculation is automatically visible in a parent module. These operations have different effects in the stated Terraform workflow.
Question 752
A Terraform deployment has independent requirements: (1) authenticate a provider using a transient secret that should not persist; (2) identify a computed attribute that Terraform cannot determine until apply. Which TWO mechanisms directly address these needs? Choose TWO.
- Environment-based provider credentials
- An unknown plan-time value
- A set of strings type
- Passing ephemeral values to providers
- Not treating Base64 as secrecy
Explanation
Correct Answers
B:An unknown value represents future information and can propagate through expressions until a provider supplies the result; this meets the requirement to identify a computed attribute that Terraform cannot determine until apply, while the other selected techniques address authenticate a provider using a transient secret that should not persist, which require their own distinct Terraform mechanisms.
D:Provider configuration is an allowed reference context for ephemeral variables, enabling runtime-only authentication values; this meets the requirement to authenticate a provider using a transient secret that should not persist, while the other selected techniques address identify a computed attribute that Terraform cannot determine until apply, which require their own distinct Terraform mechanisms.
Incorrect Answers
A:Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL; it addresses avoid putting provider access tokens directly in configuration source, but this delivery instead requires authenticate a provider using a transient secret that should not persist and identify a computed attribute that Terraform cannot determine until apply. The required combination involves An unknown plan-time value and Passing ephemeral values to providers, not the behavior of Environment-based provider credentials.
C:The set(string) type deduplicates values and does not preserve a meaningful input element order; it addresses store a collection with no duplicate members and no guaranteed order, but this delivery instead requires authenticate a provider using a transient secret that should not persist and identify a computed attribute that Terraform cannot determine until apply. The required combination involves An unknown plan-time value and Passing ephemeral values to providers, not the behavior of A set of strings type.
E:Base64 is reversible encoding; exposing encoded credentials in configuration or state still risks disclosure; it addresses recognize that an encoded password remains sensitive information, but this delivery instead requires authenticate a provider using a transient secret that should not persist and identify a computed attribute that Terraform cannot determine until apply. The required combination involves An unknown plan-time value and Passing ephemeral values to providers, not the behavior of Not treating Base64 as secrecy.
Question 753
The team evaluates “Lockfile source control” for a requirement to share repeatable plugin selections with a development team. Which observed behavior belongs to that mechanism rather than a different Terraform feature?
- A version requirement such as >= 5.0.0 allows matching later versions but does not cap major-version upgrades.
- A constraint such as < 6.0.0 prevents selection of versions that reach the excluded release boundary.
- Checking .terraform.lock.hcl into version control preserves provider version selections and integrity hashes across workstations.
- The providers lock subcommand updates dependency lock information, including hashes for specified target operating-system platforms.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to share repeatable plugin selections with a development team, so it produces the behavior described. In contrast, a lower-bound provider constraint serves a different goal: allow provider releases no older than a tested minimum, not share repeatable plugin selections with a development team.
Incorrect Answers
A:The description applies to a lower-bound provider constraint when an engineer needs to allow provider releases no older than a tested minimum; the named lockfile source control instead handles the requirement to share repeatable plugin selections with a development team, so this behavior does not describe Lockfile source control in the situation named.
B:The description applies to an upper-bound provider constraint when an engineer needs to avoid using provider versions from a newer unsupported major release; the named lockfile source control instead handles the requirement to share repeatable plugin selections with a development team, so this behavior does not describe Lockfile source control in the situation named.
D:The description applies to terraform providers lock when an engineer needs to populate provider package checksums for selected platforms; the named lockfile source control instead handles the requirement to share repeatable plugin selections with a development team, so this behavior does not describe Lockfile source control in the situation named.
Question 754
A runbook lists “Apply with -var” for the task to override a declared root-module input value for a particular run. Which technical effect should its description include?
- The auto-approve option allows the automatically created plan to proceed without interactive confirmation, so pipeline safeguards matter.
- For a normal fresh apply, Terraform plans with current provider observations unless refresh is explicitly disabled; saved plan behavior differs.
- Root output blocks expose values Terraform calculates from the applied resource graph; output display is not an access-control boundary.
- The -var option supplies a named input for the execution; it does not edit the variable declaration in code.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to override a declared root-module input value for a particular run, so it produces the behavior described. In contrast, terraform apply -auto-approve serves a different goal: suppress Terraform's normal approval prompt in a controlled pipeline, not override a declared root-module input value for a particular run.
Incorrect Answers
A:The description applies to terraform apply -auto-approve when an engineer needs to suppress Terraform's normal approval prompt in a controlled pipeline; the named apply with -var instead handles the requirement to override a declared root-module input value for a particular run, so this behavior does not describe Apply with -var in the situation named.
B:The description applies to refresh during apply planning when an engineer needs to avoid applying from stale remembered attributes after remote drift; the named apply with -var instead handles the requirement to override a declared root-module input value for a particular run, so this behavior does not describe Apply with -var in the situation named.
C:The description applies to post-apply outputs when an engineer needs to retrieve computed identifiers that can be used by deployment automation; the named apply with -var instead handles the requirement to override a declared root-module input value for a particular run, so this behavior does not describe Apply with -var in the situation named.
Question 755
A Terraform module author has a concrete implementation goal: identify a single managed object selected by a string key. What is the most appropriate Terraform mechanism?
- A module output reference
- A for_each instance address
- A local value reference
- each.value
Explanation
Correct Answer
B:Instances made from a map or string set have addresses such as aws_instance.web["blue"], rather than an integer count index; this directly meets the requirement to identify a single managed object selected by a string key. By comparison, a local value reference is intended to share one calculated expression among multiple resources in a module, which is a different task from identify a single managed object selected by a string key.
Incorrect Answers
A: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 identify a single managed object selected by a string key. These operations have different effects in the stated Terraform workflow.
C:The syntax local.NAME accesses a locally defined expression evaluated in the current module; this mechanism is useful when the job is to share one calculated expression among multiple resources in a module, whereas the current scenario requires the engineer to identify a single managed object selected by a string key. These operations have different effects in the stated Terraform workflow.
D:For a map-based for_each collection, each.value exposes the value associated with the current each.key; this mechanism is useful when the job is to read the per-instance map value when iterating with for_each, whereas the current scenario requires the engineer to identify a single managed object selected by a string key. These operations have different effects in the stated Terraform workflow.
Question 756
The team evaluates “HCP team permissions” for a requirement to grant operators different abilities to view, plan or apply workspace changes. Which observed behavior belongs to that mechanism rather than a different Terraform feature?
- HCP Terraform permissions differentiate viewing configuration and runs from authorized apply or administration operations.
- Variable sets let administrators manage common workspace variables centrally and scope them to intended workspaces or projects.
- Team access controls define which users may perform supported workspace operations rather than relying only on provider credentials.
- Sentinel policies can assess planned infrastructure and produce policy check outcomes before a run can apply when enforcement requires it.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to grant operators different abilities to view, plan or apply workspace changes, so it produces the behavior described. In contrast, organization variable sets serves a different goal: supply shared environment or Terraform input values across several workspaces, not grant operators different abilities to view, plan or apply workspace changes.
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 team permissions instead handles the requirement to grant operators different abilities to view, plan or apply workspace changes, so this behavior does not describe HCP team permissions in the situation named.
B:The description applies to organization variable sets when an engineer needs to supply shared environment or Terraform input values across several workspaces; the named HCP team permissions instead handles the requirement to grant operators different abilities to view, plan or apply workspace changes, so this behavior does not describe HCP team permissions in the situation named.
D:The description applies to sentinel policy enforcement when an engineer needs to evaluate organizational infrastructure rules during HCP Terraform runs; the named HCP team permissions instead handles the requirement to grant operators different abilities to view, plan or apply workspace changes, so this behavior does not describe HCP team permissions in the situation named.
Question 757
A change request asks an engineer to maintain dependencies for resources that have been removed from configuration. Which choice best implements the requested behavior?
- State-backed dependency links
- State locking
- State snapshots
- The state serial number
Explanation
Correct Answer
A:State can retain dependency information needed to correctly destroy objects no longer declared in configuration; this directly meets the requirement to maintain dependencies for resources that have been removed from configuration. By comparison, the state serial number is intended to understand how successive snapshots are ordered, which is a different task from maintain dependencies for resources that have been removed from configuration.
Incorrect Answers
B:A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes; this mechanism is useful when the job is to prevent concurrent state writers from overwriting each other's updates, whereas the current scenario requires the engineer to maintain dependencies for resources that have been removed from configuration. These operations have different effects in the stated Terraform workflow.
C:The state snapshot records managed instance data and metadata needed to plan future actions; this mechanism is useful when the job is to preserve Terraform's knowledge of managed infrastructure between CLI runs, whereas the current scenario requires the engineer to maintain dependencies for resources that have been removed from configuration. These operations have different effects in the stated Terraform workflow.
D:State metadata includes lineage and serial information that helps Terraform identify state history and updates; this mechanism is useful when the job is to understand how successive snapshots are ordered, whereas the current scenario requires the engineer to maintain dependencies for resources that have been removed from configuration. These operations have different effects in the stated Terraform workflow.
Question 758
A change request asks an engineer to extract a specific range of characters from a string. Which choice best implements the requested behavior?
- The file function
- The dynamic block
- The substr function
- The formatlist function
Explanation
Correct Answer
C:substr returns characters starting at an offset with the specified length rather than splitting on a delimiter; this directly meets the requirement to extract a specific range of characters from a string. By comparison, the formatlist function is intended to format each element of multiple lists using one common template, which is a different task from extract a specific range of characters from a string.
Incorrect Answers
A:file reads existing local text; it does not wait for a provisioner to create the file during apply; this mechanism is useful when the job is to read UTF-8 content already present in a local file during evaluation, whereas the current scenario requires the engineer to extract a specific range of characters from a string. 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 extract a specific range of characters from a string. These operations have different effects in the stated Terraform workflow.
D:formatlist applies its formatting string across list elements to produce a list of formatted strings; this mechanism is useful when the job is to format each element of multiple lists using one common template, whereas the current scenario requires the engineer to extract a specific range of characters from a string. These operations have different effects in the stated Terraform workflow.
Question 759
A runbook lists “toset conversion” for the task to deduplicate a collection of string identifiers for keyed iteration. Which technical effect should its description include?
- The count meta-argument uses an integer expression and creates zero-based numeric instance addresses.
- A resource's for_each meta-argument accepts maps or sets of strings; map keys appear in resource addresses.
- toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved.
- An unknown value represents future information and can propagate through expressions until a provider supplies the result.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to deduplicate a collection of string identifiers for keyed iteration, so it produces the behavior described. In contrast, for_each with a map serves a different goal: create instances using stable logical keys rather than shifting numeric indexes, not deduplicate a collection of string identifiers for keyed iteration.
Incorrect Answers
A:The description applies to count with a number when an engineer needs to create a specified number of similarly configured resource instances; the named toset conversion instead handles the requirement to deduplicate a collection of string identifiers for keyed iteration, so this behavior does not describe toset conversion in the situation named.
B:The description applies to for_each with a map when an engineer needs to create instances using stable logical keys rather than shifting numeric indexes; the named toset conversion instead handles the requirement to deduplicate a collection of string identifiers for keyed iteration, so this behavior does not describe toset conversion in the situation named.
D:The description applies to an unknown plan-time value when an engineer needs to identify a computed attribute that Terraform cannot determine until apply; the named toset conversion instead handles the requirement to deduplicate a collection of string identifiers for keyed iteration, so this behavior does not describe toset conversion in the situation named.
Question 760
A collaboration and governance review requires a way to override or tailor values used by one particular stack. Which Terraform approach most directly fulfills that request?
- Workspace-specific variables
- Distinct production and staging workspaces
- Project membership changes
- Environment promotion via workspaces
Explanation
Correct Answer
A:Workspace settings store variables for that workspace's execution; global sets should not replace environment-specific data blindly; this directly meets the requirement to override or tailor values used by one particular stack. By comparison, distinct production and staging workspaces is intended to isolate state and runs for two deployment environments, which is a different task from override or tailor values used by one particular stack.
Incorrect Answers
B:Each HCP Terraform workspace has its own state and run configuration so changes in one do not automatically update the other; this mechanism is useful when the job is to isolate state and runs for two deployment environments, whereas the current scenario requires the engineer to override or tailor values used by one particular stack. These operations have different effects in the stated Terraform workflow.
C: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 override or tailor values used by one particular stack. These operations have different effects in the stated Terraform workflow.
D:Workspaces can reference separate branches or release controls while retaining isolated state for each environment; this mechanism is useful when the job is to use a reviewed configuration revision across separate testing and production states, whereas the current scenario requires the engineer to override or tailor values used by one particular stack. These operations have different effects in the stated Terraform workflow.