skip to Main Content

We have previously been using Terraform Enterprise to store our state files. Terraform Enterprise enables versioning of state files as described here.

We are currently migrating to Azure and looked into using Azure storage to store Terraform state files instead. We would like to recreate the state versioning feature. In Azure we can enable blob versioning for a historic representation of changes to the storage blob. The problem is that applying new changes with Terraform results in multiple versions created.

Terraform State versioning

This can be costly if changes are applied in the hundreds each day. Is there any way to reduce the number of versions created? How come Terraform creates multiple blob versions for each apply?

2

Answers


  1. Chosen as BEST ANSWER

    A possible solution would be to create a blob snapshot for each change that is applied through Terraform. There is no need for blob versioning as a historic representation is given through available snapshots.


  2. Azure by itself discusses the challenge you are addressing and recommends using "data lifecycle" for reducing the storage costs.


    After you enable blob versioning for a storage account, every write operation to a blob in that account results in the creation of a new version. For this reason, enabling blob versioning may result in additional costs. To minimize costs, use a lifecycle management policy to automatically delete old versions. For more information about lifecycle management, see Optimize costs by automating Azure Blob Storage access tiers.

    From https://learn.microsoft.com/en-us/azure/storage/blobs/versioning-overview#pricing-and-billing

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search