You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Terraform module creates and assigns an Azure Policy that enforces lifecycle management on Azure Storage accounts. The policy can be applied at either management group, subscription level or storage account level.
Features
Enforce consistent lifecycle management across all storage accounts
Configure days for transition to cool tier, archive tier, and deletion
Apply at management group, subscription, or individual storage account level
Configurable policy effect (Deploy, Audit, or Disable)
Azure subscription or management group with appropriate permissions
Usage
Example usage of the Azure Storage Lifecycle Management Policy Module
Example 1: Apply at subscription level
module "storage_lifecycle_subscription" {
source = "../" # Path to the module directory
scope_type = "subscription"
subscription_id = "00000000-0000-0000-0000-000000000000" # Replace with your subscription ID
days_to_cool_tier = 30
days_to_archive_tier = 90
days_to_delete = 365
days_to_delete_snapshots = 30
prefix_filters = ["container1/", "backups/"]
policy_effect = "DeployIfNotExists"
}
Example 2: Apply at management group level
module "storage_lifecycle_management_group" {
source = "../" # Path to the module directory
scope_type = "management_group"
management_group_id = "mg-production" # Use the ID of the management group
days_to_cool_tier = 45
days_to_archive_tier = 120
days_to_delete = 730
days_to_delete_snapshots = 45
prefix_filters = ["logs/", "metrics/"]
policy_effect = "AuditIfNotExists" # Start with audit before enforcing
}
Example 3: Apply to a specific storage account
module "storage_lifecycle_storage_account" {
source = "../" # Path to the module directory
scope_type = "storage_account"
subscription_id = "00000000-0000-0000-0000-000000000000" # Replace with your subscription ID
storage_account_name = "mystorageaccount" # Replace with your storage account name
resource_group_name = "myresourcegroup" # Replace with your resource group name
days_to_cool_tier = 60
days_to_archive_tier = 180
days_to_delete = 365
days_to_delete_snapshots = 30
prefix_filters = ["critical/", "important/"]
policy_effect = "DeployIfNotExists" # Start with audit before enforcing but here we showcase DINE approach in our example.
}
The ID of the subscription to assign the policy to. Required if scope_type is 'subscription'. If not provided and scope_type is 'subscription', the current subscription will be used.