Skip to content

Commit

Permalink
Experiment with Terraform managed lock
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Dec 9, 2023
1 parent 83c91fc commit 6b6b57e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions terraform/common.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ resource "azurerm_resource_group" "rg" {

tags = var.tags
}

resource "azurerm_management_lock" "rg_lock" {
name = "Terraform Lock - ${random_id.lock.hex}"
scope = azurerm_resource_group.rg.id
lock_level = "ReadOnly"
notes = "Lock managed by Terraform to prevent manual change or accidental deletion of the resource group or resources"
}
7 changes: 7 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ resource "random_id" "environment_id" {
resource "time_rotating" "thirty_days" {
rotation_days = 30
}

resource "random_id" "lock" {
keepers = {
id = "${timestamp()}"
}
byte_length = 8
}

0 comments on commit 6b6b57e

Please sign in to comment.