Skip to content

Commit

Permalink
Add Teraform resource lock and harden storage
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Dec 9, 2023
1 parent b46ab0e commit d8d3587
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion terraform/app_data_storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ resource "azurerm_storage_account" "app_data_storage" {
account_kind = "StorageV2"
access_tier = "Hot"

enable_https_traffic_only = true
min_tls_version = "TLS1_2"
enable_https_traffic_only = true

public_network_access_enabled = false

network_rules {
default_action = "Deny"
bypass = ["AzureServices"]
}

tags = var.tags
}
Expand Down
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 (ReadOnly) - ${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"
}
7 changes: 7 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,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 d8d3587

Please sign in to comment.