nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-003 · 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…

Use Terraform outside the core workflow

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

(17 responses)
  • B
    12% (2)
  • C
    6% (1)
  • D
    82% (14)

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

#-replace flag#resource recreation#terraform apply#resource lifecycle

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-003 Practice