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

Replace azapi_resource workaround with azurerm_storage_container_immutability_policy #2

Open
DamaniN opened this issue Nov 1, 2024 · 2 comments

Comments

@DamaniN
Copy link
Contributor

DamaniN commented Nov 1, 2024

Is your feature request related to a problem? Please describe.

Microsoft and Terraform have released a azurerm_storage_container_immutability_policy resource. This workaround can now be replaced by that:

# Workaround until azurerm_storage_container supports setting the version level immutability option.
# See https://github.com/hashicorp/terraform-provider-azurerm/issues/21512 
# and https://github.com/hashicorp/terraform-provider-azurerm/issues/3722 for more details.

resource "azapi_resource" "cc_container" {

  type = "Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01"
  name      = var.cluster_name

  # We append '/blobServices/default' to the storage_account.id see desc. above
  parent_id = "${azurerm_storage_account.cc_storage_account.id}/blobServices/default"

  body = jsonencode({
    properties = {
      immutableStorageWithVersioning = {
        enabled = "${var.enableImmutability}"
      }
      publicAccess = "None"
    }
  })
}

Describe the solution you'd like

Replace azapi_resource workaround with:

resource "azurerm_storage_container_immutability_policy" "example" {
  storage_container_resource_manager_id = azurerm_storage_container.example.resource_manager_id
  immutability_period_in_days           = 14
  protected_append_writes_all_enabled   = false
  protected_append_writes_enabled       = true
}

Describe alternatives you've considered

None

Additional context

None

@DamaniN
Copy link
Contributor Author

DamaniN commented Nov 1, 2024

Looking at this new resource, it requires setting the immutability_period_in_days. That may cause a conflict with CCES and needs to be tested. In theory, if the immutability_period_in_days is set to a low value (like 3 days) CCES can extend the lock afterward.

It also requires version 4.2.0 of the Azure provider. The minimum AzureRM provider version will need to be updated as well.

@DamaniN
Copy link
Contributor Author

DamaniN commented Nov 1, 2024

This feature also requires that a immutability_policy block be added to the azurerm_storege_account block.

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

No branches or pull requests

1 participant