TA-002-P · Question #175
Once a resource is marked as tainted, the next plan will show that the resource will be _________ and ___________ and the next apply will implement this change.
The correct answer is D. destroyed and recreated. Tainting a resource schedules it to be destroyed and recreated in the next plan and apply cycle, replacing the degraded resource with a fresh instance.
Question
Once a resource is marked as tainted, the next plan will show that the resource will be _________ and ___________ and the next apply will implement this change.
Options
- Arecreated and tainted
- Bdestroyed and not recreated
- Ctainted and not destroyed
- Ddestroyed and recreated
How the community answered
(44 responses)- A2% (1)
- C2% (1)
- D95% (42)
Why each option
Tainting a resource schedules it to be destroyed and recreated in the next plan and apply cycle, replacing the degraded resource with a fresh instance.
'Recreated and tainted' is incorrect because while the resource is recreated, the newly created resource is not itself tainted - the taint flag applies only to the old instance to trigger replacement.
'Destroyed and not recreated' is incorrect because taint always triggers recreation after destruction so Terraform can restore the desired state.
'Tainted and not destroyed' contradicts the fundamental purpose of the taint mechanism, which is specifically to schedule a resource for destruction and replacement.
When a resource is tainted, Terraform marks it as needing replacement; the next terraform plan displays the resource as scheduled for destruction followed by creation, and terraform apply executes both steps to restore the resource to a clean state.
Concept tested: Terraform tainted resource lifecycle - destroy and recreate
Source: https://developer.hashicorp.com/terraform/cli/commands/taint
Topics
Community Discussion
No community discussion yet for this question.