Search⌘ K
AI Features

Removing Items from Terraform State

Understand how to use the terraform state rm command to safely remove resources from Terraform state files without destroying underlying infrastructure. This lesson helps you manage state entries, update configurations properly, and prevent errors during Terraform plans and applies.

The rm subcommand

The terraform state rm command is used to remove items from the Terraform state.

Syntax

The rm subcommand has the following syntax: terraform state rm [options] ADDRESS.

Use of the terraform state rm command

We can use this command to remove a single resource, a single instance of a resource, entire modules, and more. The resources removed by the command are removed from the state file but aren’t destroyed in the target environment.

The most common use for the rm command is to remove a resource from Terraform management. ...