github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/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  Remove one or more items from the Terraform state.
    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 where Terraform should write the backup state. This
    47    can't be disabled. If not set, Terraform will write it to the same path as
    48    the statefile with a backup extension.
    49  
    50  * `-state=path` - Path to a Terraform state file to use to look up
    51    Terraform-managed resources. By default it will use the configured backend,
    52    or the default "terraform.tfstate" if it exists.
    53  
    54  ## Example: Remove a Resource
    55  
    56  The example below removes a single resource in a module:
    57  
    58  ```
    59  $ terraform state rm module.foo.packet_device.worker[0]
    60  ```
    61  
    62  ## Example: Remove a Module
    63  
    64  The example below removes an entire module:
    65  
    66  ```
    67  $ terraform state rm module.foo
    68  ```