github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/commands/untaint.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Command: untaint"
     4  sidebar_current: "docs-commands-untaint"
     5  description: |-
     6    The `terraform untaint` command manually unmarks a Terraform-managed resource as tainted, restoring it as the primary instance in the state.
     7  ---
     8  
     9  # Command: untaint
    10  
    11  The `terraform untaint` command manually unmarks a Terraform-managed resource
    12  as tainted, restoring it as the primary instance in the state. This reverses
    13  either a manual `terraform taint` or the result of provisioners failing on a
    14  resource.
    15  
    16  This command _will not_ modify infrastructure, but does modify the state file
    17  in order to unmark a resource as tainted.
    18  
    19  ~> **NOTE on Tainted Indexes:** In certain edge cases, more than one tainted
    20  instance can be present for a single resource. When this happens, you need to specify the index after the resources, e.g. `my-resource-example[2]`. You can use the `terraform show` command to inspect the state and
    21  determine which index holds the instance you'd like to restore. In the vast
    22  majority of cases, there will only be one tainted instance, and the `-index`
    23  flag can be omitted.
    24  
    25  ## Usage
    26  
    27  Usage: `terraform untaint [options] name`
    28  
    29  The `name` argument is the name of the resource to mark as untainted.  The
    30  format of this argument is `TYPE.NAME`, such as `aws_instance.foo`.
    31  
    32  The command-line flags are all optional (with the exception of `-index` in
    33  certain cases, see above note). The list of available flags are:
    34  
    35  * `-allow-missing` - If specified, the command will succeed (exit code 0)
    36      even if the resource is missing. The command can still error, but only
    37      in critically erroneous cases.
    38  
    39  * `-backup=path` - Path to the backup file. Defaults to `-state-out` with
    40    the ".backup" extension. Disabled by setting to "-".
    41  
    42  * `-lock=true` - Lock the state file when locking is supported.
    43  
    44  * `-lock-timeout=0s` - Duration to retry a state lock.
    45  
    46  * `-module=path` - The module path where the resource to untaint exists.
    47      By default this is the root path. Other modules can be specified by
    48      a period-separated list. Example: "foo" would reference the module
    49      "foo" but "foo.bar" would reference the "bar" module in the "foo"
    50      module.
    51  
    52  * `-no-color` - Disables output with coloring
    53  
    54  * `-state=path` - Path to read and write the state file to. Defaults to "terraform.tfstate".
    55    Ignored when [remote state](/docs/state/remote.html) is used.
    56  
    57  * `-state-out=path` - Path to write updated state file. By default, the
    58    `-state` path will be used. Ignored when
    59    [remote state](/docs/state/remote.html) is used.