Remove a resource from state

Remove a resource from state without destroying it in the cloud

terraform state rm 'aws_instance.legacy'

tool
terraform43 commands
tags
terraform

More terraform commands

  • terraform output -json | jq 'to_entries[] | {(.key): .value.value}'

    Print each output as a short {name: value} JSON object

  • terraform destroy -target='aws_instance.web' -auto-approve

    Destroy one resource without a full plan and without confirmation (-auto-approve)

  • terraform force-unlock <lock-id>

    Release a stuck state lock after a failed apply

  • terraform workspace new staging && terraform workspace select staging

    Create a new workspace and switch to it

  • terraform graph | dot -Tsvg > graph.svg && open graph.svg

    Render the resource dependency graph as SVG and open it (needs Graphviz)

all 43 terraform commands