terraform/website/source/docs/state/remote/azure.html.md

1.6 KiB

layout page_title sidebar_current description
remotestate Remote State Backend: azure docs-state-remote-azure Terraform can store the state remotely, making it easier to version and work with in a team.

azure

Stores the state as a given key in a given bucket on Microsoft Azure Storage.

-> Note: Passing credentials directly via config options will make them included in cleartext inside the persisted state. Access key should, ideally, be passed using the environment variable ARM_ACCESS_KEY to follow this convention.

Example Usage

terraform remote config \
  -backend=azure \
  -backend-config="storage_account_name=terraform123abc" \
  -backend-config="container_name=terraform-state" \
  -backend-config="key=prod.terraform.tfstate"

Example Referencing

# setup remote state data source
data "terraform_remote_state" "foo" {
  backend = "azure"
  config {
    storage_account_name = "terraform123abc"
    container_name       = "terraform-state"
    key                  = "prod.terraform.tfstate"
  }
}

Configuration variables

The following configuration options are supported:

  • storage_account_name - (Required) The name of the storage account
  • container_name - (Required) The name of the container to use within the storage account
  • key - (Required) The key where to place/look for state file inside the container
  • access_key / ARM_ACCESS_KEY - (Required) Storage account access key
  • lease_id / ARM_LEASE_ID - (Optional) If set, will be used when writing to storage blob.