Skip to content

Commit

Permalink
Refactor Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Jul 1, 2024
1 parent be34f68 commit 6cb45d7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
27 changes: 15 additions & 12 deletions terraform/common.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
resource "azurerm_resource_group" "rg" {
name = local.resource_group_name
location = var.location
data "azurerm_client_config" "current" {}

tags = var.tags
data "azuread_client_config" "current" {}

resource "random_id" "environment_id" {
byte_length = 6
}

resource "time_rotating" "thirty_days" {
rotation_days = 30
}

//resource "azurerm_management_lock" "rg_lock" {
// count = var.environment == "prd" ? 1 : 0
//
// name = "Terraform (CanNotDelete) - ${random_id.lock.hex}"
// scope = azurerm_resource_group.rg.id
// lock_level = "CanNotDelete"
// notes = "CanNotDelete Lock managed by Terraform to prevent manual or accidental deletion of resource group and resources"
//}
resource "random_id" "lock" {
keepers = {
id = "${timestamp()}"
}
byte_length = 8
}
19 changes: 0 additions & 19 deletions terraform/main.tf → terraform/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,3 @@ provider "azurerm" {
}
}
}

data "azurerm_client_config" "current" {}

data "azuread_client_config" "current" {}

resource "random_id" "environment_id" {
byte_length = 6
}

resource "time_rotating" "thirty_days" {
rotation_days = 30
}

resource "random_id" "lock" {
keepers = {
id = "${timestamp()}"
}
byte_length = 8
}
15 changes: 15 additions & 0 deletions terraform/resource_group.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "azurerm_resource_group" "rg" {
name = local.resource_group_name
location = var.location

tags = var.tags
}

//resource "azurerm_management_lock" "rg_lock" {
// count = var.environment == "prd" ? 1 : 0
//
// name = "Terraform (CanNotDelete) - ${random_id.lock.hex}"
// scope = azurerm_resource_group.rg.id
// lock_level = "CanNotDelete"
// notes = "CanNotDelete Lock managed by Terraform to prevent manual or accidental deletion of resource group and resources"
//}

0 comments on commit 6cb45d7

Please sign in to comment.