github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/enterprise/state/resolving-conflicts.html.md (about)

     1  ---
     2  layout: "enterprise"
     3  page_title: "Resolving Conflicts - State - Terraform Enterprise"
     4  sidebar_current: "docs-enterprise-state-resolving"
     5  description: |-
     6    Resolving conflicts with remote states.
     7  ---
     8  
     9  # Resolving Conflicts in Remote States
    10  
    11  Resolving state conflicts can be time consuming and error prone, so it's
    12  important to approach it carefully.
    13  
    14  There are several tools provided by Terraform Enterprise to help resolve
    15  conflicts and fix remote state issues. First, you can navigate between state
    16  versions in the changes view of your environment (after toggling on the remote
    17  state checkbox) and view plain-text differences between versions.
    18  
    19  This allows you to pinpoint where things may have gone wrong and make a educated
    20  decision about resolving the conflict.
    21  
    22  ### Rolling Back to a Specific State Version
    23  
    24  The rollback feature allows you to choose a new version to set as the "Head"
    25  version of the state. Rolling back to a version means it will then return that
    26  state upon request from a client. It will not increment the serial in the state,
    27  but perform a hard rollback to the exact version of the state provided.
    28  
    29  This allows you to reset the state to an older version, essentially forgetting
    30  changes made in versions after that point.
    31  
    32  To roll back to a specific version, navigate to it in the changes view and use
    33  the rollback link. You'll need to confirm the version number to perform the
    34  operation.
    35  
    36  ### Using Terraform Locally
    37  
    38  Another way to resolve remote state conflicts is to merge and conflicted copies
    39  locally by inspecting the raw state available in the path
    40  `.terraform/terraform.tfstate`.
    41  
    42  When making state changes, it's important to make backup copies in order to
    43  avoid losing any data.
    44  
    45  Any state that is pushed with a serial that is lower than the known serial when
    46  the MD5 of the state does not match will be rejected.
    47  
    48  The serial is embedded in the state file:
    49  
    50  ```json
    51  {
    52    "version": 1,
    53    "serial": 555,
    54    "remote": {
    55      "type": "atlas",
    56      "config": {
    57        "name": "my-username/production"
    58      }
    59    }
    60  }
    61  ```
    62  
    63  Once a conflict has been resolved locally by editing the state file, the serial
    64  can be incremented past the current version and pushed:
    65  
    66  ```shell
    67  $ terraform remote push
    68  ```
    69  
    70  This will upload the manually resolved state and set it as the head version.