Recall & Review
beginner
What does the
-replace flag do in terraform apply?The
-replace flag forces Terraform to destroy and recreate a specific resource during the apply process.Click to reveal answer
beginner
How do you specify a resource to replace using the
-replace flag?You specify the resource address, like
-replace=aws_instance.example, to tell Terraform which resource to recreate.Click to reveal answer
intermediate
Why would you use the
-replace flag instead of manually deleting a resource?Using
-replace lets Terraform handle the destruction and recreation safely, keeping the state consistent and avoiding manual errors.Click to reveal answer
intermediate
Can you replace multiple resources in one
terraform apply command?Yes, you can use multiple
-replace flags to replace several resources at once.Click to reveal answer
advanced
What happens if you use
-replace on a resource that does not exist in the state?Terraform will show an error because it cannot replace a resource that is not tracked in the state.
Click to reveal answer
What is the main purpose of the
-replace flag in terraform apply?✗ Incorrect
The
-replace flag forces Terraform to destroy and recreate the specified resource.How do you specify which resource to replace?
✗ Incorrect
You specify the resource address as tracked in the Terraform state, like
aws_instance.example.Can you replace multiple resources in one command?
✗ Incorrect
Terraform allows multiple
-replace flags in one apply command to replace several resources.What happens if you try to replace a resource not in the state?
✗ Incorrect
Terraform will show an error because it cannot replace a resource that is not tracked in the state.
Why is using
-replace safer than manually deleting a resource?✗ Incorrect
Using
-replace keeps the Terraform state consistent by managing destruction and recreation properly.Explain how the
-replace flag works in terraform apply and when you might use it.Think about how Terraform manages resources and state.
You got /4 concepts.
Describe the steps Terraform takes when you run
terraform apply -replace=resource.address.Focus on the lifecycle of the resource during apply.
You got /4 concepts.