HashiCorp Certified: Terraform Associate — Question 224
Why would you use the -replace flag for terraform apply?
Answer options
- A. You want to force Terraform to destroy a resource on the next apply
- B. You want Terraform to ignore a resource on the next apply
- C. You want to force Terraform to destroy and recreate a resource on the next apply
- D. You want Terraform to destroy all the infrastructure in your workspace
Correct answer: C
Explanation
The correct answer is C because the -replace flag specifically instructs Terraform to destroy a resource and then recreate it during the next apply. Option A is incorrect as it does not involve recreation, option B is wrong because it implies ignoring rather than replacing, and option D is not accurate as it refers to destroying all infrastructure rather than a specific resource.