From 998fa781596e6f42b9b46e223fb7f1c52af2afb2 Mon Sep 17 00:00:00 2001 From: murggu Date: Fri, 2 Jun 2023 12:10:55 +0200 Subject: [PATCH 1/3] add fabric capacity --- terraform/fabric/fabric-capacity/main.tf | 22 ++++++++++++ terraform/fabric/fabric-capacity/outputs.tf | 0 terraform/fabric/fabric-capacity/providers.tf | 7 ++++ .../fabric-capacity/test/fabric_capacity.tf | 18 ++++++++++ .../fabric/fabric-capacity/test/locals.tf | 7 ++++ .../fabric/fabric-capacity/test/outputs.tf | 0 .../fabric/fabric-capacity/test/providers.tf | 25 +++++++++++++ .../fabric/fabric-capacity/test/variables.tf | 20 +++++++++++ terraform/fabric/fabric-capacity/variables.tf | 35 +++++++++++++++++++ 9 files changed, 134 insertions(+) create mode 100644 terraform/fabric/fabric-capacity/main.tf create mode 100644 terraform/fabric/fabric-capacity/outputs.tf create mode 100644 terraform/fabric/fabric-capacity/providers.tf create mode 100644 terraform/fabric/fabric-capacity/test/fabric_capacity.tf create mode 100644 terraform/fabric/fabric-capacity/test/locals.tf create mode 100644 terraform/fabric/fabric-capacity/test/outputs.tf create mode 100644 terraform/fabric/fabric-capacity/test/providers.tf create mode 100644 terraform/fabric/fabric-capacity/test/variables.tf create mode 100644 terraform/fabric/fabric-capacity/variables.tf diff --git a/terraform/fabric/fabric-capacity/main.tf b/terraform/fabric/fabric-capacity/main.tf new file mode 100644 index 00000000..35a0b8e7 --- /dev/null +++ b/terraform/fabric/fabric-capacity/main.tf @@ -0,0 +1,22 @@ +resource "azapi_resource" "fabric_capacity" { + type = "Microsoft.Fabric/capacities@2022-07-01-preview" + name = "fab${var.basename}" + parent_id = var.resource_group_id + location = var.location + schema_validation_enabled = false + + body = jsonencode({ + properties = { + administration = { + members = [ + var.admin_email + ] + } + } + sku = { + name = var.sku, + tier = "Fabric" + } + }) + tags = var.tags +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/outputs.tf b/terraform/fabric/fabric-capacity/outputs.tf new file mode 100644 index 00000000..e69de29b diff --git a/terraform/fabric/fabric-capacity/providers.tf b/terraform/fabric/fabric-capacity/providers.tf new file mode 100644 index 00000000..ee853a09 --- /dev/null +++ b/terraform/fabric/fabric-capacity/providers.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + } +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/fabric_capacity.tf b/terraform/fabric/fabric-capacity/test/fabric_capacity.tf new file mode 100644 index 00000000..b632709a --- /dev/null +++ b/terraform/fabric/fabric-capacity/test/fabric_capacity.tf @@ -0,0 +1,18 @@ +module "fabric_capacity" { + source = "../" + basename = random_string.postfix.result + resource_group_id = module.local_rg.id + location = var.location + sku = var.sku + admin_email = var.admin_email + tags = {} +} + +# Modules dependencies + +module "local_rg" { + source = "../../../resource-group" + basename = random_string.postfix.result + location = var.location + tags = local.tags +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/locals.tf b/terraform/fabric/fabric-capacity/test/locals.tf new file mode 100644 index 00000000..cf58c6d3 --- /dev/null +++ b/terraform/fabric/fabric-capacity/test/locals.tf @@ -0,0 +1,7 @@ +locals { + tags = { + Project = "Azure/azure-data-labs-modules" + Module = "fabric-capacity" + Toolkit = "Terraform" + } +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/outputs.tf b/terraform/fabric/fabric-capacity/test/outputs.tf new file mode 100644 index 00000000..e69de29b diff --git a/terraform/fabric/fabric-capacity/test/providers.tf b/terraform/fabric/fabric-capacity/test/providers.tf new file mode 100644 index 00000000..3ad37f38 --- /dev/null +++ b/terraform/fabric/fabric-capacity/test/providers.tf @@ -0,0 +1,25 @@ +terraform { + backend "azurerm" { + resource_group_name = "rg-adl-terraform-state" + storage_account_name = "stadlterraformstate" + container_name = "default" + key = "fabriccapacity.terraform.tfstate" + } + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "= 3.53.0" + } + azapi = { + source = "azure/azapi" + } + } +} + +provider "azurerm" { + features {} +} + +provider "azapi" { +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/variables.tf b/terraform/fabric/fabric-capacity/test/variables.tf new file mode 100644 index 00000000..e02145e4 --- /dev/null +++ b/terraform/fabric/fabric-capacity/test/variables.tf @@ -0,0 +1,20 @@ +resource "random_string" "postfix" { + length = 8 + special = false + upper = false +} + +variable "location" { + type = string + default = "North Europe" +} + +variable "sku" { + type = string + default = "F2" +} + +variable "admin_email" { + type = string + default = "aimurg@microsoft.com" +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/variables.tf b/terraform/fabric/fabric-capacity/variables.tf new file mode 100644 index 00000000..53c44032 --- /dev/null +++ b/terraform/fabric/fabric-capacity/variables.tf @@ -0,0 +1,35 @@ +variable "basename" { + type = string + description = "Basename of the module." + validation { + condition = can(regex("^[-0-9a-zA-Z]{1,21}$", var.basename)) && can(regex("[0-9a-zA-Z]+$", var.basename)) + error_message = "The name must be between 1 and 21 characters, can contain only letters, numbers, and hyphens. Must end with a letter or number. Cannot contain consecutive hyphens." + } +} + +variable "resource_group_id" { + type = string + description = "Resource group id." +} + +variable "location" { + type = string + description = "Location of the resource group." +} + +variable "tags" { + type = map(string) + default = {} + description = "A mapping of tags which should be assigned to the deployed resource." +} + +variable "sku" { + type = string + default = "F2" + description = "" +} + +variable "admin_email" { + type = string + description = "" +} \ No newline at end of file From b2226aa1fe89af08d7f775faefa4e4025edee286 Mon Sep 17 00:00:00 2001 From: murggu Date: Fri, 2 Jun 2023 12:27:30 +0200 Subject: [PATCH 2/3] cosmetic changes --- terraform/fabric/fabric-capacity/main.tf | 4 +++- terraform/fabric/fabric-capacity/outputs.tf | 7 +++++++ terraform/fabric/fabric-capacity/test/outputs.tf | 3 +++ terraform/fabric/fabric-capacity/test/providers.tf | 12 ++++++------ terraform/fabric/fabric-capacity/variables.tf | 10 ++++++++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/terraform/fabric/fabric-capacity/main.tf b/terraform/fabric/fabric-capacity/main.tf index 35a0b8e7..597ba3c0 100644 --- a/terraform/fabric/fabric-capacity/main.tf +++ b/terraform/fabric/fabric-capacity/main.tf @@ -1,4 +1,4 @@ -resource "azapi_resource" "fabric_capacity" { +resource "azapi_resource" "fab_capacity" { type = "Microsoft.Fabric/capacities@2022-07-01-preview" name = "fab${var.basename}" parent_id = var.resource_group_id @@ -19,4 +19,6 @@ resource "azapi_resource" "fabric_capacity" { } }) tags = var.tags + + count = var.module_enabled ? 1 : 0 } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/outputs.tf b/terraform/fabric/fabric-capacity/outputs.tf index e69de29b..3c0590b7 100644 --- a/terraform/fabric/fabric-capacity/outputs.tf +++ b/terraform/fabric/fabric-capacity/outputs.tf @@ -0,0 +1,7 @@ +output "id" { + value = ( + length(azapi_resource.fab_capacity) > 0 ? + azapi_resource.fab_capacity[0].id : "" + ) + description = "Resource identifier of the instance of Fabric Capacity." +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/outputs.tf b/terraform/fabric/fabric-capacity/test/outputs.tf index e69de29b..25e6398e 100644 --- a/terraform/fabric/fabric-capacity/test/outputs.tf +++ b/terraform/fabric/fabric-capacity/test/outputs.tf @@ -0,0 +1,3 @@ +output "id" { + value = module.fabric_capacity.id +} \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/providers.tf b/terraform/fabric/fabric-capacity/test/providers.tf index 3ad37f38..e71cbdeb 100644 --- a/terraform/fabric/fabric-capacity/test/providers.tf +++ b/terraform/fabric/fabric-capacity/test/providers.tf @@ -1,10 +1,10 @@ terraform { - backend "azurerm" { - resource_group_name = "rg-adl-terraform-state" - storage_account_name = "stadlterraformstate" - container_name = "default" - key = "fabriccapacity.terraform.tfstate" - } + # backend "azurerm" { + # resource_group_name = "rg-adl-terraform-state" + # storage_account_name = "stadlterraformstate" + # container_name = "default" + # key = "fabriccapacity.terraform.tfstate" + # } required_providers { azurerm = { diff --git a/terraform/fabric/fabric-capacity/variables.tf b/terraform/fabric/fabric-capacity/variables.tf index 53c44032..d4d675be 100644 --- a/terraform/fabric/fabric-capacity/variables.tf +++ b/terraform/fabric/fabric-capacity/variables.tf @@ -23,13 +23,19 @@ variable "tags" { description = "A mapping of tags which should be assigned to the deployed resource." } +variable "module_enabled" { + type = bool + description = "Variable to enable or disable the module." + default = true +} + variable "sku" { type = string default = "F2" - description = "" + description = "SKU name" } variable "admin_email" { type = string - description = "" + description = "Fabric administrator email" } \ No newline at end of file From 1e957254f11e6a385d4e17f24fbf21b1d9d87bca Mon Sep 17 00:00:00 2001 From: murggu Date: Fri, 2 Jun 2023 12:28:59 +0200 Subject: [PATCH 3/3] cosmetic changes --- terraform/fabric/fabric-capacity/main.tf | 46 +++++------ terraform/fabric/fabric-capacity/outputs.tf | 12 +-- terraform/fabric/fabric-capacity/providers.tf | 12 +-- .../fabric-capacity/test/fabric_capacity.tf | 34 ++++---- .../fabric/fabric-capacity/test/locals.tf | 12 +-- .../fabric/fabric-capacity/test/outputs.tf | 4 +- .../fabric/fabric-capacity/test/providers.tf | 48 +++++------ .../fabric/fabric-capacity/test/variables.tf | 38 ++++----- terraform/fabric/fabric-capacity/variables.tf | 80 +++++++++---------- 9 files changed, 143 insertions(+), 143 deletions(-) diff --git a/terraform/fabric/fabric-capacity/main.tf b/terraform/fabric/fabric-capacity/main.tf index 597ba3c0..400bb182 100644 --- a/terraform/fabric/fabric-capacity/main.tf +++ b/terraform/fabric/fabric-capacity/main.tf @@ -1,24 +1,24 @@ -resource "azapi_resource" "fab_capacity" { - type = "Microsoft.Fabric/capacities@2022-07-01-preview" - name = "fab${var.basename}" - parent_id = var.resource_group_id - location = var.location - schema_validation_enabled = false - - body = jsonencode({ - properties = { - administration = { - members = [ - var.admin_email - ] - } - } - sku = { - name = var.sku, - tier = "Fabric" - } - }) - tags = var.tags - - count = var.module_enabled ? 1 : 0 +resource "azapi_resource" "fab_capacity" { + type = "Microsoft.Fabric/capacities@2022-07-01-preview" + name = "fab${var.basename}" + parent_id = var.resource_group_id + location = var.location + schema_validation_enabled = false + + body = jsonencode({ + properties = { + administration = { + members = [ + var.admin_email + ] + } + } + sku = { + name = var.sku, + tier = "Fabric" + } + }) + tags = var.tags + + count = var.module_enabled ? 1 : 0 } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/outputs.tf b/terraform/fabric/fabric-capacity/outputs.tf index 3c0590b7..52e6d4dd 100644 --- a/terraform/fabric/fabric-capacity/outputs.tf +++ b/terraform/fabric/fabric-capacity/outputs.tf @@ -1,7 +1,7 @@ -output "id" { - value = ( - length(azapi_resource.fab_capacity) > 0 ? - azapi_resource.fab_capacity[0].id : "" - ) - description = "Resource identifier of the instance of Fabric Capacity." +output "id" { + value = ( + length(azapi_resource.fab_capacity) > 0 ? + azapi_resource.fab_capacity[0].id : "" + ) + description = "Resource identifier of the instance of Fabric Capacity." } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/providers.tf b/terraform/fabric/fabric-capacity/providers.tf index ee853a09..075d6f44 100644 --- a/terraform/fabric/fabric-capacity/providers.tf +++ b/terraform/fabric/fabric-capacity/providers.tf @@ -1,7 +1,7 @@ -terraform { - required_providers { - azapi = { - source = "Azure/azapi" - } - } +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + } } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/fabric_capacity.tf b/terraform/fabric/fabric-capacity/test/fabric_capacity.tf index b632709a..99b2ed65 100644 --- a/terraform/fabric/fabric-capacity/test/fabric_capacity.tf +++ b/terraform/fabric/fabric-capacity/test/fabric_capacity.tf @@ -1,18 +1,18 @@ -module "fabric_capacity" { - source = "../" - basename = random_string.postfix.result - resource_group_id = module.local_rg.id - location = var.location - sku = var.sku - admin_email = var.admin_email - tags = {} -} - -# Modules dependencies - -module "local_rg" { - source = "../../../resource-group" - basename = random_string.postfix.result - location = var.location - tags = local.tags +module "fabric_capacity" { + source = "../" + basename = random_string.postfix.result + resource_group_id = module.local_rg.id + location = var.location + sku = var.sku + admin_email = var.admin_email + tags = {} +} + +# Modules dependencies + +module "local_rg" { + source = "../../../resource-group" + basename = random_string.postfix.result + location = var.location + tags = local.tags } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/locals.tf b/terraform/fabric/fabric-capacity/test/locals.tf index cf58c6d3..a0d65226 100644 --- a/terraform/fabric/fabric-capacity/test/locals.tf +++ b/terraform/fabric/fabric-capacity/test/locals.tf @@ -1,7 +1,7 @@ -locals { - tags = { - Project = "Azure/azure-data-labs-modules" - Module = "fabric-capacity" - Toolkit = "Terraform" - } +locals { + tags = { + Project = "Azure/azure-data-labs-modules" + Module = "fabric-capacity" + Toolkit = "Terraform" + } } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/outputs.tf b/terraform/fabric/fabric-capacity/test/outputs.tf index 25e6398e..c275d58d 100644 --- a/terraform/fabric/fabric-capacity/test/outputs.tf +++ b/terraform/fabric/fabric-capacity/test/outputs.tf @@ -1,3 +1,3 @@ -output "id" { - value = module.fabric_capacity.id +output "id" { + value = module.fabric_capacity.id } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/providers.tf b/terraform/fabric/fabric-capacity/test/providers.tf index e71cbdeb..77cd034f 100644 --- a/terraform/fabric/fabric-capacity/test/providers.tf +++ b/terraform/fabric/fabric-capacity/test/providers.tf @@ -1,25 +1,25 @@ -terraform { - # backend "azurerm" { - # resource_group_name = "rg-adl-terraform-state" - # storage_account_name = "stadlterraformstate" - # container_name = "default" - # key = "fabriccapacity.terraform.tfstate" - # } - - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "= 3.53.0" - } - azapi = { - source = "azure/azapi" - } - } -} - -provider "azurerm" { - features {} -} - -provider "azapi" { +terraform { + # backend "azurerm" { + # resource_group_name = "rg-adl-terraform-state" + # storage_account_name = "stadlterraformstate" + # container_name = "default" + # key = "fabriccapacity.terraform.tfstate" + # } + + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "= 3.53.0" + } + azapi = { + source = "azure/azapi" + } + } +} + +provider "azurerm" { + features {} +} + +provider "azapi" { } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/test/variables.tf b/terraform/fabric/fabric-capacity/test/variables.tf index e02145e4..0f354ecc 100644 --- a/terraform/fabric/fabric-capacity/test/variables.tf +++ b/terraform/fabric/fabric-capacity/test/variables.tf @@ -1,20 +1,20 @@ -resource "random_string" "postfix" { - length = 8 - special = false - upper = false -} - -variable "location" { - type = string - default = "North Europe" -} - -variable "sku" { - type = string - default = "F2" -} - -variable "admin_email" { - type = string - default = "aimurg@microsoft.com" +resource "random_string" "postfix" { + length = 8 + special = false + upper = false +} + +variable "location" { + type = string + default = "North Europe" +} + +variable "sku" { + type = string + default = "F2" +} + +variable "admin_email" { + type = string + default = "aimurg@microsoft.com" } \ No newline at end of file diff --git a/terraform/fabric/fabric-capacity/variables.tf b/terraform/fabric/fabric-capacity/variables.tf index d4d675be..366e1f4e 100644 --- a/terraform/fabric/fabric-capacity/variables.tf +++ b/terraform/fabric/fabric-capacity/variables.tf @@ -1,41 +1,41 @@ -variable "basename" { - type = string - description = "Basename of the module." - validation { - condition = can(regex("^[-0-9a-zA-Z]{1,21}$", var.basename)) && can(regex("[0-9a-zA-Z]+$", var.basename)) - error_message = "The name must be between 1 and 21 characters, can contain only letters, numbers, and hyphens. Must end with a letter or number. Cannot contain consecutive hyphens." - } -} - -variable "resource_group_id" { - type = string - description = "Resource group id." -} - -variable "location" { - type = string - description = "Location of the resource group." -} - -variable "tags" { - type = map(string) - default = {} - description = "A mapping of tags which should be assigned to the deployed resource." -} - -variable "module_enabled" { - type = bool - description = "Variable to enable or disable the module." - default = true -} - -variable "sku" { - type = string - default = "F2" - description = "SKU name" -} - -variable "admin_email" { - type = string - description = "Fabric administrator email" +variable "basename" { + type = string + description = "Basename of the module." + validation { + condition = can(regex("^[-0-9a-zA-Z]{1,21}$", var.basename)) && can(regex("[0-9a-zA-Z]+$", var.basename)) + error_message = "The name must be between 1 and 21 characters, can contain only letters, numbers, and hyphens. Must end with a letter or number. Cannot contain consecutive hyphens." + } +} + +variable "resource_group_id" { + type = string + description = "Resource group id." +} + +variable "location" { + type = string + description = "Location of the resource group." +} + +variable "tags" { + type = map(string) + default = {} + description = "A mapping of tags which should be assigned to the deployed resource." +} + +variable "module_enabled" { + type = bool + description = "Variable to enable or disable the module." + default = true +} + +variable "sku" { + type = string + default = "F2" + description = "SKU name" +} + +variable "admin_email" { + type = string + description = "Fabric administrator email" } \ No newline at end of file