From 45e7eb06bf3689ec4649faa1b8e5467d21d8a89b Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 21:00:21 +0200 Subject: [PATCH 01/34] Update log level --- .github/workflows/terraform-fabricworkspace.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform-fabricworkspace.yml b/.github/workflows/terraform-fabricworkspace.yml index bbf2ba1..0f033a9 100644 --- a/.github/workflows/terraform-fabricworkspace.yml +++ b/.github/workflows/terraform-fabricworkspace.yml @@ -26,6 +26,6 @@ jobs: tenant_id: "37963dd4-f4e6-40f8-a7d6-24b97919e452" subscription_id: "1fdab118-1638-419a-8b12-06c9543714a0" run_test: false - log_level_test: "DEBUG" + log_level_test: "ERROR" secrets: CLIENT_ID: ${{ secrets.CLIENT_ID }} From a982e931c96029e6213951b82a317e2c62fab065 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 21:12:40 +0200 Subject: [PATCH 02/34] Update configuration --- .github/workflows/_terraformTestTemplate.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index 2cf79db..f704892 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -112,7 +112,8 @@ jobs: ARM_USE_OIDC: true FABRIC_TENANT_ID: ${{ inputs.tenant_id }} FABRIC_CLIENT_ID: ${{ secrets.CLIENT_ID }} - FABRIC_USE_OIDC: true + FABRIC_USE_MSI: true + # FABRIC_USE_OIDC: true steps: # Setup Node From 88640c06478ed7691e960f8668991faa0413ee04 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 21:16:38 +0200 Subject: [PATCH 03/34] try test --- .github/workflows/terraform-fabricworkspace.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform-fabricworkspace.yml b/.github/workflows/terraform-fabricworkspace.yml index 0f033a9..d065fea 100644 --- a/.github/workflows/terraform-fabricworkspace.yml +++ b/.github/workflows/terraform-fabricworkspace.yml @@ -25,7 +25,7 @@ jobs: node_version: 20 tenant_id: "37963dd4-f4e6-40f8-a7d6-24b97919e452" subscription_id: "1fdab118-1638-419a-8b12-06c9543714a0" - run_test: false + run_test: true log_level_test: "ERROR" secrets: CLIENT_ID: ${{ secrets.CLIENT_ID }} From e956cf48082cce8ecf32811be4eb7aef6c7cc3ba Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 21:19:29 +0200 Subject: [PATCH 04/34] Update env variable --- .github/workflows/_terraformTestTemplate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index f704892..af0e018 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -113,7 +113,7 @@ jobs: FABRIC_TENANT_ID: ${{ inputs.tenant_id }} FABRIC_CLIENT_ID: ${{ secrets.CLIENT_ID }} FABRIC_USE_MSI: true - # FABRIC_USE_OIDC: true + FABRIC_USE_OIDC: false steps: # Setup Node From ef8ff4ec70393034468e6b9977177e304ebfa6b2 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 21:48:27 +0200 Subject: [PATCH 05/34] Test deployment --- modules/fabricworkspace/README.md | 2 +- modules/fabricworkspace/data.tf | 11 +--- modules/fabricworkspace/locals.tf | 8 +-- modules/fabricworkspace/main.tf | 92 ++++++++++++++-------------- modules/fabricworkspace/terraform.tf | 2 +- 5 files changed, 53 insertions(+), 62 deletions(-) diff --git a/modules/fabricworkspace/README.md b/modules/fabricworkspace/README.md index 48e7e1c..a7f26e4 100644 --- a/modules/fabricworkspace/README.md +++ b/modules/fabricworkspace/README.md @@ -14,7 +14,7 @@ The following requirements are needed by this module: - [azapi](#requirement\_azapi) (>= 1.14.0) -- [fabric](#requirement\_fabric) (0.1.0-beta.2) +- [fabric](#requirement\_fabric) (0.1.0-beta.3) ## Modules diff --git a/modules/fabricworkspace/data.tf b/modules/fabricworkspace/data.tf index 9b0dd44..ca01898 100644 --- a/modules/fabricworkspace/data.tf +++ b/modules/fabricworkspace/data.tf @@ -1,14 +1,7 @@ -data "azapi_resource" "fabric_capacity" { - count = var.workspace_capacity_id == null ? 0 : 1 - - type = "Microsoft.Fabric/capacities@2023-11-01" - resource_id = var.workspace_capacity_id - - response_export_values = ["*"] +data "fabric_capacity" "capacitiy" { + display_name = local.fabric_capacity.name } -data "fabric_capacities" "capacities" {} - # Not enabled as other workspaces not in the list would be removed from the domain # data "fabric_domain" "domain" { # count = var.workspace_domain_id == null ? 0 : 1 diff --git a/modules/fabricworkspace/locals.tf b/modules/fabricworkspace/locals.tf index 6feb0b4..ddb949f 100644 --- a/modules/fabricworkspace/locals.tf +++ b/modules/fabricworkspace/locals.tf @@ -1,7 +1,5 @@ locals { - fabric_capity_ids = [ - for value in data.fabric_capacities.capacities.values : - value.id if value.display_name == one(data.azapi_resource.fabric_capacity[*].name) && value.region == one(data.azapi_resource.fabric_capacity[*].location) && value.sku == one(data.azapi_resource.fabric_capacity[*].sku) - ] - fabric_capity_id = length(local.fabric_capity_ids) > 0 ? local.fabric_capity_ids[0] : null + fabric_capacity = { + name = split("/", var.workspace_capacity_id)[8] + } } diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 69a9950..3f88739 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -1,7 +1,7 @@ resource "fabric_workspace" "workspace" { display_name = var.workspace_display_name description = var.workspace_description - capacity_id = local.fabric_capity_id + capacity_id = data.fabric_capacity.capacitiy.id identity = var.workspace_identity_enabled ? { type = "SystemAssigned" } : null @@ -17,56 +17,56 @@ resource "fabric_workspace" "workspace" { # ] # } -resource "fabric_spark_workspace_settings" "workspace_settings" { - count = var.workspace_capacity_id == null ? 0 : 1 +# resource "fabric_spark_workspace_settings" "workspace_settings" { +# count = var.workspace_capacity_id == null ? 0 : 1 - workspace_id = fabric_workspace.workspace.id +# workspace_id = fabric_workspace.workspace.id - automatic_log = { - enabled = var.workspace_settings.automatic_log.enabled - } - environment = { - name = var.workspace_settings.environment.default_environment_name - runtime_version = var.workspace_settings.environment.runtime_version - } - high_concurrency = { - notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled - } - pool = { - customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled - default_pool = { - name = var.workspace_settings.pool.default_pool_name - type = var.workspace_capacity_id == null ? "Workspace" : "Capacity" - } - # starter_pool = { - # max_executors = 3 - # max_node_count = 1 - # } - } -} +# automatic_log = { +# enabled = var.workspace_settings.automatic_log.enabled +# } +# environment = { +# name = var.workspace_settings.environment.default_environment_name +# runtime_version = var.workspace_settings.environment.runtime_version +# } +# high_concurrency = { +# notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled +# } +# pool = { +# customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled +# default_pool = { +# name = var.workspace_settings.pool.default_pool_name +# type = var.workspace_capacity_id == null ? "Workspace" : "Capacity" +# } +# # starter_pool = { +# # max_executors = 3 +# # max_node_count = 1 +# # } +# } +# } -resource "fabric_workspace_git" "workspace_git" { - count = var.workspace_git == null ? 0 : 1 +# resource "fabric_workspace_git" "workspace_git" { +# count = var.workspace_git == null ? 0 : 1 - workspace_id = fabric_workspace.workspace.id +# workspace_id = fabric_workspace.workspace.id - git_provider_details = { - git_provider_type = var.workspace_git.git_provider_type - organization_name = var.workspace_git.organization_name - project_name = var.workspace_git.project_name - repository_name = var.workspace_git.repository_name - branch_name = var.workspace_git.branch_name - directory_name = var.workspace_git.directory_name - } - initialization_strategy = "PreferWorkspace" -} +# git_provider_details = { +# git_provider_type = var.workspace_git.git_provider_type +# organization_name = var.workspace_git.organization_name +# project_name = var.workspace_git.project_name +# repository_name = var.workspace_git.repository_name +# branch_name = var.workspace_git.branch_name +# directory_name = var.workspace_git.directory_name +# } +# initialization_strategy = "PreferWorkspace" +# } -resource "fabric_workspace_role_assignment" "example" { - for_each = var.workspace_role_assignments +# resource "fabric_workspace_role_assignment" "example" { +# for_each = var.workspace_role_assignments - workspace_id = fabric_workspace.workspace.id +# workspace_id = fabric_workspace.workspace.id - principal_id = each.value.principal_id - principal_type = each.value.principal_type - role = each.value.role -} +# principal_id = each.value.principal_id +# principal_type = each.value.principal_type +# role = each.value.role +# } diff --git a/modules/fabricworkspace/terraform.tf b/modules/fabricworkspace/terraform.tf index 6183560..f44254e 100644 --- a/modules/fabricworkspace/terraform.tf +++ b/modules/fabricworkspace/terraform.tf @@ -8,7 +8,7 @@ terraform { } fabric = { source = "microsoft/fabric" - version = "0.1.0-beta.2" + version = "0.1.0-beta.3" } } } From 0992b4b73293c92f3b2e8acac12a94c5a0baae8d Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 21:51:48 +0200 Subject: [PATCH 06/34] Update logs --- .github/workflows/terraform-fabricworkspace.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/terraform-fabricworkspace.yml b/.github/workflows/terraform-fabricworkspace.yml index d065fea..3bf6bf9 100644 --- a/.github/workflows/terraform-fabricworkspace.yml +++ b/.github/workflows/terraform-fabricworkspace.yml @@ -26,6 +26,6 @@ jobs: tenant_id: "37963dd4-f4e6-40f8-a7d6-24b97919e452" subscription_id: "1fdab118-1638-419a-8b12-06c9543714a0" run_test: true - log_level_test: "ERROR" + log_level_test: "DEBUG" secrets: CLIENT_ID: ${{ secrets.CLIENT_ID }} From b5a86b557da6e61e014b1e1c8e691b827dd7032c Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 22:02:45 +0200 Subject: [PATCH 07/34] Update to workspace name --- modules/fabriccapacity/README.md | 4 ++++ modules/fabriccapacity/outputs.tf | 6 ++++++ modules/fabricworkspace/README.md | 4 ++-- modules/fabricworkspace/data.tf | 2 +- modules/fabricworkspace/locals.tf | 6 +++--- modules/fabricworkspace/tests/test.tftest.hcl | 2 +- modules/fabricworkspace/variables.tf | 8 ++++---- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/modules/fabriccapacity/README.md b/modules/fabriccapacity/README.md index a21321d..217ae12 100644 --- a/modules/fabriccapacity/README.md +++ b/modules/fabriccapacity/README.md @@ -78,6 +78,10 @@ The following outputs are exported: Description: Specifies the id of the fabric capacity. +### [fabric\_capacity\_name](#output\_fabric\_capacity\_name) + +Description: Specifies the name of the fabric capacity. + \ No newline at end of file diff --git a/modules/fabriccapacity/outputs.tf b/modules/fabriccapacity/outputs.tf index 4f1fb2a..f7cf226 100644 --- a/modules/fabriccapacity/outputs.tf +++ b/modules/fabriccapacity/outputs.tf @@ -3,3 +3,9 @@ output "fabric_capacity_id" { value = azapi_resource.fabric_capacity.id sensitive = false } + +output "fabric_capacity_name" { + description = "Specifies the name of the fabric capacity." + value = azapi_resource.fabric_capacity.name + sensitive = false +} diff --git a/modules/fabricworkspace/README.md b/modules/fabricworkspace/README.md index a7f26e4..27a4a55 100644 --- a/modules/fabricworkspace/README.md +++ b/modules/fabricworkspace/README.md @@ -36,9 +36,9 @@ Type: `string` The following input variables are optional (have default values): -### [workspace\_capacity\_id](#input\_workspace\_capacity\_id) +### [workspace\_capacity\_name](#input\_workspace\_capacity\_name) -Description: Specifies the resource id of a fabric capacity hosted in Azure to assign to the fabric workspace. +Description: Specifies the name of a fabric capacity hosted in Azure to assign to the fabric workspace. Type: `string` diff --git a/modules/fabricworkspace/data.tf b/modules/fabricworkspace/data.tf index ca01898..798754a 100644 --- a/modules/fabricworkspace/data.tf +++ b/modules/fabricworkspace/data.tf @@ -1,5 +1,5 @@ data "fabric_capacity" "capacitiy" { - display_name = local.fabric_capacity.name + display_name = var.workspace_capacity_name } # Not enabled as other workspaces not in the list would be removed from the domain diff --git a/modules/fabricworkspace/locals.tf b/modules/fabricworkspace/locals.tf index ddb949f..3275bca 100644 --- a/modules/fabricworkspace/locals.tf +++ b/modules/fabricworkspace/locals.tf @@ -1,5 +1,5 @@ locals { - fabric_capacity = { - name = split("/", var.workspace_capacity_id)[8] - } + # fabric_capacity = { + # name = split("/", var.workspace_capacity_id)[8] + # } } diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 40af970..34f474a 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -72,7 +72,7 @@ run "create_fabric_workspace" { command = apply variables { - workspace_capacity_id = run.setup.fabric_capacity_id + workspace_capacity_name = run.setup.fabric_capacity_name workspace_display_name = "MyTestWs" workspace_description = "My Test Workspace" workspace_identity_enabled = false diff --git a/modules/fabricworkspace/variables.tf b/modules/fabricworkspace/variables.tf index 335af14..2733646 100644 --- a/modules/fabricworkspace/variables.tf +++ b/modules/fabricworkspace/variables.tf @@ -1,15 +1,15 @@ # General variables # Fabric workspace variables -variable "workspace_capacity_id" { - description = "Specifies the resource id of a fabric capacity hosted in Azure to assign to the fabric workspace." +variable "workspace_capacity_name" { + description = "Specifies the name of a fabric capacity hosted in Azure to assign to the fabric workspace." type = string sensitive = false nullable = true default = null validation { - condition = var.workspace_capacity_id == null || can(length(split("/", var.workspace_capacity_id)) == 9) - error_message = "Please specify a valid capacity id." + condition = var.workspace_capacity_name == null || length(var.workspace_capacity_id) > 2 + error_message = "Please specify a valid capacity name." } } From 0372548813f4212f4376d853c0171b2515bbd369 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 30 Sep 2024 22:09:10 +0200 Subject: [PATCH 08/34] Fix bug --- .github/workflows/terraform-fabricworkspace.yml | 2 +- modules/fabricworkspace/variables.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform-fabricworkspace.yml b/.github/workflows/terraform-fabricworkspace.yml index 3bf6bf9..d065fea 100644 --- a/.github/workflows/terraform-fabricworkspace.yml +++ b/.github/workflows/terraform-fabricworkspace.yml @@ -26,6 +26,6 @@ jobs: tenant_id: "37963dd4-f4e6-40f8-a7d6-24b97919e452" subscription_id: "1fdab118-1638-419a-8b12-06c9543714a0" run_test: true - log_level_test: "DEBUG" + log_level_test: "ERROR" secrets: CLIENT_ID: ${{ secrets.CLIENT_ID }} diff --git a/modules/fabricworkspace/variables.tf b/modules/fabricworkspace/variables.tf index 2733646..10a92af 100644 --- a/modules/fabricworkspace/variables.tf +++ b/modules/fabricworkspace/variables.tf @@ -8,7 +8,7 @@ variable "workspace_capacity_name" { nullable = true default = null validation { - condition = var.workspace_capacity_name == null || length(var.workspace_capacity_id) > 2 + condition = var.workspace_capacity_name == null || length(var.workspace_capacity_name) > 2 error_message = "Please specify a valid capacity name." } } @@ -52,7 +52,7 @@ variable "workspace_identity_enabled" { nullable = false default = true validation { - condition = !var.workspace_identity_enabled || var.workspace_identity_enabled && var.workspace_capacity_id != null + condition = !var.workspace_identity_enabled || var.workspace_identity_enabled && var.workspace_capacity_name != null error_message = "Please specify a capacity id to enable the workspace identity." } } From b651782ee29c229589a5944776f4702f0246fb92 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 14:41:55 +0200 Subject: [PATCH 09/34] Run another test --- modules/fabricworkspace/tests/setup/outputs.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/fabricworkspace/tests/setup/outputs.tf b/modules/fabricworkspace/tests/setup/outputs.tf index 421204c..6b53b7a 100644 --- a/modules/fabricworkspace/tests/setup/outputs.tf +++ b/modules/fabricworkspace/tests/setup/outputs.tf @@ -3,3 +3,9 @@ output "fabric_capacity_id" { value = module.fabric_capacity.fabric_capacity_id sensitive = false } + +output "fabric_capacity_name" { + description = "Specifies the id of the fabric capacity." + value = module.fabric_capacity.fabric_capacity_name + sensitive = false +} From a32ba29b3525daec71b2a6789bd66ffb6fe3741e Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 15:45:44 +0200 Subject: [PATCH 10/34] Test --- .github/workflows/_terraformTestTemplate.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index 2a8c3ed..0b3d338 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -101,7 +101,7 @@ jobs: test: name: Terraform Test - runs-on: [self-hosted] + runs-on: [ubuntu-latest] # [self-hosted] continue-on-error: false environment: ${{ inputs.environment }} if: inputs.run_test @@ -117,8 +117,8 @@ jobs: ARM_USE_OIDC: true FABRIC_TENANT_ID: ${{ inputs.tenant_id }} FABRIC_CLIENT_ID: ${{ secrets.CLIENT_ID }} - FABRIC_USE_MSI: true - FABRIC_USE_OIDC: false + # FABRIC_USE_MSI: true + FABRIC_USE_OIDC: true steps: # Setup Node From 1695242552e4d6db096ea6acb2166e133882ba4b Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 16:26:26 +0200 Subject: [PATCH 11/34] test --- .github/workflows/_terraformTestTemplate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index 0b3d338..62f0783 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -117,8 +117,8 @@ jobs: ARM_USE_OIDC: true FABRIC_TENANT_ID: ${{ inputs.tenant_id }} FABRIC_CLIENT_ID: ${{ secrets.CLIENT_ID }} - # FABRIC_USE_MSI: true - FABRIC_USE_OIDC: true + FABRIC_USE_MSI: true + FABRIC_USE_OIDC: false steps: # Setup Node From 4ad36815532ecf432e3d7833abc03fa3274f458c Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 16:30:33 +0200 Subject: [PATCH 12/34] Test --- modules/fabricworkspace/data.tf | 2 +- modules/fabricworkspace/main.tf | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/fabricworkspace/data.tf b/modules/fabricworkspace/data.tf index 798754a..7691e79 100644 --- a/modules/fabricworkspace/data.tf +++ b/modules/fabricworkspace/data.tf @@ -1,5 +1,5 @@ data "fabric_capacity" "capacitiy" { - display_name = var.workspace_capacity_name + display_name = "mabutst" # var.workspace_capacity_name } # Not enabled as other workspaces not in the list would be removed from the domain diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 3f88739..e6dccde 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -1,11 +1,11 @@ -resource "fabric_workspace" "workspace" { - display_name = var.workspace_display_name - description = var.workspace_description - capacity_id = data.fabric_capacity.capacitiy.id - identity = var.workspace_identity_enabled ? { - type = "SystemAssigned" - } : null -} +# resource "fabric_workspace" "workspace" { +# display_name = var.workspace_display_name +# description = var.workspace_description +# capacity_id = data.fabric_capacity.capacitiy.id +# identity = var.workspace_identity_enabled ? { +# type = "SystemAssigned" +# } : null +# } # Not enabled as other workspaces not in the list would be removed from the domain # resource "fabric_domain_workspace_assignments" "domain_workspace_assignments" { From eee3e4c6b7909b44fb55d1ffd578eb1d32fddff0 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 16:44:58 +0200 Subject: [PATCH 13/34] test oidc --- .github/workflows/_terraformTestTemplate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index 62f0783..0b3d338 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -117,8 +117,8 @@ jobs: ARM_USE_OIDC: true FABRIC_TENANT_ID: ${{ inputs.tenant_id }} FABRIC_CLIENT_ID: ${{ secrets.CLIENT_ID }} - FABRIC_USE_MSI: true - FABRIC_USE_OIDC: false + # FABRIC_USE_MSI: true + FABRIC_USE_OIDC: true steps: # Setup Node From 1e4c38d489d61f47d5b94a13d3908df1fbd7ccb1 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 16:49:18 +0200 Subject: [PATCH 14/34] test --- modules/fabricworkspace/tests/test.tftest.hcl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 34f474a..51071e5 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -96,8 +96,8 @@ run "create_fabric_workspace" { workspace_role_assignments = {} } - assert { - condition = fabric_workspace.workspace.display_name == "MyTestWs" - error_message = "Failed to deploy." - } + # assert { + # condition = fabric_workspace.workspace.display_name == "MyTestWs" + # error_message = "Failed to deploy." + # } } From 9c28f817389e25337adc272a9c903c7bc63dc9d8 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 16:59:15 +0200 Subject: [PATCH 15/34] Test with custom capacity --- modules/fabricworkspace/data.tf | 4 ++++ modules/fabricworkspace/tests/setup/outputs.tf | 2 +- modules/fabricworkspace/variables.tf | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/fabricworkspace/data.tf b/modules/fabricworkspace/data.tf index 7691e79..f30053b 100644 --- a/modules/fabricworkspace/data.tf +++ b/modules/fabricworkspace/data.tf @@ -2,6 +2,10 @@ data "fabric_capacity" "capacitiy" { display_name = "mabutst" # var.workspace_capacity_name } +data "fabric_capacity" "capacity" { + display_name = var.workspace_capacity_name +} + # Not enabled as other workspaces not in the list would be removed from the domain # data "fabric_domain" "domain" { # count = var.workspace_domain_id == null ? 0 : 1 diff --git a/modules/fabricworkspace/tests/setup/outputs.tf b/modules/fabricworkspace/tests/setup/outputs.tf index 6b53b7a..06e8852 100644 --- a/modules/fabricworkspace/tests/setup/outputs.tf +++ b/modules/fabricworkspace/tests/setup/outputs.tf @@ -5,7 +5,7 @@ output "fabric_capacity_id" { } output "fabric_capacity_name" { - description = "Specifies the id of the fabric capacity." + description = "Specifies the name of the fabric capacity." value = module.fabric_capacity.fabric_capacity_name sensitive = false } diff --git a/modules/fabricworkspace/variables.tf b/modules/fabricworkspace/variables.tf index 10a92af..52d8ef5 100644 --- a/modules/fabricworkspace/variables.tf +++ b/modules/fabricworkspace/variables.tf @@ -8,8 +8,8 @@ variable "workspace_capacity_name" { nullable = true default = null validation { - condition = var.workspace_capacity_name == null || length(var.workspace_capacity_name) > 2 - error_message = "Please specify a valid capacity name." + condition = length(var.workspace_capacity_name) >= 2 && length(regexall("[^[:alnum:]]", var.workspace_capacity_name)) <= 0 + error_message = "Please specify a valid name." } } From eb5a13b77b149905d92d7164ab518bb26a75336d Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:01:35 +0200 Subject: [PATCH 16/34] Try self-hosted --- .github/workflows/_terraformTestTemplate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index 0b3d338..262610f 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -101,7 +101,7 @@ jobs: test: name: Terraform Test - runs-on: [ubuntu-latest] # [self-hosted] + runs-on: [self-hosted] continue-on-error: false environment: ${{ inputs.environment }} if: inputs.run_test From d0f52cc181b3f1361131f2905cdb18a4a2fd777e Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:11:42 +0200 Subject: [PATCH 17/34] Configure runner label --- .github/workflows/_terraformTestTemplate.yml | 8 ++++++-- .github/workflows/terraform-fabricworkspace.yml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index 262610f..ddca96c 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -7,6 +7,11 @@ on: required: true type: string description: "Specifies the environment of the deployment." + runner_label: + required: false + type: string + description: "Specifies the runner label." + default: "self-hosted" config: required: true type: string @@ -101,7 +106,7 @@ jobs: test: name: Terraform Test - runs-on: [self-hosted] + runs-on: [${{ inputs.runner_label }}] continue-on-error: false environment: ${{ inputs.environment }} if: inputs.run_test @@ -117,7 +122,6 @@ jobs: ARM_USE_OIDC: true FABRIC_TENANT_ID: ${{ inputs.tenant_id }} FABRIC_CLIENT_ID: ${{ secrets.CLIENT_ID }} - # FABRIC_USE_MSI: true FABRIC_USE_OIDC: true steps: diff --git a/.github/workflows/terraform-fabricworkspace.yml b/.github/workflows/terraform-fabricworkspace.yml index d065fea..69f4906 100644 --- a/.github/workflows/terraform-fabricworkspace.yml +++ b/.github/workflows/terraform-fabricworkspace.yml @@ -20,6 +20,7 @@ jobs: name: "Dev" with: environment: "dev" + runner_label: "ubuntu-latest" config: "fabricworkspace" terraform_version: "1.9.6" node_version: 20 From 047bc7b4d7c586e36b2db183d14dee276cf03456 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:19:10 +0200 Subject: [PATCH 18/34] anotehr test --- .github/workflows/_terraformTestTemplate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_terraformTestTemplate.yml b/.github/workflows/_terraformTestTemplate.yml index ddca96c..a4b58ff 100644 --- a/.github/workflows/_terraformTestTemplate.yml +++ b/.github/workflows/_terraformTestTemplate.yml @@ -106,7 +106,7 @@ jobs: test: name: Terraform Test - runs-on: [${{ inputs.runner_label }}] + runs-on: ${{ inputs.runner_label }} continue-on-error: false environment: ${{ inputs.environment }} if: inputs.run_test From 3d650d822db47dbae41e8aa9378a0e483353cd49 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:26:51 +0200 Subject: [PATCH 19/34] Update fabric capacity --- modules/fabriccapacity/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fabriccapacity/main.tf b/modules/fabriccapacity/main.tf index 8f00ef1..3b44872 100644 --- a/modules/fabriccapacity/main.tf +++ b/modules/fabriccapacity/main.tf @@ -18,7 +18,7 @@ resource "azapi_resource" "fabric_capacity" { } response_export_values = [] - schema_validation_enabled = false # Can be reverted once this is closed: https://github.com/Azure/terraform-provider-azapi/issues/524 + schema_validation_enabled = true locks = [] ignore_casing = false ignore_missing_property = true From f561e228c06fc0c669636c7dcfc4737aca5c643b Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:30:12 +0200 Subject: [PATCH 20/34] Test workspace creation --- modules/fabricworkspace/data.tf | 4 ---- modules/fabricworkspace/locals.tf | 5 ----- modules/fabricworkspace/main.tf | 16 ++++++++-------- 3 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 modules/fabricworkspace/locals.tf diff --git a/modules/fabricworkspace/data.tf b/modules/fabricworkspace/data.tf index f30053b..591fc0d 100644 --- a/modules/fabricworkspace/data.tf +++ b/modules/fabricworkspace/data.tf @@ -1,7 +1,3 @@ -data "fabric_capacity" "capacitiy" { - display_name = "mabutst" # var.workspace_capacity_name -} - data "fabric_capacity" "capacity" { display_name = var.workspace_capacity_name } diff --git a/modules/fabricworkspace/locals.tf b/modules/fabricworkspace/locals.tf deleted file mode 100644 index 3275bca..0000000 --- a/modules/fabricworkspace/locals.tf +++ /dev/null @@ -1,5 +0,0 @@ -locals { - # fabric_capacity = { - # name = split("/", var.workspace_capacity_id)[8] - # } -} diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index e6dccde..11c5912 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -1,11 +1,11 @@ -# resource "fabric_workspace" "workspace" { -# display_name = var.workspace_display_name -# description = var.workspace_description -# capacity_id = data.fabric_capacity.capacitiy.id -# identity = var.workspace_identity_enabled ? { -# type = "SystemAssigned" -# } : null -# } +resource "fabric_workspace" "workspace" { + display_name = var.workspace_display_name + description = var.workspace_description + capacity_id = data.fabric_capacity.capacity.id + identity = var.workspace_identity_enabled ? { + type = "SystemAssigned" + } : null +} # Not enabled as other workspaces not in the list would be removed from the domain # resource "fabric_domain_workspace_assignments" "domain_workspace_assignments" { From 4d3117482cc21d54af8c708cbbd09cdb3709b6e7 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:35:05 +0200 Subject: [PATCH 21/34] Test with workspace settings --- modules/fabricworkspace/main.tf | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 11c5912..b9d0fe3 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -17,33 +17,33 @@ resource "fabric_workspace" "workspace" { # ] # } -# resource "fabric_spark_workspace_settings" "workspace_settings" { -# count = var.workspace_capacity_id == null ? 0 : 1 +resource "fabric_spark_workspace_settings" "workspace_settings" { + count = var.workspace_capacity_name == null ? 0 : 1 -# workspace_id = fabric_workspace.workspace.id + workspace_id = fabric_workspace.workspace.id -# automatic_log = { -# enabled = var.workspace_settings.automatic_log.enabled -# } -# environment = { -# name = var.workspace_settings.environment.default_environment_name -# runtime_version = var.workspace_settings.environment.runtime_version -# } -# high_concurrency = { -# notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled -# } -# pool = { -# customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled -# default_pool = { -# name = var.workspace_settings.pool.default_pool_name -# type = var.workspace_capacity_id == null ? "Workspace" : "Capacity" -# } -# # starter_pool = { -# # max_executors = 3 -# # max_node_count = 1 -# # } -# } -# } + automatic_log = { + enabled = var.workspace_settings.automatic_log.enabled + } + environment = { + name = var.workspace_settings.environment.default_environment_name + runtime_version = var.workspace_settings.environment.runtime_version + } + high_concurrency = { + notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled + } + pool = { + customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled + default_pool = { + name = var.workspace_settings.pool.default_pool_name + type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" + } + # starter_pool = { + # max_executors = 3 + # max_node_count = 1 + # } + } +} # resource "fabric_workspace_git" "workspace_git" { # count = var.workspace_git == null ? 0 : 1 From 230ed0a8fb2a2512181bd36981e4b9faf4578ec1 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:41:48 +0200 Subject: [PATCH 22/34] Update default pool name --- modules/fabricworkspace/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fabricworkspace/variables.tf b/modules/fabricworkspace/variables.tf index 52d8ef5..c6ce797 100644 --- a/modules/fabricworkspace/variables.tf +++ b/modules/fabricworkspace/variables.tf @@ -72,7 +72,7 @@ variable "workspace_settings" { }), {}) pool = optional(object({ customize_compute_enabled = optional(bool, true) - default_pool_name = optional(string, "defaultpool") + default_pool_name = optional(string, "StarterPool") }), {}) }) sensitive = false From 58540aeab6def64f851fdc96e63c1d8a10e206a2 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:48:35 +0200 Subject: [PATCH 23/34] Update pool name --- modules/fabricworkspace/README.md | 2 +- modules/fabricworkspace/main.tf | 20 +++++++++---------- modules/fabricworkspace/tests/test.tftest.hcl | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/fabricworkspace/README.md b/modules/fabricworkspace/README.md index 27a4a55..d2bcef1 100644 --- a/modules/fabricworkspace/README.md +++ b/modules/fabricworkspace/README.md @@ -115,7 +115,7 @@ object({ }), {}) pool = optional(object({ customize_compute_enabled = optional(bool, true) - default_pool_name = optional(string, "defaultpool") + default_pool_name = optional(string, "StarterPool") }), {}) }) ``` diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index b9d0fe3..6824152 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -32,17 +32,17 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { high_concurrency = { notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled } - pool = { - customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled - default_pool = { - name = var.workspace_settings.pool.default_pool_name - type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" + pool = { + customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled + default_pool = { + name = var.workspace_settings.pool.default_pool_name + type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" + } + # starter_pool = { + # max_executors = 3 + # max_node_count = 1 + # } } - # starter_pool = { - # max_executors = 3 - # max_node_count = 1 - # } - } } # resource "fabric_workspace_git" "workspace_git" { diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 51071e5..35ca9da 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -89,7 +89,7 @@ run "create_fabric_workspace" { } pool = { customize_compute_enabled = true - default_pool_name = "defaultpool" + default_pool_name = "StarterPool" } } workspace_git = null From 5df3b559cffb69dfea3f01291f0f675c2cf367df Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:52:21 +0200 Subject: [PATCH 24/34] lint --- modules/fabricworkspace/main.tf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 6824152..b9d0fe3 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -32,17 +32,17 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { high_concurrency = { notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled } - pool = { - customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled - default_pool = { - name = var.workspace_settings.pool.default_pool_name - type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" - } - # starter_pool = { - # max_executors = 3 - # max_node_count = 1 - # } + pool = { + customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled + default_pool = { + name = var.workspace_settings.pool.default_pool_name + type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" } + # starter_pool = { + # max_executors = 3 + # max_node_count = 1 + # } + } } # resource "fabric_workspace_git" "workspace_git" { From e006d54e32e88bcf0454ff9431be795ffd468e3b Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 17:55:45 +0200 Subject: [PATCH 25/34] test --- modules/fabricworkspace/main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index b9d0fe3..560270e 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -34,10 +34,10 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { } pool = { customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled - default_pool = { - name = var.workspace_settings.pool.default_pool_name - type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" - } + # default_pool = { + # name = var.workspace_settings.pool.default_pool_name + # type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" + # } # starter_pool = { # max_executors = 3 # max_node_count = 1 From 395c572e3d2faf5ae1c965c479511d879f9b589c Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 18:20:10 +0200 Subject: [PATCH 26/34] test --- modules/fabricworkspace/main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 560270e..25adf1d 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -25,10 +25,10 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { automatic_log = { enabled = var.workspace_settings.automatic_log.enabled } - environment = { - name = var.workspace_settings.environment.default_environment_name - runtime_version = var.workspace_settings.environment.runtime_version - } + # environment = { + # name = var.workspace_settings.environment.default_environment_name + # runtime_version = var.workspace_settings.environment.runtime_version + # } high_concurrency = { notebook_interactive_run_enabled = var.workspace_settings.high_concurrency.notebook_interactive_run_enabled } From da796d508bdc7f0ad8f808a9e6ce381b9b5e8043 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 18:24:16 +0200 Subject: [PATCH 27/34] test starterpool --- modules/fabricworkspace/main.tf | 8 ++++---- modules/fabricworkspace/tests/test.tftest.hcl | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 25adf1d..63b09b9 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -34,10 +34,10 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { } pool = { customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled - # default_pool = { - # name = var.workspace_settings.pool.default_pool_name - # type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" - # } + default_pool = { + name = var.workspace_settings.pool.default_pool_name + type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" + } # starter_pool = { # max_executors = 3 # max_node_count = 1 diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 35ca9da..2a2dda0 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -89,7 +89,7 @@ run "create_fabric_workspace" { } pool = { customize_compute_enabled = true - default_pool_name = "StarterPool" + default_pool_name = "starterPool" } } workspace_git = null From 1f9822be5abce0a461e5a34fae893d3a62e74527 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 22:51:27 +0200 Subject: [PATCH 28/34] Comment out workspace config --- modules/fabricworkspace/main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 63b09b9..25adf1d 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -34,10 +34,10 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { } pool = { customize_compute_enabled = var.workspace_settings.pool.customize_compute_enabled - default_pool = { - name = var.workspace_settings.pool.default_pool_name - type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" - } + # default_pool = { + # name = var.workspace_settings.pool.default_pool_name + # type = var.workspace_capacity_name == null ? "Workspace" : "Capacity" + # } # starter_pool = { # max_executors = 3 # max_node_count = 1 From 0309d39ec1843ba5ed68e843b8c8dab0680d720e Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 22:56:58 +0200 Subject: [PATCH 29/34] Test role assignment --- modules/fabricworkspace/main.tf | 40 +++++++++---------- modules/fabricworkspace/tests/setup/data.tf | 1 + .../fabricworkspace/tests/setup/outputs.tf | 6 +++ modules/fabricworkspace/tests/test.tftest.hcl | 10 ++++- 4 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 modules/fabricworkspace/tests/setup/data.tf diff --git a/modules/fabricworkspace/main.tf b/modules/fabricworkspace/main.tf index 25adf1d..73495f9 100644 --- a/modules/fabricworkspace/main.tf +++ b/modules/fabricworkspace/main.tf @@ -45,28 +45,28 @@ resource "fabric_spark_workspace_settings" "workspace_settings" { } } -# resource "fabric_workspace_git" "workspace_git" { -# count = var.workspace_git == null ? 0 : 1 +resource "fabric_workspace_git" "workspace_git" { + count = var.workspace_git == null ? 0 : 1 -# workspace_id = fabric_workspace.workspace.id + workspace_id = fabric_workspace.workspace.id -# git_provider_details = { -# git_provider_type = var.workspace_git.git_provider_type -# organization_name = var.workspace_git.organization_name -# project_name = var.workspace_git.project_name -# repository_name = var.workspace_git.repository_name -# branch_name = var.workspace_git.branch_name -# directory_name = var.workspace_git.directory_name -# } -# initialization_strategy = "PreferWorkspace" -# } + git_provider_details = { + git_provider_type = var.workspace_git.git_provider_type + organization_name = var.workspace_git.organization_name + project_name = var.workspace_git.project_name + repository_name = var.workspace_git.repository_name + branch_name = var.workspace_git.branch_name + directory_name = var.workspace_git.directory_name + } + initialization_strategy = "PreferWorkspace" +} -# resource "fabric_workspace_role_assignment" "example" { -# for_each = var.workspace_role_assignments +resource "fabric_workspace_role_assignment" "example" { + for_each = var.workspace_role_assignments -# workspace_id = fabric_workspace.workspace.id + workspace_id = fabric_workspace.workspace.id -# principal_id = each.value.principal_id -# principal_type = each.value.principal_type -# role = each.value.role -# } + principal_id = each.value.principal_id + principal_type = each.value.principal_type + role = each.value.role +} diff --git a/modules/fabricworkspace/tests/setup/data.tf b/modules/fabricworkspace/tests/setup/data.tf new file mode 100644 index 0000000..cee07df --- /dev/null +++ b/modules/fabricworkspace/tests/setup/data.tf @@ -0,0 +1 @@ +data "azurerm_client_config" "current" {} diff --git a/modules/fabricworkspace/tests/setup/outputs.tf b/modules/fabricworkspace/tests/setup/outputs.tf index 06e8852..80fad85 100644 --- a/modules/fabricworkspace/tests/setup/outputs.tf +++ b/modules/fabricworkspace/tests/setup/outputs.tf @@ -9,3 +9,9 @@ output "fabric_capacity_name" { value = module.fabric_capacity.fabric_capacity_name sensitive = false } + +output "client_config_object_id" { + description = "Specifies the object id of the client." + value = data.azurerm_client_config.current.object_id + sensitive = false +} diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 2a2dda0..57a48bb 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -92,8 +92,14 @@ run "create_fabric_workspace" { default_pool_name = "starterPool" } } - workspace_git = null - workspace_role_assignments = {} + workspace_git = null + workspace_role_assignments = { + my_sp = { + principal_id = run.setup.client_config_object_id + principal_type = "ServicePrincipal" + role = "Viewer" + } + } } # assert { From 8962b42897b9dd0709fa8092b322bb88189cb8a8 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 23:10:41 +0200 Subject: [PATCH 30/34] Test again --- modules/fabricworkspace/tests/setup/data.tf | 1 - modules/fabricworkspace/tests/setup/outputs.tf | 6 ------ modules/fabricworkspace/tests/test.tftest.hcl | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 modules/fabricworkspace/tests/setup/data.tf diff --git a/modules/fabricworkspace/tests/setup/data.tf b/modules/fabricworkspace/tests/setup/data.tf deleted file mode 100644 index cee07df..0000000 --- a/modules/fabricworkspace/tests/setup/data.tf +++ /dev/null @@ -1 +0,0 @@ -data "azurerm_client_config" "current" {} diff --git a/modules/fabricworkspace/tests/setup/outputs.tf b/modules/fabricworkspace/tests/setup/outputs.tf index 80fad85..06e8852 100644 --- a/modules/fabricworkspace/tests/setup/outputs.tf +++ b/modules/fabricworkspace/tests/setup/outputs.tf @@ -9,9 +9,3 @@ output "fabric_capacity_name" { value = module.fabric_capacity.fabric_capacity_name sensitive = false } - -output "client_config_object_id" { - description = "Specifies the object id of the client." - value = data.azurerm_client_config.current.object_id - sensitive = false -} diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 57a48bb..7dbb5ea 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -95,7 +95,7 @@ run "create_fabric_workspace" { workspace_git = null workspace_role_assignments = { my_sp = { - principal_id = run.setup.client_config_object_id + principal_id = "973df2ad-4e5e-4e8b-9df6-17f61e9efd55" principal_type = "ServicePrincipal" role = "Viewer" } From ff0137757850a2966e373d7bf58dcfa39f2ad0b8 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 23:38:40 +0200 Subject: [PATCH 31/34] Update variables --- modules/fabricworkspace/README.md | 7 +--- modules/fabricworkspace/variables.tf | 51 ++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/modules/fabricworkspace/README.md b/modules/fabricworkspace/README.md index d2bcef1..5876577 100644 --- a/modules/fabricworkspace/README.md +++ b/modules/fabricworkspace/README.md @@ -54,7 +54,7 @@ Default: `""` ### [workspace\_git](#input\_workspace\_git) -Description: Specifies git config of the fabric workspace. +Description: Specifies git config of the fabric workspace. Not supported when deploying with service principal. Type: @@ -106,16 +106,11 @@ object({ automatic_log = optional(object({ enabled = optional(bool, true) }), {}) - environment = optional(object({ - default_environment_name = optional(string, "") - runtime_version = optional(string, "1.3") - }), {}) high_concurrency = optional(object({ notebook_interactive_run_enabled = optional(bool, true) }), {}) pool = optional(object({ customize_compute_enabled = optional(bool, true) - default_pool_name = optional(string, "StarterPool") }), {}) }) ``` diff --git a/modules/fabricworkspace/variables.tf b/modules/fabricworkspace/variables.tf index c6ce797..0efd714 100644 --- a/modules/fabricworkspace/variables.tf +++ b/modules/fabricworkspace/variables.tf @@ -63,16 +63,11 @@ variable "workspace_settings" { automatic_log = optional(object({ enabled = optional(bool, true) }), {}) - environment = optional(object({ - default_environment_name = optional(string, "") - runtime_version = optional(string, "1.3") - }), {}) high_concurrency = optional(object({ notebook_interactive_run_enabled = optional(bool, true) }), {}) pool = optional(object({ customize_compute_enabled = optional(bool, true) - default_pool_name = optional(string, "StarterPool") }), {}) }) sensitive = false @@ -84,8 +79,52 @@ variable "workspace_settings" { } } +# variable "workspace_settings" { +# description = "Specifies settings of the fabric workspace." +# type = object({ +# automatic_log = optional(object({ +# enabled = optional(bool, true) +# }), {}) +# environment = optional(object({ +# default_environment_enabled = optional(bool, false) +# runtime_version = optional(string, "1.3") +# default_environment_config = optional(object({ +# publication_status = optional(string, "Published") +# driver_cores = optional(number, 4) +# driver_memory = optional(string, "28g") +# executor_cores = optional(number, 4) +# executor_memory = optional(string, "28g") +# dynamic_executor_allocation = optional(object({ +# enabled = optional(bool, false) +# min_executors = optional(number, null) +# max_executors = optional(number, null) +# }), {}) +# }), {}) +# }), {}) +# high_concurrency = optional(object({ +# notebook_interactive_run_enabled = optional(bool, true) +# }), {}) +# pool = optional(object({ +# customize_compute_enabled = optional(bool, true) +# default_pool_enabled = optional(bool, false) +# default_pool_config = optional(object({ +# node_family = optional(string, "MemoryOptimized") +# node_size = optional(string, "Small") + +# }), {}) +# }), {}) +# }) +# sensitive = false +# nullable = false +# default = {} +# validation { +# condition = contains(["1.2", "1.3"], var.workspace_settings.environment.runtime_version) +# error_message = "Please specify a valid runtime version. Version 1.1 should no longer be used." +# } +# } + variable "workspace_git" { - description = "Specifies git config of the fabric workspace." + description = "Specifies git config of the fabric workspace. Not supported when deploying with service principal." type = object({ git_provider_type = optional(string, "AzureDevOps") organization_name = string From 2dace27e9789ee26bdac0f7e1659852b87302375 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 23:41:57 +0200 Subject: [PATCH 32/34] Update workflow --- .github/workflows/terraform-fabricworkspace.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/terraform-fabricworkspace.yml b/.github/workflows/terraform-fabricworkspace.yml index 69f4906..0b3775f 100644 --- a/.github/workflows/terraform-fabricworkspace.yml +++ b/.github/workflows/terraform-fabricworkspace.yml @@ -26,7 +26,5 @@ jobs: node_version: 20 tenant_id: "37963dd4-f4e6-40f8-a7d6-24b97919e452" subscription_id: "1fdab118-1638-419a-8b12-06c9543714a0" - run_test: true - log_level_test: "ERROR" secrets: CLIENT_ID: ${{ secrets.CLIENT_ID }} From de87e6a0b36335cf1a2c0d6fa73bbb0751605afe Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 23:46:00 +0200 Subject: [PATCH 33/34] Update test --- modules/fabricworkspace/tests/test.tftest.hcl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/fabricworkspace/tests/test.tftest.hcl b/modules/fabricworkspace/tests/test.tftest.hcl index 7dbb5ea..cde132b 100644 --- a/modules/fabricworkspace/tests/test.tftest.hcl +++ b/modules/fabricworkspace/tests/test.tftest.hcl @@ -80,16 +80,16 @@ run "create_fabric_workspace" { automatic_log = { enabled = true } - environment = { - default_environment_name = "" - runtime_version = "1.3" - } + # environment = { + # default_environment_name = "" + # runtime_version = "1.3" + # } high_concurrency = { notebook_interactive_run_enabled = true } pool = { customize_compute_enabled = true - default_pool_name = "starterPool" + # default_pool_name = "starterPool" } } workspace_git = null From feed6723abc9f87a45c5d3839b02ac158db77562 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Wed, 2 Oct 2024 23:48:48 +0200 Subject: [PATCH 34/34] Update variable validation --- modules/fabricworkspace/variables.tf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/fabricworkspace/variables.tf b/modules/fabricworkspace/variables.tf index 0efd714..9e9b130 100644 --- a/modules/fabricworkspace/variables.tf +++ b/modules/fabricworkspace/variables.tf @@ -73,10 +73,6 @@ variable "workspace_settings" { sensitive = false nullable = false default = {} - validation { - condition = contains(["1.2", "1.3"], var.workspace_settings.environment.runtime_version) - error_message = "Please specify a valid runtime version. Version 1.1 should no longer be used." - } } # variable "workspace_settings" {