From 9e55613c09ceb528f3517a3fe077080c25a1bb12 Mon Sep 17 00:00:00 2001 From: velotioaastha Date: Mon, 29 Jul 2024 16:26:56 +0530 Subject: [PATCH] updated boyb codebase --- examples/byob/main.tf | 16 +++++++++------- examples/byob/terraform.tfvars | 5 ++++- examples/byob/variables.tf | 7 ++++++- main.tf | 3 --- modules/byob/main.tf | 30 +++++++++++++++--------------- modules/byob/variables.tf | 11 ++++++++++- 6 files changed, 44 insertions(+), 28 deletions(-) diff --git a/examples/byob/main.tf b/examples/byob/main.tf index bb64114..bc02d4f 100644 --- a/examples/byob/main.tf +++ b/examples/byob/main.tf @@ -3,13 +3,15 @@ provider "azurerm" { } module "byob" { - source = "../../modules/byob" - resource_group_name = { name = "${var.rg_name}", id = "byob" } - location = var.location - prefix = var.prefix - deletion_protection = var.deletion_protection - create_cmk = var.create_cmk - rg_name = var.rg_name + source = "../../modules/byob" + resource_group_name = { name = "${var.rg_name}", id = "byob" } + location = var.location + prefix = var.prefix + deletion_protection = var.deletion_protection + create_cmk = var.enable_encryption + rg_name = var.rg_name + purge_protection_enabled = true + tags = var.tags } output "blob_container" { diff --git a/examples/byob/terraform.tfvars b/examples/byob/terraform.tfvars index aea9a0d..8b5b795 100644 --- a/examples/byob/terraform.tfvars +++ b/examples/byob/terraform.tfvars @@ -1,4 +1,7 @@ rg_name = "rg-name" location = "westeurope" prefix = "byob-wandb" -create_cmk = false +tags = { + "name" = "wandb" +} +enable_encryption = true \ No newline at end of file diff --git a/examples/byob/variables.tf b/examples/byob/variables.tf index a21f84a..178088d 100644 --- a/examples/byob/variables.tf +++ b/examples/byob/variables.tf @@ -17,6 +17,11 @@ variable "deletion_protection" { type = bool default = false } -variable "create_cmk" { +variable "enable_encryption" { type = bool +} + +variable "tags" { + type = map(string) + description = "Map of tags for resource" } \ No newline at end of file diff --git a/main.tf b/main.tf index 6123809..75f3948 100644 --- a/main.tf +++ b/main.tf @@ -114,9 +114,6 @@ locals { wb_managed_key_id_storage = contains(keys(local.filtered_vault_key_map), "storage") ? azurerm_key_vault_key.encryption_keys["storage"].id : null } - - - module "storage" { count = (var.blob_container == "" && var.external_bucket == null) ? 1 : 0 source = "./modules/storage" diff --git a/modules/byob/main.tf b/modules/byob/main.tf index 3cb1a6d..05ccdad 100644 --- a/modules/byob/main.tf +++ b/modules/byob/main.tf @@ -1,16 +1,3 @@ -module "storage" { - source = "../storage" - create_queue = false - namespace = var.prefix - resource_group_name = var.resource_group_name.name - location = var.location - deletion_protection = var.deletion_protection - wb_managed_key_id = var.create_cmk == true ? azurerm_key_vault_key.Vault_key[0].versionless_id : null - identity_ids = var.create_cmk == true ? module.identity[0].identity.id : null - dynamic_create_cmk = var.create_cmk - -} - module "identity" { count = var.create_cmk ? 1 : 0 source = "../identity" @@ -27,8 +14,10 @@ module "vault" { resource_group = { name = "${var.rg_name}", id = "byob" } location = var.location - identity_object_id = module.identity[0].identity.principal_id - depends_on = [module.identity] + identity_object_id = module.identity[0].identity.principal_id + depends_on = [module.identity] + tags = var.tags + purge_protection_enabled = var.purge_protection_enabled } resource "azurerm_key_vault_key" "Vault_key" { @@ -51,3 +40,14 @@ resource "azurerm_key_vault_key" "Vault_key" { module.vault ] } +module "storage" { + source = "../storage" + create_queue = false + namespace = var.prefix + resource_group_name = var.resource_group_name.name + location = var.location + deletion_protection = var.deletion_protection + wb_managed_key_id = var.create_cmk == true ? azurerm_key_vault_key.Vault_key[0].versionless_id : null + identity_ids = var.create_cmk == true ? module.identity[0].identity.id : null +} + diff --git a/modules/byob/variables.tf b/modules/byob/variables.tf index 9f08932..0815d6b 100644 --- a/modules/byob/variables.tf +++ b/modules/byob/variables.tf @@ -27,7 +27,16 @@ variable "rg_name" { type = string } - variable "create_cmk" { type = bool +} + +variable "tags" { + type = map(string) + description = "Map of tags for resource" +} + +variable "purge_protection_enabled" { + type = bool + description = "Enable or disable purge protection for the Key Vault." } \ No newline at end of file