[HOWTO] Move Terraform state from an Azure Blob Storage container to another

As already stated in the title, this blog post shows a simple way to move Terraform state between Azure Blob Storage containers.

Terraform version: Terraform v1.3.7
Azure Storage Account kind: StorageV2 (general purpose v2)

To perform the move, proceed as follows:

  1. Execute terraform init with the actual terraform backend configuration
  2. Execute terraform apply with the actual terraform backend configuration to ensure there are no changes pending
  3. Adjust terraform backend config so that it points to the new Azure Blob Storage container
    This will create a new state blob in the target Azure Blob Storage container
  4. Copy blob content from old state blob to the new state blob
    The content can be copied and pasted using the blob edit view in the Azure portal
  5. Execute terraform init
  6. Execute terraform plan

That’s it. Almost too easy.

Important: the approach described above was verified with a state consisting of exactly one blob.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: