Question 400
A Terraform deployment has independent requirements: (1) fail a plan or apply when a prerequisite property is unacceptable; (2) prevent unauthorized operators from reading sensitive resource attributes. Which TWO mechanisms directly address these needs? Choose TWO.
- Remote state access controls
- A write-only argument version field
- Resource postcondition
- Resource precondition
- No secrets in version control
- terraform validate versus runtime assertions
Explanation
Correct Answers
A:Protecting state requires backend encryption, identity-based authorization and controlled access because state can store raw secret values; this meets the requirement to prevent unauthorized operators from reading sensitive resource attributes, while the other selected techniques address fail a plan or apply when a prerequisite property is unacceptable, which require their own distinct Terraform mechanisms.
D:A precondition inside lifecycle requires a true predicate before Terraform can continue the relevant resource operation; this meets the requirement to fail a plan or apply when a prerequisite property is unacceptable, while the other selected techniques address prevent unauthorized operators from reading sensitive resource attributes, which require their own distinct Terraform mechanisms.
Incorrect Answers
B:Some write-only provider arguments expose an accompanying nonsecret version marker that triggers a new operation when incremented; it addresses force an update when a write-only secret changes without exposing the secret itself, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and prevent unauthorized operators from reading sensitive resource attributes. The required combination involves Resource precondition and Remote state access controls, not the behavior of A write-only argument version field.
C:A postcondition evaluates a condition concerning resource results and blocks downstream use when its assertion fails; it addresses verify an invariant about a resource after reading or managing it, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and prevent unauthorized operators from reading sensitive resource attributes. The required combination involves Resource precondition and Remote state access controls, not the behavior of Resource postcondition.
E:Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; it addresses keep API keys out of committed terraform.tfvars and .tf files, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and prevent unauthorized operators from reading sensitive resource attributes. The required combination involves Resource precondition and Remote state access controls, not the behavior of No secrets in version control.
F:Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply; it addresses distinguish static configuration checks from conditions requiring actual resource values, but this delivery instead requires fail a plan or apply when a prerequisite property is unacceptable and prevent unauthorized operators from reading sensitive resource attributes. The required combination involves Resource precondition and Remote state access controls, not the behavior of terraform validate versus runtime assertions.
Question 401
An operations runbook for tracked objects requires a way to isolate provider-related diagnostic output during API troubleshooting. Which Terraform approach most directly fulfills that request?
- TF_LOG_PROVIDER
- TF_LOG_CORE
- TF_LOG=DEBUG
- TF_LOG=ERROR
Explanation
Correct Answer
A:The TF_LOG_PROVIDER setting controls provider log verbosity and can help locate failures involving provider communication; this directly meets the requirement to isolate provider-related diagnostic output during API troubleshooting. By comparison, TF_LOG_CORE is intended to focus verbose diagnostics on Terraform Core rather than all plugin activity, which is a different task from isolate provider-related diagnostic output during API troubleshooting.
Incorrect Answers
B:The TF_LOG_CORE variable can control log verbosity for Core messages independently of general logging; this mechanism is useful when the job is to focus verbose diagnostics on Terraform Core rather than all plugin activity, whereas the current scenario requires the engineer to isolate provider-related diagnostic output during API troubleshooting. These operations have different effects in the stated Terraform workflow.
C:Setting TF_LOG to DEBUG exposes useful troubleshooting messages without the full trace-level volume; this mechanism is useful when the job is to enable diagnostic output with lower verbosity than TRACE, whereas the current scenario requires the engineer to isolate provider-related diagnostic output during API troubleshooting. These operations have different effects in the stated Terraform workflow.
D:ERROR restricts diagnostic output to serious problems rather than normal trace-level activity; this mechanism is useful when the job is to focus logging on error-level diagnostics, whereas the current scenario requires the engineer to isolate provider-related diagnostic output during API troubleshooting. These operations have different effects in the stated Terraform workflow.
Question 402
During a design review, the requirement is to read command-line and tfvars input values for the root module. Which option should the engineer select?
- Nested module output propagation
- Different values for two module calls
- Root input variable scope
- Parent-to-child argument passing
Explanation
Correct Answer
C:Root variables accept runtime assignments, whereas a child module normally receives its inputs through the parent's module call; this directly meets the requirement to read command-line and tfvars input values for the root module. By comparison, different values for two module calls is intended to instantiate the same module with distinct environment inputs, which is a different task from read command-line and tfvars input values for the root module.
Incorrect Answers
A:Each module boundary needs an output passthrough because the root cannot directly access an arbitrary grandchild's private resources; this mechanism is useful when the job is to make a value from a grandchild module visible to the root module, whereas the current scenario requires the engineer to read command-line and tfvars input values for the root module. These operations have different effects in the stated Terraform workflow.
B: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 read command-line and tfvars input values for the root module. These operations have different effects in the stated Terraform workflow.
D:A module block explicitly sets the child's declared input variables using arguments of matching names; this mechanism is useful when the job is to set a reusable module's environment tag from the caller, whereas the current scenario requires the engineer to read command-line and tfvars input values for the root module. These operations have different effects in the stated Terraform workflow.
Question 403
A team proposes “Provider registry installation” to accept minor and patch updates without crossing the next major version. If they proceed with that technique, which result should they anticipate instead?
- The pessimistic constraint ~> 5.3 permits version 5.3 and later releases below 6.0.0.
- The -upgrade switch permits newer versions that satisfy constraints instead of preserving current installed or locked selections.
- Terraform uses provider source metadata and its configured installation methods to find and install the appropriate plugin binary.
- The .terraform.lock.hcl file records selected provider versions and checksums to constrain subsequent installations.
Explanation
Correct Answer
C:Provider registry installation is used when an operator needs to retrieve a published plugin from its declared registry source. Consequently, this choice cannot meet the separate requirement to accept minor and patch updates without crossing the next major version. The intended action would instead require A major-series compatible constraint.
Incorrect Answers
A:That outcome belongs to A major-series compatible constraint, the mechanism that can accept minor and patch updates without crossing the next major version. The question concerns the engineer’s actual proposal, Provider registry installation; it is directed at retrieve a published plugin from its declared registry source, not that result.
B:This behavior belongs to terraform init -upgrade, which helps engineers intentionally reconsider previously locked provider and module selections rather than satisfying the separate requirement to accept minor and patch updates without crossing the next major version. The attempted technique was Provider registry installation; it would instead be used to retrieve a published plugin from its declared registry source, not to produce the effect associated with terraform init -upgrade.
D:This behavior belongs to The dependency lock file, which helps engineers reproduce previously selected provider package versions on other machines rather than satisfying the separate requirement to accept minor and patch updates without crossing the next major version. The attempted technique was Provider registry installation; it would instead be used to retrieve a published plugin from its declared registry source, not to produce the effect associated with The dependency lock file.
Question 404
A runbook lists “Avoiding index churn with for_each” for the task to preserve instance identity when a middle collection item is removed. Which technical effect should its description include?
- The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts.
- The map(string) type models uniform values accessed by key rather than by positional index.
- The bool primitive type represents logical truth values used in conditionals and comparisons.
- Keyed for_each instances use stable identifiers, whereas count indexes can shift when list elements are deleted.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to preserve instance identity when a middle collection item is removed, so it produces the behavior described. In contrast, a bool variable type serves a different goal: limit a feature toggle to true or false values, not preserve instance identity when a middle collection item is removed.
Incorrect Answers
A:The description applies to the any type constraint when an engineer needs to accept values without imposing a specific static input shape; the named avoiding index churn with for_each instead handles the requirement to preserve instance identity when a middle collection item is removed, so this behavior does not describe Avoiding index churn with for_each in the situation named.
B:The description applies to a map of strings type when an engineer needs to associate arbitrary string keys with string values; the named avoiding index churn with for_each instead handles the requirement to preserve instance identity when a middle collection item is removed, so this behavior does not describe Avoiding index churn with for_each in the situation named.
C:The description applies to a bool variable type when an engineer needs to limit a feature toggle to true or false values; the named avoiding index churn with for_each instead handles the requirement to preserve instance identity when a middle collection item is removed, so this behavior does not describe Avoiding index churn with for_each in the situation named.
Question 405
During a design review, the requirement is to expose a chosen internal attribute to the calling parent module. Which option should the engineer select?
- A child module output
- Root input variable scope
- Input object variables
- A variable default inside a child
Explanation
Correct Answer
A:The output block defines a published module interface; the parent reads the value as module.NAME.OUTPUT; this directly meets the requirement to expose a chosen internal attribute to the calling parent module. By comparison, root input variable scope is intended to read command-line and tfvars input values for the root module, which is a different task from expose a chosen internal attribute to the calling parent module.
Incorrect Answers
B:Root variables accept runtime assignments, whereas a child module normally receives its inputs through the parent's module call; this mechanism is useful when the job is to read command-line and tfvars input values for the root module, whereas the current scenario requires the engineer to expose a chosen internal attribute to the calling parent module. These operations have different effects in the stated Terraform workflow.
C:An object type lets a module enforce named configuration fields instead of accepting many untyped values; this mechanism is useful when the job is to pass a structured settings bundle into a reusable module, whereas the current scenario requires the engineer to expose a chosen internal attribute to the calling parent module. These operations have different effects in the stated Terraform workflow.
D:A default inside the child variable declaration applies when the caller omits that module argument; this mechanism is useful when the job is to make a module input optional when callers do not require customization, whereas the current scenario requires the engineer to expose a chosen internal attribute to the calling parent module. These operations have different effects in the stated Terraform workflow.
Question 406
A Terraform module author needs to choose the first nonempty list from several candidates. Which feature or operation is the most direct match?
- The jsondecode function
- The upper function
- The replace function
- The coalescelist function
Explanation
Correct Answer
D:coalescelist evaluates list arguments and returns the first with at least one element; this directly meets the requirement to choose the first nonempty list from several candidates. By comparison, the jsondecode function is intended to parse a JSON document string into Terraform values, which is a different task from choose the first nonempty list from several candidates.
Incorrect Answers
A:jsondecode converts JSON input into native maps, objects, lists or primitives used in expressions; this mechanism is useful when the job is to parse a JSON document string into Terraform values, whereas the current scenario requires the engineer to choose the first nonempty list from several candidates. These operations have different effects in the stated Terraform workflow.
B:upper transforms the letters of a string into uppercase without changing its underlying Terraform type; this mechanism is useful when the job is to convert an environment label to uppercase, whereas the current scenario requires the engineer to choose the first nonempty list from several candidates. These operations have different effects in the stated Terraform workflow.
C:replace searches a string for a matching substring or pattern and replaces matches with a new string; this mechanism is useful when the job is to substitute matching substrings within a value, whereas the current scenario requires the engineer to choose the first nonempty list from several candidates. These operations have different effects in the stated Terraform workflow.
Question 407
An operations handover for an existing Terraform deployment requires a way to apply Terraform's canonical formatting to local .tf source files. Which Terraform approach most directly fulfills that request?
- terraform fmt
- terraform fmt -diff
- Formatting versus validation
- terraform fmt -recursive
Explanation
Correct Answer
A:The fmt command rewrites HCL source according to Terraform's formatting conventions without provisioning resources; this directly meets the requirement to apply Terraform's canonical formatting to local .tf source files. By comparison, terraform fmt -diff is intended to show which HCL formatting edits Terraform would make, which is a different task from apply Terraform's canonical formatting to local .tf source files.
Incorrect Answers
B:The diff switch displays textual differences between current file formatting and the canonical formatting result; this mechanism is useful when the job is to show which HCL formatting edits Terraform would make, whereas the current scenario requires the engineer to apply Terraform's canonical formatting to local .tf source files. These operations have different effects in the stated Terraform workflow.
C:terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; this mechanism is useful when the job is to distinguish style-only issues from Terraform type and schema errors, whereas the current scenario requires the engineer to apply Terraform's canonical formatting to local .tf source files. These operations have different effects in the stated Terraform workflow.
D:The recursive switch extends formatting into subdirectories rather than limiting the operation to the current directory; this mechanism is useful when the job is to format Terraform files in nested directories under a module tree, whereas the current scenario requires the engineer to apply Terraform's canonical formatting to local .tf source files. These operations have different effects in the stated Terraform workflow.
Question 408
An output block uses the value expression compact(["a", "", "b"]). Assuming only the literal data shown, which result should be expected?
- ["b", "a"]
- ["a", "b"] (list with two retained members)
- ["a"]
- ["a", "", "b"] (original three-member list)
Explanation
Correct Answer
B:The expression compact(["a", "", "b"]) evaluates to ["a", "b"] because compact removes the empty string while retaining the two nonempty strings in order. This is Terraform's direct evaluation of the supplied literal arguments in compact(["a", "", "b"]), not an external provider lookup.
Incorrect Answers
A:Compact does not reverse the order of the remaining items. In this specific evaluation, compact removes the empty string while retaining the two nonempty strings in order, which rules out the proposed alternative.
C:The nonempty b member must also remain in the output. HCL evaluates compact(["a", "", "b"]) using the supplied arguments: compact removes the empty string while retaining the two nonempty strings in order; the listed result is therefore incorrect.
D:An empty string is specifically filtered out by compact. For compact(["a", "", "b"]), compact removes the empty string while retaining the two nonempty strings in order; consequently this candidate is not the value Terraform computes.
Question 409
A remote-state operations review needs to understand why Terraform tries to reset a manually edited resource attribute. Which feature or operation is the most direct match?
- terraform state rm
- terraform state mv
- Avoid direct state JSON editing
- A refreshed changed resource
Explanation
Correct Answer
D:Configuration still describes the preferred value, so normal planning can propose undoing an out-of-band modification unless ignored; this directly meets the requirement to understand why Terraform tries to reset a manually edited resource attribute. By comparison, terraform state rm is intended to forget a managed object without destroying the corresponding real infrastructure, which is a different task from understand why Terraform tries to reset a manually edited resource attribute.
Incorrect Answers
A:The state rm command removes the association so the remote object remains but is no longer tracked by that state; this mechanism is useful when the job is to forget a managed object without destroying the corresponding real infrastructure, whereas the current scenario requires the engineer to understand why Terraform tries to reset a manually edited resource attribute. These operations have different effects in the stated Terraform workflow.
B:The state mv command reassigns a managed resource's address without contacting the provider to destroy the object; this mechanism is useful when the job is to change the address of a tracked object directly within state, whereas the current scenario requires the engineer to understand why Terraform tries to reset a manually edited resource attribute. These operations have different effects in the stated Terraform workflow.
C:Manual state-file changes can break address mappings or serial consistency; commands such as state mv and moved blocks are safer; this mechanism is useful when the job is to make state changes through supported Terraform commands and declarative refactors, whereas the current scenario requires the engineer to understand why Terraform tries to reset a manually edited resource attribute. These operations have different effects in the stated Terraform workflow.
Question 410
An engineer intends to read current attributes of managed remote objects during planning and is reviewing “Provider data refresh”. What consequence follows from using it as intended?
- Terraform generally selects the default provider matching a resource's type prefix unless an alternate configuration is specified.
- Terraform Core handles language evaluation, planning and state orchestration while provider plugins execute service-specific operations.
- The namespace portion of a source address separates provider publishers in the registry.
- A provider configuration with alias defines a named alternate that resources or modules can explicitly select.
- Providers retrieve object details so Terraform can compare observed infrastructure against desired configuration and prior state.
Explanation
Correct Answer
E:The named mechanism is used when the objective is to read current attributes of managed remote objects during planning, so it produces the behavior described. In contrast, Terraform Core serves a different goal: evaluate HCL expressions and calculate a resource dependency graph, not read current attributes of managed remote objects during planning.
Incorrect Answers
A:The description applies to implicit provider selection when an engineer needs to use the default provider configuration for a resource type; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.
B:The description applies to Terraform Core when an engineer needs to evaluate HCL expressions and calculate a resource dependency graph; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.
C:The description applies to the provider registry namespace when an engineer needs to identify the publisher when providers share a type name; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.
D:The description applies to provider aliases when an engineer needs to configure two connections to the same service for different regions or accounts; the named provider data refresh instead handles the requirement to read current attributes of managed remote objects during planning, so this behavior does not describe Provider data refresh in the situation named.