Use Case
If you need to migrate a workspace to a different organization
Procedure
Please note you’ll need a user API token that has sufficient permissions in both organizations. (https://app.terraform.io/app/<your organization>/settings/authentication-tokens)
Ensure that all of the settings (VCS, variables, SSH keys, Terraform version, etc) are the same in both the Original and Destination Organizations workspaces.
- Download the same version of terraform used in the Organizations/workspaces locally
- Locally, create a backend.tf file of the origin Organization * Do not commit this to your VCS repository.*
terraform {
backend "remote" {
hostname = “app.terraform.io”
organization = "<Originating Organization name>"
workspaces {
name = "<Originating workspace name>"
}
}
}
- From a command prompt where the backend.tf exists, log in into Terraform API from the commandline by issuing terraform login
- Follow the instructions of the prompts, the second one will require the user API token
- Run the command terraform init to begin establishing communications between the Organizations
- Modify the backend.tf to point to the Destination Organization:
terraform {
backend "remote" {
hostname = “app.terraform.io”
organization = "<Destination Organization name>"
workspaces {
name = "<Destination workspace name>"
}
}
}
- Execute
$terraform init
to trigger the communication with the Destination Organization. Terraform should prompt to copy the state file to the new Organization workspace. Enter yes. - Check the Destination Organization workspace for the new state file.