Using terraform plan command of Terraform CLI, how can you enforce replacing of a specific resource that wasn't changed?
Experience Level: Junior
Tags: Terraform
Answer
Run the following command:
terraform plan -replace=resource
The command above will generate a speculative execution plan that includes replacement of the requested resource. The plan won't be executed unless it's stored to an output file and applied using terraform apply -state=path command.
Related Terraform job interview questions
What happens on Linux-based operating systems when you run terraform plan command and confirm by typing yes?
Terraform JuniorUsing Terraform CLI, how do you create or update infrastructure according to Terraform configuration?
Terraform JuniorWill Terraform CLI execute the planned actions when you generate a speculative execution plan?
Terraform JuniorWhat is a speculative execution plan in Terraform?
Terraform JuniorUsing Terraform CLI, how do you limit planning operation to only specific resource?
Terraform Junior