I am trying to add a LifeCycle Policy on a storage account created.
I face this error: “Error: creating Storage Account Management Policy: (Management Policy Name “default” / Storage Account Name “xyz” / Resource Group “RG-XYZ”): unexpected status 400 with error: MissingLastAccessTimeBasedTrackingPolicy: Last access time based tracking policy must be enabled before using its specific actions in object lifecycle management policy” .
The code for my sa management policy is:
resource “azurerm_storage_account” “abc” { code…
}
resource "azurerm_storage_management_policy" "abc" {
storage_account_id = azurerm_storage_account.abc.id
rule {
name = "LifecyclePolicy"
enabled = true
filters {
blob_types = ["blockBlob"]
}
actions {
base_blob {
tier_to_cool_after_days_since_last_access_time_greater_than = 30
tier_to_archive_after_days_since_last_access_time_greater_than = 60
delete_after_days_since_last_access_time_greater_than = 90
}
}
}
}
It creates the Storage Account but it fails with the error above mentioned.
The WorkAround that works is to go manually in the Azure Portal in the storage account abc and to enable manually “Enable access tracking” from Lifecycle management tab of Data Management.
Is there another way to declare this enabled in my policy? or I should use another type of resource for this storage account management policy?