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.
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
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.
Azure by itself discusses the challenge you are addressing and recommends using "data lifecycle" for reducing the storage costs.
From https://learn.microsoft.com/en-us/azure/storage/blobs/versioning-overview#pricing-and-billing