-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_storage_management_policy overwrites the rules #18583
Comments
I ran into a similar issue, and found fix is to add both rules to the same resource "azurerm_storage_management_policy" "default" {
storage_account_id = data.azurerm_storage_account.example.id
rule {
name = "default"
enabled = true
filters {
prefix_match = [""]
blob_types = ["blockBlob"]
}
actions {
base_blob {
tier_to_cool_after_days_since_modification_greater_than = 999
tier_to_archive_after_days_since_modification_greater_than = 999
delete_after_days_since_modification_greater_than = 0
}
}
}
rule {
name = "retention"
enabled = true
filters {
prefix_match = ["container/blob1"]
blob_types = ["blockBlob"]
}
actions {
base_blob {
tier_to_cool_after_days_since_modification_greater_than = 30
}
}
}
} From what I can tell, each storage account can only have a single management policy. If you try create multiple I think it would be good if this were mentioned in the docs, and the provider either prevented you from creating multiple |
Indeed - that's a bug since every other Resource in the Provider checks for the presence of an existing resource (or non-default configuration, where the resource is created by default) when creating the resource to ensure we don't unintentionally adopt it - so fixing that would fix this issue. @magodo since you've worked with this one most recently/have the most context, would you mind taking a look into that? |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Is there an existing issue for this?
Community Note
Terraform Version
1.2.0
AzureRM Provider Version
3.24.0
Affected Resource(s)/Data Source(s)
azurerm_storage_management_policy
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Should create two policy rules , as they can be created from the portal
Actual Behaviour
terraform plan shows to create only one rule and doesn't shows the removal of the rule which the apply performs
deletes one rule and creates only one of the two rules for lifecycle management
Steps to Reproduce
terraform plan
terraform apply
Important Factoids
No response
References
Is this because of the constraint :
https://learn.microsoft.com/en-us/azure/storage/blobs/lifecycle-management-overview#:~:text=If%20you%20define%20more%20than%20one%20action%20on%20the%20same%20blob%2C%20lifecycle%20management%20applies%20the%20least%20expensive%20action%20to%20the%20blob.
The text was updated successfully, but these errors were encountered: