Join us this September for 3 days of talks, training, product news & more. Book Your Ticket Now

Terraform Cloud

Migrating to Terraform Cloud from local state storage

How to Store State Remotely

First, we'll use Terraform Cloud as our backend. Terraform Cloud offers free remote state management. It is a great way to get started with Terraform backends.

If you don't have an account, please sign up here. For more information on Terraform Cloud, view our getting started guide First, configure the backend in your configuration file:

terraform {
  backend "remote" {
    organization = "<ORGANIZATION NAME>"

    workspaces {
      name = "<WORKSPACE NAME>"

The backend section configures the backend you want to use. After configuring a backend, run terraform init to setup Terraform. It should ask if you want to migrate your state to Terraform Cloud. Say "yes" and Terraform will copy your state.

Now, if you run terraform apply, Terraform should state that there are no changes:

$ terraform apply
# ...

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and the latest version of your state. As a result, Terraform
doesn't need to do anything.

Terraform is now storing your state remotely in Terraform Cloud. Remote state storage makes collaboration easier and keeps state and secret information off your local disk. Remote state is loaded only in memory when it is used.

If you want to move back to local state, you can remove the backend configuration block from your configuration and run terraform init again. Terraform will once again ask if you want to migrate your state back to local.