Question 120
An engineer intends to avoid assuming a local calculation is automatically visible in a parent module and is reviewing “A local value confined to its module”. What consequence follows from using it as intended?
- Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value.
- An object type lets a module enforce named configuration fields instead of accepting many untyped values.
- A child module may validate its input variables using conditions and errors independent of the parent's variable definitions.
- A child output can be marked sensitive, but its underlying value may still reside in state unless it uses permitted ephemeral handling.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to avoid assuming a local calculation is automatically visible in a parent module, so it produces the behavior described. In contrast, variable validation inside a module serves a different goal: enforce a reusable module's own input contract, not avoid assuming a local calculation is automatically visible in a parent module.
Incorrect Answers
B:The description applies to input object variables when an engineer needs to pass a structured settings bundle into a reusable module; the named a local value confined to its module instead handles the requirement to avoid assuming a local calculation is automatically visible in a parent module, so this behavior does not describe A local value confined to its module in the situation named.
C:The description applies to variable validation inside a module when an engineer needs to enforce a reusable module's own input contract; the named a local value confined to its module instead handles the requirement to avoid assuming a local calculation is automatically visible in a parent module, so this behavior does not describe A local value confined to its module in the situation named.
D:The description applies to child module outputs and sensitivity when an engineer needs to limit ordinary display of a sensitive result exported from a reusable module; the named a local value confined to its module instead handles the requirement to avoid assuming a local calculation is automatically visible in a parent module, so this behavior does not describe A local value confined to its module in the situation named.
Question 121
A Terraform runbook prescribes “Reviewing module upgrade changes” to avoid confusing provider plugin selection with reusable module source selection, but it does not meet the requirement. What does that step actually accomplish?
- A Git module's ?ref= tag or commit selects a repository revision instead of a registry module version constraint.
- 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.
- A module version ~> 2.1.0 permits 2.1.x releases but excludes 2.2.0 and later.
Explanation
Correct Answer
C:Reviewing module upgrade changes is used when an operator needs to control behavioral changes after moving to a new module release. Consequently, this choice cannot meet the separate requirement to avoid confusing provider plugin selection with reusable module source selection. The intended action would instead require Provider and module version separation.
Incorrect Answers
A:This behavior belongs to A Git tag pin for a module, which helps engineers select a specific VCS module release without using a registry version argument rather than satisfying the separate requirement to avoid confusing provider plugin selection with reusable module source selection. The attempted technique was Reviewing module upgrade changes; it would instead be used to control behavioral changes after moving to a new module release, not to produce the effect associated with A Git tag pin for a module.
B:That outcome belongs to Provider and module version separation, the mechanism that can avoid confusing provider plugin selection with reusable module source selection. The question concerns the engineer’s actual proposal, Reviewing module upgrade changes; it is directed at control behavioral changes after moving to a new module release, not that result.
D: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 avoid confusing provider plugin selection with reusable module source selection. The attempted technique was Reviewing module upgrade changes; it would instead be used to control behavioral changes after moving to a new module release, not to produce the effect associated with A pessimistic module version constraint.
Question 122
An infrastructure architecture discussion needs to see intended infrastructure changes without immediately creating them. Which feature or operation is the most direct match?
- Plan-before-apply reviews
- Environment parametrization
- Idempotent convergence
- Code review of infrastructure
- Consistent dependency management
Explanation
Correct Answer
A:A Terraform plan is a reviewable proposed set of actions; execution occurs only when an apply runs against the chosen plan; this directly meets the requirement to see intended infrastructure changes without immediately creating them. By comparison, environment parametrization is intended to deploy similarly structured stacks with environment-specific settings, which is a different task from see intended infrastructure changes without immediately creating them.
Incorrect Answers
B:Terraform input variables permit different values for capacity, names and endpoints without copying the entire resource definition; this mechanism is useful when the job is to deploy similarly structured stacks with environment-specific settings, whereas the current scenario requires the engineer to see intended infrastructure changes without immediately creating them. These operations have different effects in the stated Terraform workflow.
C:With no configuration or remote drift requiring action, a new plan normally proposes no infrastructure changes; this mechanism is useful when the job is to run unchanged configuration repeatedly without inventing new infrastructure updates, whereas the current scenario requires the engineer to see intended infrastructure changes without immediately creating them. These operations have different effects in the stated Terraform workflow.
D:A version-control pull request can expose infrastructure edits to peer review, policy checks and automated validation; this mechanism is useful when the job is to catch undesirable configuration changes before deployment, whereas the current scenario requires the engineer to see intended infrastructure changes without immediately creating them. These operations have different effects in the stated Terraform workflow.
E:Terraform infers many dependencies from references and applies graph ordering to create or modify related resources safely; this mechanism is useful when the job is to avoid hand-sequencing every resource operation, whereas the current scenario requires the engineer to see intended infrastructure changes without immediately creating them. These operations have different effects in the stated Terraform workflow.
Question 123
A team compares Terraform mechanisms for the goal to render a file containing template expressions with an object of variables. Which stated consequence belongs specifically to “The templatefile function”?
- replace searches a string for a matching substring or pattern and replaces matches with a new string.
- split divides a string at a delimiter and returns its constituent substrings.
- concat joins lists end to end and preserves their element ordering, including duplicate values.
- templatefile reads a template and evaluates placeholders using the supplied variable map.
- lower converts letters to lowercase and is often used in consistent name expressions.
Explanation
Correct Answer
D:The named mechanism is used when the objective is to render a file containing template expressions with an object of variables, so it produces the behavior described. In contrast, the replace function serves a different goal: substitute matching substrings within a value, not render a file containing template expressions with an object of variables.
Incorrect Answers
A:The description applies to the replace function when an engineer needs to substitute matching substrings within a value; the named the templatefile function instead handles the requirement to render a file containing template expressions with an object of variables, so this behavior does not describe The templatefile function in the situation named.
B:The description applies to the split function when an engineer needs to convert a delimiter-separated string into a list; the named the templatefile function instead handles the requirement to render a file containing template expressions with an object of variables, so this behavior does not describe The templatefile function in the situation named.
C:The description applies to the concat function when an engineer needs to append the elements of multiple lists into one sequence; the named the templatefile function instead handles the requirement to render a file containing template expressions with an object of variables, so this behavior does not describe The templatefile function in the situation named.
E:The description applies to the lower function when an engineer needs to normalize a string identifier to lowercase; the named the templatefile function instead handles the requirement to render a file containing template expressions with an object of variables, so this behavior does not describe The templatefile function in the situation named.
Question 124
An engineer intends to tie an approved infrastructure change to a reviewed commit and is reviewing “Keep configuration in version control”. What consequence follows from using it as intended?
- The plan stage compares desired configuration with observed resource state and shows the proposed operations for review.
- A revised configuration must be planned again because a prior plan does not automatically incorporate later edits.
- Committing root module files allows the team to relate plans and runs to a specific version of intended infrastructure.
- Following apply, output values and state inspection can reveal created identifiers while a new plan can test for remaining drift.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to tie an approved infrastructure change to a reviewed commit, so it produces the behavior described. In contrast, check infrastructure after apply serves a different goal: confirm deployed outputs and state match the expected result, not tie an approved infrastructure change to a reviewed commit.
Incorrect Answers
A:This describes Review a plan before apply and its job to inspect predicted create, update and delete actions prior to making changes, whereas the question asks about Keep configuration in version control. The latter is the mechanism used to tie an approved infrastructure change to a reviewed commit; the proposed effect belongs to a different Terraform feature.
B:The description applies to iterate after feedback when an engineer needs to modify and re-plan after a change request is rejected; the named keep configuration in version control instead handles the requirement to tie an approved infrastructure change to a reviewed commit, so this behavior does not describe Keep configuration in version control in the situation named.
D:The description applies to check infrastructure after apply when an engineer needs to confirm deployed outputs and state match the expected result; the named keep configuration in version control instead handles the requirement to tie an approved infrastructure change to a reviewed commit, so this behavior does not describe Keep configuration in version control in the situation named.
Question 125
An engineer troubleshooting a .tf configuration has a concrete implementation goal: make a child module's private resource attribute available to its caller. What is the most appropriate Terraform mechanism?
- A child module output block
- The -var option
- An environment variable prefixed TF_VAR_
- A variable default value
Explanation
Correct Answer
A:A child module must explicitly export an output for its parent to access it through module.CHILD.OUTPUT; this directly meets the requirement to make a child module's private resource attribute available to its caller. By comparison, a variable default value is intended to make a module input optional for callers using a common baseline, which is a different task from make a child module's private resource attribute available to its caller.
Incorrect Answers
B:Command-line -var assignments take high precedence and are useful for an explicit run-specific override; this mechanism is useful when the job is to supply a single variable assignment when invoking plan or apply, whereas the current scenario requires the engineer to make a child module's private resource attribute available to its caller. These operations have different effects in the stated Terraform workflow.
C:Terraform reads variables named TF_VAR_name as a source of input assignments, subject to input precedence rules; this mechanism is useful when the job is to provide root-module input values from an automated execution environment, whereas the current scenario requires the engineer to make a child module's private resource attribute available to its caller. These operations have different effects in the stated Terraform workflow.
D:The default argument supplies a value when the caller provides no other assignment for that variable; this mechanism is useful when the job is to make a module input optional for callers using a common baseline, whereas the current scenario requires the engineer to make a child module's private resource attribute available to its caller. These operations have different effects in the stated Terraform workflow.
Question 126
An engineer intends to use an existing DNS zone from a provider without taking ownership of the zone and is reviewing “Data sources as external lookups”. What consequence follows from using it as intended?
- References like aws_vpc.main.id use a managed resource's attributes and create an implicit dependency.
- The built-in terraform_data resource can represent input changes and trigger replacement behavior without managing a cloud API resource.
- A provider data source can resolve the zone ID for use in managed records while the zone itself remains outside that configuration's resource lifecycle.
- When a managed resource is absent from configuration but still tracked in state, normal planning proposes its destruction.
Explanation
Correct Answer
C:The named mechanism is used when the objective is to use an existing DNS zone from a provider without taking ownership of the zone, so it produces the behavior described. In contrast, the terraform_data resource serves a different goal: model a Terraform-managed lifecycle value without requiring an external service object, not use an existing DNS zone from a provider without taking ownership of the zone.
Incorrect Answers
A:The description applies to a resource attribute reference when an engineer needs to pass a newly managed object's computed identifier to a dependent resource; the named data sources as external lookups instead handles the requirement to use an existing DNS zone from a provider without taking ownership of the zone, so this behavior does not describe Data sources as external lookups in the situation named.
B:The description applies to the terraform_data resource when an engineer needs to model a Terraform-managed lifecycle value without requiring an external service object; the named data sources as external lookups instead handles the requirement to use an existing DNS zone from a provider without taking ownership of the zone, so this behavior does not describe Data sources as external lookups in the situation named.
D:The description applies to removing a resource declaration when an engineer needs to plan to delete a previously managed object that remains in state; the named data sources as external lookups instead handles the requirement to use an existing DNS zone from a provider without taking ownership of the zone, so this behavior does not describe Data sources as external lookups in the situation named.
Question 127
A team compares Terraform mechanisms for the goal to diagnose why destroy fails despite valid Terraform syntax. Which stated consequence belongs specifically to “Resource-specific delete restrictions”?
- Providers and remote APIs can reject deletion when dependencies, protection flags or permissions prevent removing the object.
- Reviewing a destroy plan is essential because a command can remove every managed instance within the relevant state scope.
- Destroy planning shows the deletion proposal without carrying out the deletion until apply.
- Terraform generally reverses dependency order when destroying managed resources so dependent objects are removed first.
Explanation
Correct Answer
A:The named mechanism is used when the objective is to diagnose why destroy fails despite valid Terraform syntax, so it produces the behavior described. In contrast, terraform plan -destroy serves a different goal: review an all-destroy plan before approving resource deletion, not diagnose why destroy fails despite valid Terraform syntax.
Incorrect Answers
B:The description applies to destroy plan risk review when an engineer needs to identify which root-module-managed resources will be affected before a cleanup; the named resource-specific delete restrictions instead handles the requirement to diagnose why destroy fails despite valid Terraform syntax, so this behavior does not describe Resource-specific delete restrictions in the situation named.
C:The description applies to terraform plan -destroy when an engineer needs to review an all-destroy plan before approving resource deletion; the named resource-specific delete restrictions instead handles the requirement to diagnose why destroy fails despite valid Terraform syntax, so this behavior does not describe Resource-specific delete restrictions in the situation named.
D:The description applies to dependency-aware deletion when an engineer needs to remove dependent resources before objects they rely on; the named resource-specific delete restrictions instead handles the requirement to diagnose why destroy fails despite valid Terraform syntax, so this behavior does not describe Resource-specific delete restrictions in the situation named.
Question 128
A configuration review for an application stack has a concrete implementation goal: both redact a transient secret and omit its value from state and plan files. What is the most appropriate Terraform mechanism?
- Environment-based provider credentials
- No secrets in version control
- Combining sensitive and ephemeral
- Vault short-lived credentials
Explanation
Correct Answer
C:A variable may declare sensitive = true and ephemeral = true together for runtime secret inputs consumed only in permitted contexts; this directly meets the requirement to both redact a transient secret and omit its value from state and plan files. By comparison, no secrets in version control is intended to keep API keys out of committed terraform.tfvars and .tf files, which is a different task from both redact a transient secret and omit its value from state and plan files.
Incorrect Answers
A:Providers can often authenticate through environment variables or identity integrations so credentials are absent from checked-in HCL; this mechanism is useful when the job is to avoid putting provider access tokens directly in configuration source, whereas the current scenario requires the engineer to both redact a transient secret and omit its value from state and plan files. These operations have different effects in the stated Terraform workflow.
B:Secrets inserted directly into tracked configuration can leak through repository history, regardless of later state redaction; this mechanism is useful when the job is to keep API keys out of committed terraform.tfvars and .tf files, whereas the current scenario requires the engineer to both redact a transient secret and omit its value from state and plan files. These operations have different effects in the stated Terraform workflow.
D:Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys; this mechanism is useful when the job is to limit the lifetime and scope of identities used by infrastructure automation, whereas the current scenario requires the engineer to both redact a transient secret and omit its value from state and plan files. These operations have different effects in the stated Terraform workflow.
Question 129
A configuration review for an application stack requires a way to recognize that an encoded password remains sensitive information. Which Terraform approach most directly fulfills that request?
- A write-only argument version field
- A write-only resource argument
- An ephemeral resource block
- ephemeral = true on a variable
- Not treating Base64 as secrecy
Explanation
Correct Answer
E:Base64 is reversible encoding; exposing encoded credentials in configuration or state still risks disclosure; this directly meets the requirement to recognize that an encoded password remains sensitive information. By comparison, a write-only resource argument is intended to pass a secret to a resource without persisting that argument's value, which is a different task from recognize that an encoded password remains sensitive information.
Incorrect Answers
A:Some write-only provider arguments expose an accompanying nonsecret version marker that triggers a new operation when incremented; this mechanism is useful when the job is to force an update when a write-only secret changes without exposing the secret itself, whereas the current scenario requires the engineer to recognize that an encoded password remains sensitive information. These operations have different effects in the stated Terraform workflow.
B:Provider-defined write-only arguments introduced in Terraform 1.11 are available only when the resource schema supports them; this mechanism is useful when the job is to pass a secret to a resource without persisting that argument's value, whereas the current scenario requires the engineer to recognize that an encoded password remains sensitive information. These operations have different effects in the stated Terraform workflow.
C:Provider-supported ephemeral resources exist only during an operation and can feed appropriate ephemeral consumers; this mechanism is useful when the job is to retrieve or generate temporary data that should not be persisted in Terraform state, whereas the current scenario requires the engineer to recognize that an encoded password remains sensitive information. These operations have different effects in the stated Terraform workflow.
D:Terraform 1.10+ ephemeral variables can flow only into allowed ephemeral contexts and are omitted from persisted artifacts; this mechanism is useful when the job is to use a short-lived runtime secret without saving its value in plan or state, whereas the current scenario requires the engineer to recognize that an encoded password remains sensitive information. These operations have different effects in the stated Terraform workflow.
Question 130
A Terraform change proposal names “Declarative resource configuration” to describe the desired infrastructure state instead of scripting every API step. Which outcome can reviewers attribute to that particular mechanism?
- Planning compares configuration with state and refreshed remote data to propose actions that reconcile differences.
- Terraform interprets resource declarations, constructs a dependency graph, and asks providers to reconcile real objects with that desired state.
- Terraform Core evaluates configuration while provider plugins implement the provider-specific API operations.
- Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations.
- IaC configuration provides repeatable definitions; variables and isolated state allow environments to differ without independently hand-building each object.
Explanation
Correct Answer
B:The named mechanism is used when the objective is to describe the desired infrastructure state instead of scripting every API step, so it produces the behavior described. In contrast, repeatable environment definition serves a different goal: recreate the same logical infrastructure design across test and production, not describe the desired infrastructure state instead of scripting every API step.
Incorrect Answers
A:The description applies to desired-state reconciliation when an engineer needs to identify changes between the declared configuration and managed infrastructure; the named declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration in the situation named.
C:The description applies to provider-mediated API operations when an engineer needs to manage infrastructure services through a shared declarative workflow; the named declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration in the situation named.
D:The description applies to a resource graph when an engineer needs to determine a safe sequence for creating objects with references between them; the named declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration in the situation named.
E:The description applies to repeatable environment definition when an engineer needs to recreate the same logical infrastructure design across test and production; the named declarative resource configuration instead handles the requirement to describe the desired infrastructure state instead of scripting every API step, so this behavior does not describe Declarative resource configuration in the situation named.