main.locks.tf (10 lines of code) (raw):

# Resource Block for Locks for storage account resource "azurerm_management_lock" "this_storage_account" { count = var.lock != null ? 1 : 0 lock_level = var.lock.kind name = coalesce(var.lock.name, "lock-${var.name}") scope = azurerm_storage_account.this.id notes = var.lock.kind == "CanNotDelete" ? "Cannot delete the resource or its child resources." : "Cannot delete or modify the resource or its child resources." depends_on = [ azurerm_storage_account.this ] }