Skip to main content

Clear terraform state

Here is how you can empty your state:

terraform
for resource in $(terraform state list); do
terraform state rm $resource
done

another way is to run this single command

terraform
terraform state list | xargs -n1 terraform state rm

In PowerShell, you can do these:

$resources = terraform state list

and then

$resources | ForEach-Object { terraform state rm "$_" }