How To Store Terraform State in Terraform Cloud (Free Tier).

How To Store Terraform State in Terraform Cloud (Free Tier).

By default, Terraform writes its state (terraform.tfstate) locally.
That’s fine for quick experiments, but it has two problems:

  • Local state can be lost or corrupted.
  • Multiple people (or multiple shells) can’t safely run Terraform at the same time.

HashiCorp offers a free service — Terraform Cloud — which solves both problems.
It stores your state remotely, handles locking automatically, and keeps a full version history.

1.1 Register for a free account

Go to Terraform Cloud and create a free account.
The Free tier includes:

  • Remote state storage
  • State locking
  • Version history
  • Up to 5 team members

Снимок экрана 2025-09-11 002536.png

1.2 Create an organization and workspace

  1. After login, create a new personal organization (e.g. kube-lab).
  2. Inside the org, create a new workspace (e.g. proxmox-stage). Choose CLI-driven workflow — we’ll run Terraform locally, but state will be remote.

Снимок экрана 2025-09-11 003423.png

personal_organization.png

terraform_cli(1).png

Снимок экрана 2025-09-11 004822.png

create_button(1).png

1.3 Generate an API token

In Terraform Cloud UI:

  • Go to User SettingsTokensCreate API token.
  • Copy the token — this is your credential for Terraform CLI.
    Save it in ~/.terraformrc (or ~/.terraform.d/credentials.tfrc.json):
credentials "app.terraform.io" {
  token = "YOUR_TERRAFORM_CLOUD_TOKEN"
}

account_settings.png

tokens_choosig.png

create_token.png

token_created.png

1.4 Make Sure to use Terraform Cloud Only for Remote State

By default, Terraform Cloud workspaces run in remote execution mode. That means plan and apply happen on HashiCorp’s servers — which can’t access your private SSH key we will use to upload a cloud-init snippet via bpg provider.

In Terraform Cloud UI:

  • Go to Workspace → Settings → General
  • Set Execution Mode = Local

Снимок экрана 2025-09-12 044456.png

Снимок экрана 2025-09-12 044548.png

Read more