2017-05-31 02:46:12 +02:00
|
|
|
---
|
2021-11-23 00:57:25 +01:00
|
|
|
layout: "docs"
|
|
|
|
page_title: "Command: workspace delete"
|
|
|
|
sidebar_current: "docs-commands-workspace-sub-delete"
|
|
|
|
description: |-
|
|
|
|
The terraform workspace delete command is used to delete a workspace.
|
2017-05-31 02:46:12 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# Command: workspace delete
|
|
|
|
|
|
|
|
The `terraform workspace delete` command is used to delete an existing workspace.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2020-11-11 15:14:54 +01:00
|
|
|
Usage: `terraform workspace delete [OPTIONS] NAME [DIR]`
|
2017-05-31 02:46:12 +02:00
|
|
|
|
|
|
|
This command will delete the specified workspace.
|
|
|
|
|
|
|
|
To delete an workspace, it must already exist, it must have an empty state,
|
|
|
|
and it must not be your current workspace. If the workspace state is not empty,
|
|
|
|
Terraform will not allow you to delete it unless the `-force` flag is specified.
|
|
|
|
|
|
|
|
If you delete a workspace with a non-empty state (via `-force`), then resources
|
|
|
|
may become "dangling". These are resources that physically exist but that
|
|
|
|
Terraform can no longer manage. This is sometimes preferred: you want
|
|
|
|
Terraform to stop managing resources so they can be managed some other way.
|
|
|
|
Most of the time, however, this is not intended and so Terraform protects you
|
|
|
|
from getting into this situation.
|
|
|
|
|
|
|
|
The command-line flags are all optional. The only supported flag is:
|
|
|
|
|
|
|
|
* `-force` - Delete the workspace even if its state is not empty. Defaults to false.
|
2021-05-12 18:05:03 +02:00
|
|
|
* `-lock=false` - Don't hold a state lock during the operation. This is
|
2021-11-23 00:57:25 +01:00
|
|
|
dangerous if others might concurrently run commands against the same
|
|
|
|
workspace.
|
2021-05-12 18:05:03 +02:00
|
|
|
* `-lock-timeout=DURATION` - Duration to retry a state lock. Default 0s.
|
2017-05-31 02:46:12 +02:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform workspace delete example
|
|
|
|
Deleted workspace "example".
|
|
|
|
```
|