github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/website/docs/commands/state/rm.html.md (about) 1 --- 2 layout: "commands-state" 3 page_title: "Command: state rm" 4 sidebar_current: "docs-state-sub-rm" 5 description: |- 6 The `terraform state rm` command removes items from the Terraform state. 7 --- 8 9 # Command: state rm 10 11 The `terraform state rm` command is used to remove items from the 12 [Terraform state](/docs/state/index.html). This command can remove 13 single resources, single instances of a resource, entire modules, 14 and more. 15 16 ## Usage 17 18 Usage: `terraform state rm [options] ADDRESS...` 19 20 The command will remove all the items matched by the addresses given. 21 22 Items removed from the Terraform state are _not physically destroyed_. 23 Items removed from the Terraform state are only no longer managed by 24 Terraform. For example, if you remove an AWS instance from the state, the AWS 25 instance will continue running, but `terraform plan` will no longer see that 26 instance. 27 28 There are various use cases for removing items from a Terraform state 29 file. The most common is refactoring a configuration to no longer manage 30 that resource (perhaps moving it to another Terraform configuration/state). 31 32 The state will only be saved on successful removal of all addresses. 33 If any specific address errors for any reason (such as a syntax error), 34 the state will not be modified at all. 35 36 This command will output a backup copy of the state prior to saving any 37 changes. The backup cannot be disabled. Due to the destructive nature 38 of this command, backups are required. 39 40 This command requires one or more addresses that point to a resources in the 41 state. Addresses are 42 in [resource addressing format](/docs/commands/state/addressing.html). 43 44 The command-line flags are all optional. The list of available flags are: 45 46 * `-backup=path` - Path to a backup file Defaults to the state path plus 47 a timestamp with the ".backup" extension. 48 49 * `-state=path` - Path to the state file. Defaults to "terraform.tfstate". 50 51 ## Example: Remove a Resource 52 53 The example below removes a single resource in a module: 54 55 ``` 56 $ terraform state rm module.foo.packet_device.worker[0] 57 ``` 58 59 ## Example: Remove a Module 60 61 The example below removes an entire module: 62 63 ``` 64 $ terraform state rm module.foo 65 ```