Question 420
The team evaluates “terraform output -json” for a requirement to retrieve root outputs for integration with another program. Which observed behavior belongs to that mechanism rather than a different Terraform feature?
- Command-line -var assignments take high precedence and are useful for an explicit run-specific override.
- The module block assigns arguments corresponding to input variables declared in the child; variables are scoped to modules.
- The nullable argument on a variable declaration determines whether null is a valid override of its normal value.
- The JSON output mode serializes output values and metadata for automation; it can expose sensitive values and must be protected.
- The -var-file flag explicitly selects a variables file rather than relying on auto-loaded naming conventions.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to retrieve root outputs for integration with another program, so it produces the behavior described. In contrast, the -var-file option serves a different goal: load a nonstandard variable file selected for one environment, not retrieve root outputs for integration with another program.
Incorrect Answers
A:The description applies to the -var option when an engineer needs to supply a single variable assignment when invoking plan or apply; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.
B:The description applies to passing module inputs explicitly when an engineer needs to configure a child module with parent-provided values; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.
C:The description applies to a nullable variable setting when an engineer needs to control whether a caller can intentionally pass null to an input variable; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.
E:The description applies to the -var-file option when an engineer needs to load a nonstandard variable file selected for one environment; the named terraform output -json instead handles the requirement to retrieve root outputs for integration with another program, so this behavior does not describe terraform output -json in the situation named.
Question 421
An engineer proposes “A provider mirror” to allow provider releases no older than a tested minimum. Which outcome does the proposed technique actually provide?
- A version requirement such as >= 5.0.0 allows matching later versions but does not cap major-version upgrades.
- A CLI provider_installation configuration can direct provider package discovery to a network or filesystem mirror.
- The .terraform.lock.hcl file records selected provider versions and checksums to constrain subsequent installations.
- The providers lock subcommand updates dependency lock information, including hashes for specified target operating-system platforms.
Explanation
Correct Answer
B:A provider mirror is used when an operator needs to install approved plugins from an internal distribution location. Consequently, this choice cannot meet the separate requirement to allow provider releases no older than a tested minimum. The intended action would instead require A lower-bound provider constraint.
Incorrect Answers
A:That outcome belongs to A lower-bound provider constraint, the mechanism that can allow provider releases no older than a tested minimum. The question concerns the engineer’s actual proposal, A provider mirror; it is directed at install approved plugins from an internal distribution location, not that result.
C: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 allow provider releases no older than a tested minimum. The attempted technique was A provider mirror; it would instead be used to install approved plugins from an internal distribution location, not to produce the effect associated with The dependency lock file.
D:This behavior belongs to terraform providers lock, which helps engineers populate provider package checksums for selected platforms rather than satisfying the separate requirement to allow provider releases no older than a tested minimum. The attempted technique was A provider mirror; it would instead be used to install approved plugins from an internal distribution location, not to produce the effect associated with terraform providers lock.
Question 422
A state migration and recovery exercise needs to integrate Terraform CLI with an HCP organization and workspace. Which feature or operation is the most direct match?
- Backend credentials from the environment
- An HCP Terraform cloud block
- Partial backend configuration
- Remote backend support for workspaces
Explanation
Correct Answer
B:The terraform cloud block connects configuration to HCP Terraform, and cannot coexist with a standard backend block in the same configuration; this directly meets the requirement to integrate Terraform CLI with an HCP organization and workspace. By comparison, remote backend support for workspaces is intended to use multiple logical state namespaces when the backend implementation supports it, which is a different task from integrate Terraform CLI with an HCP organization and workspace.
Incorrect Answers
A:Supported backends can discover authentication from environment settings or identity mechanisms rather than inline key literals; this mechanism is useful when the job is to avoid embedding cloud backend access keys into tracked Terraform source, whereas the current scenario requires the engineer to integrate Terraform CLI with an HCP organization and workspace. These operations have different effects in the stated Terraform workflow.
C:Backend config arguments supplied at init time fill required values, but sensitive content can still be cached in local metadata or plans; this mechanism is useful when the job is to provide environment-specific backend details at initialization rather than hard-coding them, whereas the current scenario requires the engineer to integrate Terraform CLI with an HCP organization and workspace. These operations have different effects in the stated Terraform workflow.
D:Workspace support depends on the selected backend, and each workspace tracks its own state snapshot; this mechanism is useful when the job is to use multiple logical state namespaces when the backend implementation supports it, whereas the current scenario requires the engineer to integrate Terraform CLI with an HCP organization and workspace. These operations have different effects in the stated Terraform workflow.
Question 423
During a design review, the requirement is to associate configuration, variables, state and runs for one managed infrastructure scope. Which option should the engineer select?
- An HCP Terraform workspace
- HCP Terraform remote state
- An API-driven workspace
- The HCP run queue
Explanation
Correct Answer
A:An HCP Terraform workspace organizes its own state and runs, providing a collaboration boundary for Terraform execution; this directly meets the requirement to associate configuration, variables, state and runs for one managed infrastructure scope. By comparison, an API-driven workspace is intended to start Terraform runs through an external automation integration, which is a different task from associate configuration, variables, state and runs for one managed infrastructure scope.
Incorrect Answers
B:HCP Terraform maintains workspace state versions and supports collaboration without exposing a machine-local canonical state file; this mechanism is useful when the job is to store Terraform state under managed service controls rather than a local file, whereas the current scenario requires the engineer to associate configuration, variables, state and runs for one managed infrastructure scope. These operations have different effects in the stated Terraform workflow.
C:HCP Terraform APIs can upload configuration versions and orchestrate runs programmatically; this mechanism is useful when the job is to start Terraform runs through an external automation integration, whereas the current scenario requires the engineer to associate configuration, variables, state and runs for one managed infrastructure scope. These operations have different effects in the stated Terraform workflow.
D:Queued runs and workspace run management help serialize changes and avoid competing applies to one state; this mechanism is useful when the job is to coordinate multiple requested changes against the same workspace state, whereas the current scenario requires the engineer to associate configuration, variables, state and runs for one managed infrastructure scope. These operations have different effects in the stated Terraform workflow.
Question 424
In a Terraform configuration, what value does the HCL expression length(toset(["a", "b", "a"])) evaluate to?
- 2
- 3
- 4
- 1
Explanation
Correct Answer
A:The expression length(toset(["a", "b", "a"])) evaluates to 2 because toset removes the repeated a before length counts the remaining unique members. This is Terraform's direct evaluation of the supplied literal arguments in length(toset(["a", "b", "a"])), not an external provider lookup.
Incorrect Answers
B:That counts the source list before set deduplication. For length(toset(["a", "b", "a"])), toset removes the repeated a before length counts the remaining unique members; consequently this candidate is not the value Terraform computes.
C:No fourth unique value is introduced by the conversion. HCL evaluates length(toset(["a", "b", "a"])) using the supplied arguments: toset removes the repeated a before length counts the remaining unique members; the listed result is therefore incorrect.
D:Both a and b remain unique members after conversion. In this specific evaluation, toset removes the repeated a before length counts the remaining unique members, which rules out the proposed alternative.
Question 425
An engineer proposes “Provider and module version separation” to select a supported module release range from the registry. Which outcome does the proposed technique actually provide?
- A module version ~> 2.1.0 permits 2.1.x releases but excludes 2.2.0 and later.
- Provider versions are constrained in required_providers and locked in .terraform.lock.hcl; registry modules use their module block version arguments.
- A module upgrade can change resource definitions and outputs, so the consumer should inspect the new source and resulting Terraform plan.
- The module version argument accepts version constraints for registry sources and Terraform resolves compatible published releases during init.
Explanation
Correct Answer
B:Provider and module version separation is used when an operator needs to avoid confusing provider plugin selection with reusable module source selection. Consequently, this choice cannot meet the separate requirement to select a supported module release range from the registry. The intended action would instead require A registry module version constraint.
Incorrect Answers
A:This behavior belongs to A pessimistic module version constraint, which helps engineers allow compatible patch updates within a module's minor release series rather than satisfying the separate requirement to select a supported module release range from the registry. The attempted technique was Provider and module version separation; it would instead be used to avoid confusing provider plugin selection with reusable module source selection, not to produce the effect associated with A pessimistic module version constraint.
C:This behavior belongs to Reviewing module upgrade changes, which helps engineers control behavioral changes after moving to a new module release rather than satisfying the separate requirement to select a supported module release range from the registry. The attempted technique was Provider and module version separation; it would instead be used to avoid confusing provider plugin selection with reusable module source selection, not to produce the effect associated with Reviewing module upgrade changes.
D:That outcome belongs to A registry module version constraint, the mechanism that can select a supported module release range from the registry. The question concerns the engineer’s actual proposal, Provider and module version separation; it is directed at avoid confusing provider plugin selection with reusable module source selection, not that result.
Question 426
An engineer intends to populate provider package checksums for selected platforms and is reviewing “terraform providers lock”. What consequence follows from using it as intended?
- The pessimistic constraint ~> 5.3.0 admits versions at least 5.3.0 but below 5.4.0.
- A version requirement such as >= 5.0.0 allows matching later versions but does not cap major-version upgrades.
- The providers lock subcommand updates dependency lock information, including hashes for specified target operating-system platforms.
- The -upgrade switch permits newer versions that satisfy constraints instead of preserving current installed or locked selections.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to populate provider package checksums for selected platforms, so it produces the behavior described. In contrast, a compatible provider constraint serves a different goal: accept patch updates within a chosen minor line, not populate provider package checksums for selected platforms.
Incorrect Answers
A:The description applies to a compatible provider constraint when an engineer needs to accept patch updates within a chosen minor line; the named terraform providers lock instead handles the requirement to populate provider package checksums for selected platforms, so this behavior does not describe terraform providers lock in the situation named.
B: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 terraform providers lock instead handles the requirement to populate provider package checksums for selected platforms, so this behavior does not describe terraform providers lock in the situation named.
D:The description applies to terraform init -upgrade when an engineer needs to intentionally reconsider previously locked provider and module selections; the named terraform providers lock instead handles the requirement to populate provider package checksums for selected platforms, so this behavior does not describe terraform providers lock in the situation named.
Question 427
A team compares Terraform mechanisms for the goal to configure a child module with parent-provided values. Which stated consequence belongs specifically to “Passing module inputs explicitly”?
- The JSON output mode serializes output values and metadata for automation; it can expose sensitive values and must be protected.
- The module block assigns arguments corresponding to input variables declared in the child; variables are scoped to modules.
- The nullable argument on a variable declaration determines whether null is a valid override of its normal value.
- Terraform automatically discovers terraform.tfvars and terraform.tfvars.json in the working directory.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to configure a child module with parent-provided values, so it produces the behavior described. In contrast, a terraform.tfvars file serves a different goal: load a conventional set of root-module variable assignments automatically, not configure a child module with parent-provided values.
Incorrect Answers
A:The description applies to terraform output -json when an engineer needs to retrieve root outputs for integration with another program; the named passing module inputs explicitly instead handles the requirement to configure a child module with parent-provided values, so this behavior does not describe Passing module inputs explicitly in the situation named.
C:The description applies to a nullable variable setting when an engineer needs to control whether a caller can intentionally pass null to an input variable; the named passing module inputs explicitly instead handles the requirement to configure a child module with parent-provided values, so this behavior does not describe Passing module inputs explicitly in the situation named.
D:The description applies to a terraform.tfvars file when an engineer needs to load a conventional set of root-module variable assignments automatically; the named passing module inputs explicitly instead handles the requirement to configure a child module with parent-provided values, so this behavior does not describe Passing module inputs explicitly in the situation named.
Question 428
Reviewers reject “Init after changing state storage” as a way to declare the backend type and settings used to store root-module state. Which actual behavior explains why the proposal is unsuitable?
- A terraform { backend "TYPE" {} } declaration selects state storage; its settings are initialized separately from provider configuration.
- Supported backends can discover authentication from environment settings or identity mechanisms rather than inline key literals.
- Terraform detects changed backend settings and requires initialization with an explicit migration or reconfiguration choice.
- Encryption is controlled by the chosen backend service; Terraform's remote backend abstraction does not supply one universal encryption mechanism.
Explanation
Correct Answer
C:Init after changing state storage is used when an operator needs to adopt a new remote state destination after editing configuration. Consequently, this choice cannot meet the separate requirement to declare the backend type and settings used to store root-module state. The intended action would instead require A terraform backend block.
Incorrect Answers
A:That outcome belongs to A terraform backend block, the mechanism that can declare the backend type and settings used to store root-module state. The question concerns the engineer’s actual proposal, Init after changing state storage; it is directed at adopt a new remote state destination after editing configuration, not that result.
B:This behavior belongs to Backend credentials from the environment, which helps engineers avoid embedding cloud backend access keys into tracked Terraform source rather than satisfying the separate requirement to declare the backend type and settings used to store root-module state. The attempted technique was Init after changing state storage; it would instead be used to adopt a new remote state destination after editing configuration, not to produce the effect associated with Backend credentials from the environment.
D:This behavior belongs to Remote state encryption at rest, which helps engineers protect stored state contents from unauthorized storage-layer access rather than satisfying the separate requirement to declare the backend type and settings used to store root-module state. The attempted technique was Init after changing state storage; it would instead be used to adopt a new remote state destination after editing configuration, not to produce the effect associated with Remote state encryption at rest.
Question 429
A team compares Terraform mechanisms for the goal to understand why a computed attribute is unavailable in the preview. Which stated consequence belongs specifically to “An unknown value until apply”?
- Terraform may mark attributes as known after apply because a provider assigns their values only when creating or updating a real object.
- Detailed exit codes are 0 for no diff, 2 for a nonempty successful plan and 1 for an error.
- The -json flag emits a structured JSON representation suitable for inspection by automation, with careful handling of sensitive output.
- In conventional human-readable plans, + signifies that a managed resource is proposed for creation.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to understand why a computed attribute is unavailable in the preview, so it produces the behavior described. In contrast, a resource action marked plus serves a different goal: interpret the leading + symbol in Terraform's plan, not understand why a computed attribute is unavailable in the preview.
Incorrect Answers
B:The description applies to terraform plan -detailed-exitcode when an engineer needs to distinguish no changes from proposed changes in automation; the named an unknown value until apply instead handles the requirement to understand why a computed attribute is unavailable in the preview, so this behavior does not describe An unknown value until apply in the situation named.
C:The description applies to terraform show -json on a plan when an engineer needs to feed a saved plan to a machine-readable analysis tool; the named an unknown value until apply instead handles the requirement to understand why a computed attribute is unavailable in the preview, so this behavior does not describe An unknown value until apply in the situation named.
D:The description applies to a resource action marked plus when an engineer needs to interpret the leading + symbol in Terraform's plan; the named an unknown value until apply instead handles the requirement to understand why a computed attribute is unavailable in the preview, so this behavior does not describe An unknown value until apply in the situation named.
Question 430
A Terraform change proposal names “Variable validation during planning” to reject a supplied input value that violates a custom validation rule. Which outcome can reviewers attribute to that particular mechanism?
- 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.
- Provider schemas and Terraform's type checking can make validate fail before an apply is attempted.
- The fmt -check option exits with a failure status when source files would need formatting changes rather than altering them.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to reject a supplied input value that violates a custom validation rule, so it produces the behavior described. In contrast, a type mismatch diagnosis serves a different goal: catch an argument whose expression does not match the provider schema, not reject a supplied input value that violates a custom validation rule.
Incorrect Answers
A:The description applies to terraform test when an engineer needs to run declarative module tests instead of only checking syntax; the named variable validation during planning instead handles the requirement to reject a supplied input value that violates a custom validation rule, so this behavior does not describe Variable validation during planning in the situation named.
C:The description applies to a type mismatch diagnosis when an engineer needs to catch an argument whose expression does not match the provider schema; the named variable validation during planning instead handles the requirement to reject a supplied input value that violates a custom validation rule, so this behavior does not describe Variable validation during planning in the situation named.
D:The description applies to terraform fmt -check when an engineer needs to verify formatting without rewriting the files in a CI job; the named variable validation during planning instead handles the requirement to reject a supplied input value that violates a custom validation rule, so this behavior does not describe Variable validation during planning in the situation named.