terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

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

Open DamaniN opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

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

DamaniN avatar Apr 24 '23 06:04 DamaniN

+1

ninkaninus avatar Apr 24 '23 07:04 ninkaninus

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 } } }) }

rb-cloud-guru avatar May 08 '24 20:05 rb-cloud-guru