Friday, May 26, 2023
HomeSoftware EngineeringMethods to Take away a Useful resource from Terraform State

Methods to Take away a Useful resource from Terraform State


Terraform state displays the freshest reference of the infrastructure.

Typically you might have to take away a useful resource from the Terraform state manually. That is useful if a useful resource has been deleted or modified manually and the useful resource definition has been eliminated in your Terraform code. This fashion you may re-run your Terraform plan and apply with out deleting the distant infra useful resource that you simply faraway from the state.

Step 1 – Discover the useful resource you need to delete

Operating this command will place all assets managed by Terraform in a listing type, all assets separated by line breaks.

terraform state checklist

Step 2 – Take away the useful resource in query

As soon as you already know the useful resource you wish to take away from the state, move it’s Terraform reference title to the rm command beneath:

terraform state rm <resource_name>

Instance:

terraform state rm module.kms_key.aws_kms_key.default[0]
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments