100% Latest & Updated HashiCorp Terraform Associate 004 Practice Test Questions, Exam Dumps & Verified Answers!
30 Days Free Updates, Instant Download!
Question 280
A Terraform platform team is coordinating 3 independent decisions. Workstream A: A pipeline produces a list of service names with inconsistent letter casing and needs normalized DNS labels. and Workstream B: A company intentionally altered remote settings and wants Terraform state to reflect the real objects without proposing configuration-driven remediation yet. and Workstream C: An infrastructure release creates AWS resources in two regions, with a disaster-recovery instance explicitly assigned to the second region. Select exactly 3 actions, one addressing each distinct workstream.
- Run a refresh-only plan, review its state changes, and apply refresh-only if the update is appropriate.
- Configure default and aliased AWS providers and assign the disaster-recovery resource to the alias.
- Declare the input in the child and supply environment = var.environment in the root's module call.
- Select the correct workspace/backend state and run terraform destroy only after reviewing its destruction plan.
- Use a for expression with lower() to derive normalized names from the input collection.
- Use a valid git:: module source and an appropriate immutable reviewed ref, with the necessary credentials.
Explanation
Correct Answers
A:For the workstream in which a company intentionally altered remote settings and wants Terraform state to reflect the real objects without proposing configuration-driven remediation yet, use this action: Run a refresh-only plan, review its state changes, and apply refresh-only if the update is appropriate. Refresh-only updates Terraform's recorded understanding rather than enforcing desired configuration. Verify: State and root outputs synchronize with observed remote data without changing the cloud object itself. Limitation: Refresh-only does not make configuration match reality or prevent later normal plans from proposing remediation.
B:For the workstream in which an infrastructure release creates AWS resources in two regions, with a disaster-recovery instance explicitly assigned to the second region, use this action: Configure default and aliased AWS providers and assign the disaster-recovery resource to the alias. Multiple provider configurations allow one plugin to manage distinct endpoints or regions. Verify: The plan identifies primary and recovery resources using the intended regional provider instances. Limitation: Resources cannot infer an alias from a tag or name; it must be referenced by Terraform configuration.
E:For the workstream in which a pipeline produces a list of service names with inconsistent letter casing and needs normalized DNS labels, use this action: Use a for expression with lower() to derive normalized names from the input collection. For expressions transform Terraform values during evaluation; functions supply operations such as case conversion. Verify: The computed list contains each intended service name normalized consistently. Limitation: Collision after normalization must be handled explicitly; lower() alone does not ensure uniqueness.
Incorrect Answers
C:This action is appropriate instead for a different, unlisted requirement: A child module uses var.environment but the root module declares an environment variable of the same name and passes nothing. It would be checked by: Planning resolves the child's environment value from the explicit module call. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
D:This action is appropriate instead for a different, unlisted requirement: A disposable integration environment must be removed without unintentionally deleting shared infrastructure in another state. It would be checked by: The destruction plan lists the managed objects targeted in that state, not arbitrary cloud resources. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
F:This action is appropriate instead for a different, unlisted requirement: An infrastructure module is checked out from a private Git repository at a reviewed branch or tag, not published as a registry module. It would be checked by: Initialization checks out the intended Git module revision and the plan uses its configuration. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
Question 281
An infrastructure team faces this specific situation: A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. Which Terraform action most directly satisfies the requirement?
- Define a root output whose value references the managed load balancer's endpoint attribute.
- Pass values through appropriate .tfvars files or documented TF_VAR_name environment variables.
- Choose an appropriate set(number) input type for distinct port values.
- Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency.
Explanation
Correct Answer
D:For this case, the appropriate action is: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. Depends_on expresses ordering when Terraform cannot infer it from attribute references. Confirm it by checking: The dependency graph orders the attachment action before the dependent rule operation. Boundary: Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative.
Incorrect Answers
A:This is linked to a different situation: An operations team must surface a load balancer endpoint after apply so downstream jobs can consume it. There the relevant decision is: Define a root output whose value references the managed load balancer's endpoint attribute. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant decision is: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A deployment job must supply different nonsecret inputs for each pipeline run without editing source-controlled HCL. There the relevant decision is: Pass values through appropriate .tfvars files or documented TF_VAR_name environment variables. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant decision is: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: A security allowlist is an unordered set of unique ports and duplicate entries must not affect the configuration. There the relevant decision is: Choose an appropriate set(number) input type for distinct port values. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant decision is: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. It would therefore not resolve or assess the case as stated.
Question 282
A reviewer is confirming a change for the following use case: A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. The implementation follows this approach: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. Which observation or acceptance test most directly verifies the intended result?
- The first, second, and third output elements correspond to documented ordered subnet assignments.
- The dependency graph orders the attachment action before the dependent rule operation.
- An invalid condition causes a diagnostic and blocks the governed action.
- Inspect the chosen mechanism and verify secrets do not appear in plan/state artifacts where omission is required.
Explanation
Correct Answer
B:Acceptance evidence: The dependency graph orders the attachment action before the dependent rule operation. It validates the proposed action, add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency, because depends_on expresses ordering when Terraform cannot infer it from attribute references. Remaining limitation: Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative.
Incorrect Answers
A:This is linked to a different situation: A module emits an ordered list of three subnet IDs aligned with ordered availability zones and consumers depend on position. There the relevant acceptance is: The first, second, and third output elements correspond to documented ordered subnet assignments. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant acceptance is: The dependency graph orders the attachment action before the dependent rule operation. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: A team must verify a network policy's expected input range before taking an action that would violate the rule. There the relevant acceptance is: An invalid condition causes a diagnostic and blocks the governed action. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant acceptance is: The dependency graph orders the attachment action before the dependent rule operation. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: An application secret is supplied as a Terraform variable marked sensitive, and a teammate claims it cannot enter a saved state file. There the relevant acceptance is: Inspect the chosen mechanism and verify secrets do not appear in plan/state artifacts where omission is required. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant acceptance is: The dependency graph orders the attachment action before the dependent rule operation. It would therefore not resolve or assess the case as stated.
Question 283
Consider a proposed solution for this requirement: A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. The team plans to do the following: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. Which limitation or operational caveat must remain in the review?
- sensitive primarily redacts normal CLI display; it does not by itself exclude a value from state.
- Keys must exist and be stable; renaming a key may change addresses and induce replacement.
- Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative.
- A precondition only protects the invariant actually encoded in its expression.
Explanation
Correct Answer
C:The limitation is explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative. The proposed change is add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. Validate it by checking the dependency graph orders the attachment action before the dependent rule operation. depends_on expresses ordering when Terraform cannot infer it from attribute references.
Incorrect Answers
A:This is linked to a different situation: An application secret is supplied as a Terraform variable marked sensitive, and a teammate claims it cannot enter a saved state file. There the relevant limitation is: sensitive primarily redacts normal CLI display; it does not by itself exclude a value from state. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant limitation is: Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A module uses for_each on a map of regions and must output one subnet ID for the us-east-1 instance. There the relevant limitation is: Keys must exist and be stable; renaming a key may change addresses and induce replacement. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant limitation is: Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: A team must verify a network policy's expected input range before taking an action that would violate the rule. There the relevant limitation is: A precondition only protects the invariant actually encoded in its expression. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant limitation is: Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative. It would therefore not resolve or assess the case as stated.
Question 284
The team is reviewing a Terraform implementation for this case: A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. Which tempting assumption would be specifically incorrect for this proposed implementation?
- Assume every failed check block prevents Terraform from applying all resources.
- Assume a root variable of the same name is implicitly imported into all children.
- Assume any object named in a data block is subject to resource deletion on destroy.
- Assume Terraform infers dependencies between unrelated resources from human-readable names.
Explanation
Correct Answer
D:Reject the assumption: Assume Terraform infers dependencies between unrelated resources from human-readable names. Instead, add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. depends_on expresses ordering when Terraform cannot infer it from attribute references. Acceptance evidence: The dependency graph orders the attachment action before the dependent rule operation.
Incorrect Answers
A:This is linked to a different situation: An operations group wants an infrastructure health assertion that can report a diagnostic without behaving exactly like a resource precondition. There the relevant misconception is: Assume every failed check block prevents Terraform from applying all resources. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant misconception is: Assume Terraform infers dependencies between unrelated resources from human-readable names. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A child module expects a variable named subnet_ids, but the calling root references an undeclared variable from inside the child. There the relevant misconception is: Assume a root variable of the same name is implicitly imported into all children. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant misconception is: Assume Terraform infers dependencies between unrelated resources from human-readable names. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: An engineer sees a data block representing a preexisting DNS zone and wants to delete that DNS zone with terraform destroy. There the relevant misconception is: Assume any object named in a data block is subject to resource deletion on destroy. For the question's actual requirement — A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. — the specifically relevant misconception is: Assume Terraform infers dependencies between unrelated resources from human-readable names. It would therefore not resolve or assess the case as stated.
Question 285
A Terraform platform team is coordinating 2 independent decisions. Workstream A: A firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment. and Workstream B: A managed object should stop being controlled by Terraform while remaining physically available. Select exactly 2 actions, one addressing each distinct workstream.
- Pass a different root provider configuration into each module call through its providers map.
- Use a reviewed removed block with destroy = false or a careful terraform state rm operation to forget its binding.
- Organize related workspaces into HCP Terraform projects and assign team-level project permissions.
- Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency.
- Declare resources through separate compatible providers in one Terraform configuration, with references for dependencies.
Explanation
Correct Answers
B:For the workstream in which a managed object should stop being controlled by Terraform while remaining physically available, use this action: Use a reviewed removed block with destroy = false or a careful terraform state rm operation to forget its binding. Removing a state binding without destroying the object changes management ownership rather than infrastructure existence. Verify: Terraform no longer lists the address as managed, while the remote object remains available. Limitation: If configuration still declares the object, a normal later plan may attempt to create it again.
D:For the workstream in which a firewall rule should be provisioned only after a policy attachment exists, but the rule's arguments do not reference that attachment, use this action: Add an explicit depends_on referencing the policy attachment resource for the hidden operational dependency. depends_on expresses ordering when Terraform cannot infer it from attribute references. Verify: The dependency graph orders the attachment action before the dependent rule operation. Limitation: Explicit dependencies should be limited to real hidden dependencies; excessive depends_on can make plans conservative.
Incorrect Answers
A:This option addresses a separate requirement: A security team calls the same reusable child module twice, once under each of two cloud accounts. Evidence for that other requirement would be each module instance is associated with the correct account provider during plan; neither listed workstream asks for it.
C:This option addresses a separate requirement: An organization has dozens of workspaces for finance and research teams with distinct access requirements. Evidence for that other requirement would be the intended finance and research teams have scoped access to their respective project workspaces; neither listed workstream asks for it.
E:This option addresses a separate requirement: A logistics firm needs a private data-center virtual machine and a public-cloud DNS record managed from one reviewed release. Evidence for that other requirement would be a single plan lists the intended private and public resource actions under their respective providers; neither listed workstream asks for it.
Question 286
An infrastructure team faces this specific situation: A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. Which Terraform action most directly satisfies the requirement?
- Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted.
- Use a check block for an appropriate post-deployment assertion, and interpret its warning behavior correctly.
- Use a conditional expression over a declared environment variable to select the appropriate hostname.
- Define a root output whose value references the managed load balancer's endpoint attribute.
Explanation
Correct Answer
A:Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. Lifecycle replacement ordering can reduce interruption but does not override provider or service constraints. Verify: The replacement plan creates the new instance before destroying the old one where provider constraints allow. Limitation: Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding.
Incorrect Answers
B:This is linked to a different situation: An operations group wants an infrastructure health assertion that can report a diagnostic without behaving exactly like a resource precondition. There the relevant decision is: Use a check block for an appropriate post-deployment assertion, and interpret its warning behavior correctly. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant decision is: Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: A deployment needs to choose a service hostname based on whether the environment is production. There the relevant decision is: Use a conditional expression over a declared environment variable to select the appropriate hostname. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant decision is: Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: An operations team must surface a load balancer endpoint after apply so downstream jobs can consume it. There the relevant decision is: Define a root output whose value references the managed load balancer's endpoint attribute. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant decision is: Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. It would therefore not resolve or assess the case as stated.
Question 287
A reviewer is confirming a change for the following use case: A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. The implementation follows this approach: Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. Which observation or acceptance test most directly verifies the intended result?
- The computed list contains each intended service name normalized consistently.
- Planning with an invalid input produces a useful validation error before unwanted resource operations.
- The replacement plan creates the new instance before destroying the old one where provider constraints allow.
- Version-controlled HCL contains no hardcoded cleartext credential and the approved secret path is resolvable at runtime.
Explanation
Correct Answer
C:Acceptance evidence: The replacement plan creates the new instance before destroying the old one where provider constraints allow. It validates the proposed action, consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted, because lifecycle replacement ordering can reduce interruption but does not override provider or service constraints. Remaining limitation: Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding.
Incorrect Answers
A:This is linked to a different situation: A pipeline produces a list of service names with inconsistent letter casing and needs normalized DNS labels. There the relevant acceptance is: The computed list contains each intended service name normalized consistently. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant acceptance is: The replacement plan creates the new instance before destroying the old one where provider constraints allow. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A reusable module needs to reject a user-provided CIDR that is outside a documented allowed address family. There the relevant acceptance is: Planning with an invalid input produces a useful validation error before unwanted resource operations. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant acceptance is: The replacement plan creates the new instance before destroying the old one where provider constraints allow. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: A company rotates application credentials in Vault and wants Terraform pipelines to avoid checking decrypted secrets into source control. There the relevant acceptance is: Version-controlled HCL contains no hardcoded cleartext credential and the approved secret path is resolvable at runtime. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant acceptance is: The replacement plan creates the new instance before destroying the old one where provider constraints allow. It would therefore not resolve or assess the case as stated.
Question 288
Consider a proposed solution for this requirement: A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. The team plans to do the following: Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. Which limitation or operational caveat must remain in the review?
- Order-sensitive outputs should not be built from unordered map iteration without intentional sorting.
- A module output is an interface; it does not automatically expose every internal resource or local.
- Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding.
- Input variable declarations are module-scoped, not automatically shared across the entire configuration.
Explanation
Correct Answer
C:The limitation is unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding. The proposed change is consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. Validate it by checking the replacement plan creates the new instance before destroying the old one where provider constraints allow. Lifecycle replacement ordering can reduce interruption but does not override provider or service constraints.
Incorrect Answers
A:This is linked to a different situation: A module emits an ordered list of three subnet IDs aligned with ordered availability zones and consumers depend on position. There the relevant limitation is: Order-sensitive outputs should not be built from unordered map iteration without intentional sorting. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant limitation is: Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding. It would therefore not resolve or assess the case as stated.
B:This is linked to a different situation: A resource argument refers to an output produced by a child module, but the author attempts to read the child's internal local name directly. There the relevant limitation is: A module output is an interface; it does not automatically expose every internal resource or local. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant limitation is: Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: A child module expects a variable named subnet_ids, but the calling root references an undeclared variable from inside the child. There the relevant limitation is: Input variable declarations are module-scoped, not automatically shared across the entire configuration. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant limitation is: Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding. It would therefore not resolve or assess the case as stated.
Question 289
The team is reviewing a Terraform implementation for this case: A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. Which tempting assumption would be specifically incorrect for this proposed implementation?
- Assume create_before_destroy guarantees zero downtime even when duplicate names are forbidden.
- Use count with changing list positions while assuming unrelated indices can never shift.
- Use a numeric count index for a for_each resource that is addressed by map keys.
- Use an unknown expression branch as though Terraform skips all type checking.
Explanation
Correct Answer
A:Reject the assumption: Assume create_before_destroy guarantees zero downtime even when duplicate names are forbidden. Instead, consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. Lifecycle replacement ordering can reduce interruption but does not override provider or service constraints. Acceptance evidence: The replacement plan creates the new instance before destroying the old one where provider constraints allow.
Incorrect Answers
B:This is linked to a different situation: An application team must create one DNS record per hostname from a stable set of known domain names. There the relevant misconception is: Use count with changing list positions while assuming unrelated indices can never shift. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant misconception is: Assume create_before_destroy guarantees zero downtime even when duplicate names are forbidden. It would therefore not resolve or assess the case as stated.
C:This is linked to a different situation: A module uses for_each on a map of regions and must output one subnet ID for the us-east-1 instance. There the relevant misconception is: Use a numeric count index for a for_each resource that is addressed by map keys. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant misconception is: Assume create_before_destroy guarantees zero downtime even when duplicate names are forbidden. It would therefore not resolve or assess the case as stated.
D:This is linked to a different situation: A deployment needs to choose a service hostname based on whether the environment is production. There the relevant misconception is: Use an unknown expression branch as though Terraform skips all type checking. For the question's actual requirement — A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. — the specifically relevant misconception is: Assume create_before_destroy guarantees zero downtime even when duplicate names are forbidden. It would therefore not resolve or assess the case as stated.
Question 290
A Terraform platform team is coordinating 3 independent decisions. Workstream A: A service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create. and Workstream B: A database already exists outside Terraform but needs to become managed under an explicit new resource address. and Workstream C: A security team calls the same reusable child module twice, once under each of two cloud accounts. Select exactly 3 actions, one addressing each distinct workstream.
- Choose an explicit Git ref in the source URL rather than the registry-specific module version argument.
- Expect the default local backend to manage a terraform.tfstate file in the working directory.
- Run a refresh-only plan, review its state changes, and apply refresh-only if the update is appropriate.
- Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted.
- Pass a different root provider configuration into each module call through its providers map.
- Write a matching resource declaration and use an import block or terraform import with the real object identifier.
Explanation
Correct Answers
D:For the workstream in which a service cannot tolerate downtime when replacing a VM and the provider's planned operation requires destroy-and-create, use this action: Consider lifecycle create_before_destroy on the managed resource after confirming simultaneous old and new instances are permitted. Lifecycle replacement ordering can reduce interruption but does not override provider or service constraints. Verify: The replacement plan creates the new instance before destroying the old one where provider constraints allow. Limitation: Unique names, fixed addresses, quotas, and dependent resources may prevent this pattern from succeeding.
E:For the workstream in which a security team calls the same reusable child module twice, once under each of two cloud accounts, use this action: Pass a different root provider configuration into each module call through its providers map. Provider instances are configured at the root and passed to module instances as needed. Verify: Each module instance is associated with the correct account provider during plan. Limitation: Do not put shared provider configuration blocks inside a modern reusable child module to solve this mapping.
F:For the workstream in which a database already exists outside Terraform but needs to become managed under an explicit new resource address, use this action: Write a matching resource declaration and use an import block or terraform import with the real object identifier. Import binds an existing remote object to a Terraform resource address. Verify: State gains the intended address and a reviewed plan evaluates remaining configuration differences. Limitation: Import establishes identity and may not generate all required configuration fields automatically.
Incorrect Answers
A:This action is appropriate instead for a different, unlisted requirement: A private Git-sourced module has a reviewed release tag and an engineer adds version = "2.3" next to its Git source. It would be checked by: Terraform downloads the module code at the intended Git tag or commit during init. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
B:This action is appropriate instead for a different, unlisted requirement: A developer uses a fresh local Terraform directory with no backend block and asks where state will be written after apply. It would be checked by: A successful local apply creates or updates a locally persisted state snapshot for the selected workspace. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
C:This action is appropriate instead for a different, unlisted requirement: A company intentionally altered remote settings and wants Terraform state to reflect the real objects without proposing configuration-driven remediation yet. It would be checked by: State and root outputs synchronize with observed remote data without changing the cloud object itself. None of the 3 specified workstreams calls for this action; their correct choices directly solve the identified cases.
HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests