hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

Support for Immutable Storage With Versioning option when creating a container with azurerm_storage_container #21512

Open DamaniN opened 1 year ago

DamaniN commented 1 year ago

Is there an existing issue for this?

Community Note

Description

Please add support for enabling Immutable Storage With Versioning on a container when it's created with azurerm_storage_container. This request was forked from this comment in #3722.

More details about this feature flag can be found here: https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-policy-configure-version-scope?tabs=azure-portal#enable-version-level-immutability-for-a-new-container

New or Affected Resource(s)/Data Source(s)

azurerm_storage_container

Potential Terraform Configuration

resource "azurerm_resource_group" "example" {
    name     = "example-rg
    location = "West US2"
}

resource "azurerm_storage_account" "example" {
    name                            = "example-sa"
    resource_group_name             = azurerm_resource_group.example.name
    location                        = azurerm_resource_group.example.location
    account_tier                    = "Standard"
    account_replication_type        = "LRS"
    public_network_access_enabled   = true

    blob_properties {
        versioning_enabled          = true
    }
}

resource "azurerm_storage_container" "example" {
    name                              = "example-container"
    storage_account_name              = azurerm_storage_account.example.name
    immutable_storage_with_versioning = true
}

References

https://github.com/hashicorp/terraform-provider-azurerm/issues/3722

https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-policy-configure-version-scope?tabs=azure-portal#enable-version-level-immutability-for-a-new-container

ninkaninus commented 1 year ago

+1

rb-cloud-guru commented 4 months ago

you need to use the azapi. In 2024 this is still not working?

azapi for storage container immutability

resource "azapi_resource" "container" { type = "Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01" name = var.container_name parent_id = "${azurerm_storage_account.sa.id}/blobServices/default"

body = jsonencode({ properties = { immutableStorageWithVersioning = { enabled = var.container_versioning_enabled } } }) }