Skip to content

Commit

Permalink
Change to delete locks and add additional
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Dec 9, 2023
1 parent 93f39e4 commit be63920
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions terraform/app_data_storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ resource "azurerm_storage_account" "app_data_storage" {
tags = var.tags
}

resource "azurerm_management_lock" "app_data_storage_lock" {
name = "Terraform (CanNotDelete) - ${random_id.lock.hex}"
scope = azurerm_storage_account.app_data_storage.id
lock_level = "CanNotDelete"
notes = "CanNotDelete Lock managed by Terraform to prevent manual or accidental deletion of resource group and resources"
}

resource "azurerm_storage_container" "ban_files_container" {
name = "ban-files"

Expand Down
6 changes: 3 additions & 3 deletions terraform/common.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ resource "azurerm_resource_group" "rg" {
}

resource "azurerm_management_lock" "rg_lock" {
name = "Terraform (ReadOnly) - ${random_id.lock.hex}"
name = "Terraform (CanNotDelete) - ${random_id.lock.hex}"
scope = azurerm_resource_group.rg.id
lock_level = "ReadOnly"
notes = "ReadOnly Lock managed by Terraform to prevent manual or accidental modification of resource group and resources"
lock_level = "CanNotDelete"
notes = "CanNotDelete Lock managed by Terraform to prevent manual or accidental deletion of resource group and resources"
}
7 changes: 7 additions & 0 deletions terraform/key_vault.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ resource "azurerm_key_vault" "kv" {
}
}

resource "azurerm_management_lock" "kv_lock" {
name = "Terraform (CanNotDelete) - ${random_id.lock.hex}"
scope = azurerm_key_vault.kv.id
lock_level = "CanNotDelete"
notes = "CanNotDelete Lock managed by Terraform to prevent manual or accidental deletion of resource group and resources"
}

resource "azurerm_role_assignment" "web_app_kv_role_assignment" {
scope = azurerm_key_vault.kv.id
role_definition_name = "Key Vault Secrets User"
Expand Down

0 comments on commit be63920

Please sign in to comment.