Find out how to Take away a Useful resource from Terraform State


Terraform state displays the hottest reference of the infrastructure.

Typically it’s possible you’ll must 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 possibly can re-run your Terraform plan and apply with out deleting the distant infra useful resource that you just faraway from the state.

Step 1 – Discover the useful resource you wish to delete

Working this command will place all sources managed by Terraform in a listing kind, all sources separated by line breaks.

terraform state listing

Step 2 – Take away the useful resource in query

As soon as you realize the useful resource you wish to take away from the state, go it’s Terraform reference identify to the rm command beneath:

terraform state rm <resource_name>

Instance:

terraform state rm module.kms_key.aws_kms_key.default[0]
See also  Enjoying the Alphabet Warfare in Python

Leave a Reply