Update state
This commit is contained in:
parent
7924c6f2d3
commit
d31e1d9efa
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
layout: "enterprise"
|
layout: "enterprise"
|
||||||
page_title: "State: Collaborating"
|
page_title: "Collaborating - State - Terraform Enterprise"
|
||||||
sidebar_current: "docs-enterprise-state-collaborating"
|
sidebar_current: "docs-enterprise-state-collaborating"
|
||||||
description: |-
|
description: |-
|
||||||
How to collaborate on states.
|
How to collaborate on states.
|
||||||
|
@ -10,12 +10,14 @@ description: |-
|
||||||
|
|
||||||
Terraform Enterprise is one of a few options to store [remote state](/docs/enterprise/state).
|
Terraform Enterprise is one of a few options to store [remote state](/docs/enterprise/state).
|
||||||
|
|
||||||
Remote state gives you the ability to version and collaborate on Terraform changes. It
|
Remote state gives you the ability to version and collaborate on Terraform
|
||||||
stores information about the changes Terraform makes based on configuration.
|
changes. It stores information about the changes Terraform makes based on
|
||||||
|
configuration.
|
||||||
|
|
||||||
In order to collaborate safely on remote state, we recommend
|
In order to collaborate safely on remote state, we recommend
|
||||||
[creating an organization](/docs/enterprise/organizations/create.html) to manage teams of users.
|
[creating an organization](/docs/enterprise/organizations/create.html) to
|
||||||
|
manage teams of users.
|
||||||
|
|
||||||
Then, following a [remote state push](/docs/enterprise/state) you can view state versions
|
Then, following a [remote state push](/docs/enterprise/state) you can view state
|
||||||
in the changes tab of the environment created under the same name
|
versions in the changes tab of the environment created under the same name as
|
||||||
as the remote state.
|
the remote state.
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
---
|
---
|
||||||
layout: "enterprise"
|
layout: "enterprise"
|
||||||
page_title: "About Remote State"
|
page_title: "State - Terraform Enterprise"
|
||||||
sidebar_current: "docs-enterprise-state"
|
sidebar_current: "docs-enterprise-state"
|
||||||
description: |-
|
description: |-
|
||||||
Terraform stores the state of your managed infrastructure from the last time Terraform was run. This section is about states.
|
Terraform stores the state of your managed infrastructure from the last time Terraform was run. This section is about states.
|
||||||
---
|
---
|
||||||
|
|
||||||
# About Remote State
|
# State
|
||||||
|
|
||||||
Terraform stores the state of your managed infrastructure from the last
|
Terraform stores the state of your managed infrastructure from the last time
|
||||||
time Terraform was run. By default this state is stored in a local file
|
Terraform was run. By default this state is stored in a local file named
|
||||||
named `terraform.tfstate`, but it can also be stored remotely, which
|
`terraform.tfstate`, but it can also be stored remotely, which works better in a
|
||||||
works better in a team environment.
|
team environment.
|
||||||
|
|
||||||
Terraform Enterprise is a remote state provider, allowing you to store, version and
|
Terraform Enterprise is a remote state provider, allowing you to store, version
|
||||||
collaborate on states.
|
and collaborate on states.
|
||||||
|
|
||||||
Remote state gives you more than just easier version control and safer
|
Remote state gives you more than just easier version control and safer storage.
|
||||||
storage. It also allows you to delegate the outputs to other teams.
|
It also allows you to delegate the outputs to other teams. This allows your
|
||||||
This allows your infrastructure to be more easily broken down into
|
infrastructure to be more easily broken down into components that multiple teams
|
||||||
components that multiple teams can access.
|
can access.
|
||||||
|
|
||||||
Read [more about remote state](https://www.terraform.io/docs/state/remote.html).
|
Read [more about remote state](https://www.terraform.io/docs/state/remote.html).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
layout: "enterprise"
|
layout: "enterprise"
|
||||||
page_title: "State: Pushing"
|
page_title: "Pushing - State - Terraform Enterprise"
|
||||||
sidebar_current: "docs-enterprise-state-pushing"
|
sidebar_current: "docs-enterprise-state-pushing"
|
||||||
description: |-
|
description: |-
|
||||||
Pushing remote states.
|
Pushing remote states.
|
||||||
|
@ -10,10 +10,14 @@ description: |-
|
||||||
|
|
||||||
Terraform Enterprise is one of a few options to store [remote state](/docs/enterprise/state).
|
Terraform Enterprise is one of a few options to store [remote state](/docs/enterprise/state).
|
||||||
|
|
||||||
Remote state gives you the ability to version and collaborate on Terraform changes. It
|
Remote state gives you the ability to version and collaborate on Terraform
|
||||||
stores information about the changes Terraform makes based on configuration.
|
changes. It stores information about the changes Terraform makes based on
|
||||||
|
configuration.
|
||||||
|
|
||||||
To use Terraform Enterprise to store remote state, you'll first need to have the
|
To use Terraform Enterprise to store remote state, you'll first need to have the
|
||||||
`ATLAS_TOKEN` environment variable set and run the following command.
|
`ATLAS_TOKEN` environment variable set and run the following command.
|
||||||
|
|
||||||
$ terraform remote config -backend-config="name=%{DEFAULT_USERNAME}/product"
|
```shell
|
||||||
|
$ terraform remote config \
|
||||||
|
-backend-config="name=$USERNAME/product"
|
||||||
|
```
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
layout: "enterprise"
|
layout: "enterprise"
|
||||||
page_title: "State: Resolving Conflicts"
|
page_title: "Resolving Conflicts - State - Terraform Enterprise"
|
||||||
sidebar_current: "docs-enterprise-state-resolving"
|
sidebar_current: "docs-enterprise-state-resolving"
|
||||||
description: |-
|
description: |-
|
||||||
Resolving conflicts with remote states.
|
Resolving conflicts with remote states.
|
||||||
|
@ -8,64 +8,63 @@ description: |-
|
||||||
|
|
||||||
# Resolving Conflicts in Remote States
|
# Resolving Conflicts in Remote States
|
||||||
|
|
||||||
Resolving state conflicts can be time consuming and error prone, so
|
Resolving state conflicts can be time consuming and error prone, so it's
|
||||||
it's important to approach it carefully.
|
important to approach it carefully.
|
||||||
|
|
||||||
There are several tools provided by Terraform Enterprise to help resolve conflicts
|
There are several tools provided by Terraform Enterprise to help resolve
|
||||||
and fix remote state issues. First, you can navigate between state
|
conflicts and fix remote state issues. First, you can navigate between state
|
||||||
versions in the changes view of your environment (after toggling on
|
versions in the changes view of your environment (after toggling on the remote
|
||||||
the remote state checkbox) and view plain-text differences between
|
state checkbox) and view plain-text differences between versions.
|
||||||
versions.
|
|
||||||
|
|
||||||
This allows you to pinpoint where things may have gone wrong and
|
This allows you to pinpoint where things may have gone wrong and make a educated
|
||||||
make a educated decision about resolving the conflict.
|
decision about resolving the conflict.
|
||||||
|
|
||||||
### Rolling Back to a Specific State Version
|
### Rolling Back to a Specific State Version
|
||||||
|
|
||||||
The rollback feature allows you to choose a new version to set as the
|
The rollback feature allows you to choose a new version to set as the "Head"
|
||||||
"Head" version of the state. Rolling back to a version means it will
|
version of the state. Rolling back to a version means it will then return that
|
||||||
then return that state upon request from a client. It will not
|
state upon request from a client. It will not increment the serial in the state,
|
||||||
increment the serial in the state, but perform a hard rollback to the
|
but perform a hard rollback to the exact version of the state provided.
|
||||||
exact version of the state provided.
|
|
||||||
|
|
||||||
This allows you to reset the state to an older version, essentially
|
This allows you to reset the state to an older version, essentially forgetting
|
||||||
forgetting changes made in versions after that point.
|
changes made in versions after that point.
|
||||||
|
|
||||||
To roll back to a specific version, navigate to it in the changes view
|
To roll back to a specific version, navigate to it in the changes view and use
|
||||||
and use the rollback link. You'll need to confirm the version number
|
the rollback link. You'll need to confirm the version number to perform the
|
||||||
to perform the operation.
|
operation.
|
||||||
|
|
||||||
### Using Terraform Locally
|
### Using Terraform Locally
|
||||||
|
|
||||||
Another way to resolve remote state conflicts
|
Another way to resolve remote state conflicts is to merge and conflicted copies
|
||||||
is to merge and conflicted copies locally by inspecting the
|
locally by inspecting the raw state available in the path
|
||||||
raw state available in the path `.terraform/terraform.tfstate`.
|
`.terraform/terraform.tfstate`.
|
||||||
|
|
||||||
When making state changes, it's important to make backup copies in
|
When making state changes, it's important to make backup copies in order to
|
||||||
order to avoid losing any data.
|
avoid losing any data.
|
||||||
|
|
||||||
Any state that is pushed with a serial that is lower
|
Any state that is pushed with a serial that is lower than the known serial when
|
||||||
than the known serial when the MD5 of the state does not match will be rejected.
|
the MD5 of the state does not match will be rejected.
|
||||||
|
|
||||||
The serial is embedded in the state file:
|
The serial is embedded in the state file:
|
||||||
|
|
||||||
{
|
```json
|
||||||
"version": 1,
|
{
|
||||||
"serial": 555,
|
"version": 1,
|
||||||
"remote": {
|
"serial": 555,
|
||||||
"type": "atlas",
|
"remote": {
|
||||||
"config": {
|
"type": "atlas",
|
||||||
"name": "%{DEFAULT_USERNAME}/production"
|
"config": {
|
||||||
}
|
"name": "my-username/production"
|
||||||
},
|
|
||||||
...
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Once a conflict has been resolved locally by editing the state file,
|
Once a conflict has been resolved locally by editing the state file, the serial
|
||||||
the serial can be incremented past the current version and
|
can be incremented past the current version and pushed:
|
||||||
pushed:
|
|
||||||
|
|
||||||
terraform remote push
|
```shell
|
||||||
|
$ terraform remote push
|
||||||
|
```
|
||||||
|
|
||||||
This will upload the manually resolved state and set it as the head
|
This will upload the manually resolved state and set it as the head version.
|
||||||
version.
|
|
||||||
|
|
Loading…
Reference in New Issue