nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-004 · Question #157

Why would you use the -replace flag for terraform apply?

The correct answer is D. You want to force Terraform to destroy and recreate a resource on the next apply. The -replace flag is used with the terraform apply command when there is a need to explicitly force Terraform to destroy and then recreate a specific resource during the next apply. This can be necessary in situations where a simple update is insufficient or when a resource…

Submitted by yaw92· Apr 18, 2026Use Terraform CLI

Question

Why would you use the -replace flag for terraform apply?

Options

  • AYou want Terraform to ignore a resource on the next apply
  • BYou want Terraform to destroy all the infrastructure in your workspace
  • CYou want to force Terraform to destroy a resource on the next apply
  • DYou want to force Terraform to destroy and recreate a resource on the next apply

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    6% (2)
  • D
    87% (27)

Explanation

The -replace flag is used with the terraform apply command when there is a need to explicitly force Terraform to destroy and then recreate a specific resource during the next apply. This can be necessary in situations where a simple update is insufficient or when a resource must be re- provisioned to pick up certain changes.

Topics

#Terraform CLI#terraform apply#Resource Lifecycle#-replace flag

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice