Continuing from my previous blog post on automating Azure Blob Storage backups with Terraform and AzureRM Storage Management Policy, let's delve into the recent enhancements, particularly the introduction of the "cold" storage tier and its integration with Terraform's AzureRM provider.

Introduction to Cold Storage Tier in Azure Blob Storage

Microsoft Azure has expanded its storage tier options with the introduction of the "cold" storage tier. This tier is particularly useful for data that is infrequently accessed but requires long-term storage. It's a cost-effective solution for retaining large volumes of data with less need for speedy retrieval. This new tier complements the existing "hot" and "cool" tiers, offering more flexibility in managing storage costs and performance.

The Issue: Integrating Cold Storage Tier in Terraform's AzureRM Provider

In your existing Terraform configurations, you might have used the azurerm_storage_management_policy resource to automate lifecycle management of blob storage. However, with the introduction of the cold storage tier, a new challenge emerges: the previous versions of the AzureRM provider did not support the new "tierToCold" rule action. This gap means you could not automatically move data to the cold storage tier based on your defined lifecycle rules.

The Solution: Terraform AzureRM Provider v3.79.0

Good news comes with the release of version 3.79.0 of the Terraform AzureRM provider. This update includes support for the cold storage tier, allowing you to define rules that automatically move data to this new tier based on certain conditions like modification time, last access time, or creation time.

Implementing Cold Storage Policies with Terraform

To use this new feature, your Terraform configuration for the azurerm_storage_management_policy resource will now include additional properties in the actions block of your rules. Here's an example configuration snippet:


resource "azurerm_storage_management_policy" "this" {
  storage_account_id = azurerm_storage_account.this.id

  rule {
    name    = "moveToCold"
    enabled = true

    actions {
      base_blob {
        tier_to_cold_after_days_since_modification_greater_than = 30
        // Add other actions if required...
      }
    }
  }
}

In this example, blobs are moved to the cold storage tier if they haven't been modified for more than 30 days.

Advantages and Use Cases

  • Cost-Effectiveness: By moving infrequently accessed data to the cold storage tier, you can significantly reduce storage costs.
  • Compliance and Data Retention: For industries with long-term data retention requirements, the cold tier offers an affordable way to store data for years.
  • Backup and Disaster Recovery: Cold storage can be part of a comprehensive backup strategy, storing historical data backups.

References

Conclusion

The addition of the cold storage tier in Azure Blob Storage and its support in Terraform's AzureRM provider version 3.79.0 marks a significant advancement in data lifecycle management. This feature empowers you to optimize storage costs and performance based on your specific access patterns and retention policies. With this new capability, Terraform continues to be an invaluable tool for managing cloud resources efficiently and cost-effectively.