-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support for Azure Storage Account Data protection #8268
Comments
Upvoting, this has been available for a while now: https://azure.microsoft.com/en-gb/updates/azure-blob-versioning-is-now-general-available/ Current work around (not hugely ideal)
|
The resource "azurerm_storage_account" "storage_account_attachments" {
...
blob_properties {
delete_retention_policy {
days = 365
}
}
} |
In addition to #8268 (comment) I'm also adding template example to include changeFeed, restorePolicy and containerDeleteRetentionPolicy resource "azurerm_storage_account" "asdfstorage" {
name = oooo
resource_group_name = azurerm_resource_group.asdf.name
...
blob_properties {
delete_retention_policy {
days = 365
}
}
}
resource "azurerm_template_deployment" "asdf" {
name = "asdf"
resource_group_name = azurerm_resource_group.asdf.name
deployment_mode = "Incremental"
parameters = {
"storageAccount" = azurerm_storage_account.asdfstorage.name
}
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccount": {
"type": "string",
"metadata": {
"description": "Storage Account Name"}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccount'), '/default')]",
"properties": {
"IsVersioningEnabled": true,
"ChangeFeed": {
"enabled": true
},
"RestorePolicy": {
"enabled": true,
"days": 364
},
"ContainerDeleteRetentionPolicy": {
"enabled": true,
"days": 7
}
}
}
]
}
DEPLOY
} |
The only shortcoming I've experienced so far with @fluffy-cakes work around is that it only works for Standard account tier for storage account. I just tried it in my pipeline with Premium and it fails. |
With the new feature for blob versioning this would be a valuable feature for the storage account. https://docs.microsoft.com/en-us/azure/storage/blobs/versioning-overview |
Yes, these need to be supported. Upvoting... |
Does anyone know why when I try to apply this workaround, I run into this error? thanks The Terraform configuration must be valid before initialization so that Error: Invalid expression on main.tf line 90, in resource "azurerm_template_deployment" "qacdnstg_dataProtection": Expected the start of an expression, but found an invalid expression token. Error: Argument or block definition required on main.tf line 124: An argument or block definition is required here. To set an argument, use the |
I tried to reproduce your error, but I was not able to. I was able to deploy exactly (well, almost) the same as you did. I was successful. Here is my Terraform and provider version -->
Here is my code (the only change I changed was the storage account name, because "asdf" is taken up already (probably by you yourself ) resource "azurerm_resource_group" "asdf" { resource "azurerm_storage_account" "asdf" { resource "azurerm_template_deployment" "asdf" {
} A few observations:
terraform { provider "azurerm" {
Thanks |
Created a pull reuqest for versioning. ChangeFeed API seems to be either broken or documentation is not up to date. I am unable to set a retentionInDays parameter. |
thanks for trying to reproduce it @sean-t-shen , turns out I was missing the = before << |
Good for you to find where the problem is. |
This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.57.0"
}
# ... other configuration ... |
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. |
Community Note
Description
Azure Storage Accounts now support some Data-Protection configurations, for example versioning or soft deletion for blob-storages.
Would be great if this could be configured with Terraform as well.
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: