Skip to content
Latchkey

How to Configure GCS and azurerm Remote State in CI

The gcs and azurerm backends store state in a bucket or blob container and lock natively, so no extra lock table is required.

Use a gcs backend for Google Cloud or an azurerm backend for Azure. Both lock state without a companion table: GCS uses object generations and azurerm uses a blob lease.

gcs backend

main.tf
terraform {
  backend "gcs" {
    bucket = "acme-tf-state"
    prefix = "prod/app"
  }
}

azurerm backend

main.tf
terraform {
  backend "azurerm" {
    resource_group_name  = "tf-state-rg"
    storage_account_name = "acmetfstate"
    container_name       = "tfstate"
    key                  = "prod/app.tfstate"
  }
}

Gotchas

  • Enable object versioning on the GCS bucket so you can recover a clobbered state.
  • The azurerm backend holds a blob lease for the run; a killed job can leave a lease that must be broken.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →