Skip to content
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 Immutable Storage With Versioning option when creating a container with azurerm_storage_container #21512

Open
1 task done
DamaniN opened this issue Apr 24, 2023 · 3 comments

Comments

@DamaniN
Copy link

DamaniN commented Apr 24, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 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

#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

This comment was marked as off-topic.

@rb-cloud-guru
Copy link

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

@WeetA34
Copy link

WeetA34 commented Nov 8, 2024

for now, I confirm it can only be done through azapi:

data "azurerm_resource_group" "rg" {
  name = "myresourcegroup"
}

data "azurerm_storage_account" "st" {
  name                = "mystorageaccount"
  resource_group_name = data.azurerm_resource_group.rg.name
}

resource "azapi_resource" "c" {
  type      = "Microsoft.Storage/storageAccounts/blobServices/containers@2023-05-01"
  name      = "mycontainer"
  parent_id = "${data.azurerm_storage_account.st.id}/blobServices/default"
  body = {
    properties = {
      defaultEncryptionScope      = "$account-encryption-key"
      denyEncryptionScopeOverride = false
      immutableStorageWithVersioning = {
        enabled = true
      }
      publicAccess = "None"
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants