From 45df8b80b22adae8a5537bfb727cddea93f22a86 Mon Sep 17 00:00:00 2001 From: Vimukthi Perera Date: Thu, 21 Nov 2024 21:11:16 +0530 Subject: [PATCH] Refactor synapse workspace module --- .../outputs.tf | 0 .../synapse_workspace_storage_account.tf} | 23 +++++++++++++++++-- .../variables.tf | 5 ++++ .../versions.tf | 0 4 files changed, 26 insertions(+), 2 deletions(-) rename modules/azurerm/{Synapse-Workspace => Synapse-Workspace-Storage-Account}/outputs.tf (100%) rename modules/azurerm/{Synapse-Workspace/synapse_workspace.tf => Synapse-Workspace-Storage-Account/synapse_workspace_storage_account.tf} (62%) rename modules/azurerm/{Synapse-Workspace => Synapse-Workspace-Storage-Account}/variables.tf (93%) rename modules/azurerm/{Synapse-Workspace => Synapse-Workspace-Storage-Account}/versions.tf (100%) diff --git a/modules/azurerm/Synapse-Workspace/outputs.tf b/modules/azurerm/Synapse-Workspace-Storage-Account/outputs.tf similarity index 100% rename from modules/azurerm/Synapse-Workspace/outputs.tf rename to modules/azurerm/Synapse-Workspace-Storage-Account/outputs.tf diff --git a/modules/azurerm/Synapse-Workspace/synapse_workspace.tf b/modules/azurerm/Synapse-Workspace-Storage-Account/synapse_workspace_storage_account.tf similarity index 62% rename from modules/azurerm/Synapse-Workspace/synapse_workspace.tf rename to modules/azurerm/Synapse-Workspace-Storage-Account/synapse_workspace_storage_account.tf index fda072ad..5ceb0f94 100644 --- a/modules/azurerm/Synapse-Workspace/synapse_workspace.tf +++ b/modules/azurerm/Synapse-Workspace-Storage-Account/synapse_workspace_storage_account.tf @@ -18,14 +18,33 @@ # # -------------------------------------------------------------------------------------- +resource "azurerm_storage_account" "storage_account" { + name = join("", ["st", var.storage_account_name]) + resource_group_name = var.resource_group_name + location = var.location + account_tier = "Standard" + account_replication_type = "LRS" + account_kind = "StorageV2" + is_hns_enabled = true + tags = var.tags +} + +resource "azurerm_storage_data_lake_gen2_filesystem" "storage_data_lake_gen2_filesystem" { + name = join("", ["fs", var.storage_account_name]) + storage_account_id = azurerm_storage_account.storage_account.id +} + resource "azurerm_synapse_workspace" "synapse_workspace" { name = join("-", ["synw", var.name]) resource_group_name = var.resource_group_name location = var.location - storage_data_lake_gen2_filesystem_id = var.storage_data_lake_gen2_filesystem_id + storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.storage_data_lake_gen2_filesystem.id sql_administrator_login = var.sql_administrator_login sql_administrator_login_password = var.sql_administrator_login_password managed_virtual_network_enabled = var.managed_virtual_network_enabled data_exfiltration_protection_enabled = var.data_exfiltration_protection_enabled - tags = var.tags + identity { + type = "SystemAssigned" + } + tags = var.tags } diff --git a/modules/azurerm/Synapse-Workspace/variables.tf b/modules/azurerm/Synapse-Workspace-Storage-Account/variables.tf similarity index 93% rename from modules/azurerm/Synapse-Workspace/variables.tf rename to modules/azurerm/Synapse-Workspace-Storage-Account/variables.tf index d8b0e00e..0d0bf57d 100644 --- a/modules/azurerm/Synapse-Workspace/variables.tf +++ b/modules/azurerm/Synapse-Workspace-Storage-Account/variables.tf @@ -61,6 +61,11 @@ variable "data_exfiltration_protection_enabled" { default = false } +variable "storage_account_name" { + description = "The name of the Storage account linked to the Synapse Workspace" + type = string +} + variable "tags" { description = "A mapping of tags to assign to the resource" type = map(string) diff --git a/modules/azurerm/Synapse-Workspace/versions.tf b/modules/azurerm/Synapse-Workspace-Storage-Account/versions.tf similarity index 100% rename from modules/azurerm/Synapse-Workspace/versions.tf rename to modules/azurerm/Synapse-Workspace-Storage-Account/versions.tf