Skip to content

Commit

Permalink
add fabric cap (#236)
Browse files Browse the repository at this point in the history
* cosmetic changes
  • Loading branch information
murggu committed Jun 2, 2023
1 parent e17da5a commit def9ab2
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 127 deletions.
44 changes: 23 additions & 21 deletions terraform/fabric/fabric-capacity/main.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
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
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
}
7 changes: 7 additions & 0 deletions terraform/fabric/fabric-capacity/outputs.tf
Original file line number Diff line number Diff line change
@@ -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."
}
12 changes: 6 additions & 6 deletions terraform/fabric/fabric-capacity/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}
34 changes: 17 additions & 17 deletions terraform/fabric/fabric-capacity/test/fabric_capacity.tf
Original file line number Diff line number Diff line change
@@ -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
}
12 changes: 6 additions & 6 deletions terraform/fabric/fabric-capacity/test/locals.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 3 additions & 0 deletions terraform/fabric/fabric-capacity/test/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = module.fabric_capacity.id
}
48 changes: 24 additions & 24 deletions terraform/fabric/fabric-capacity/test/providers.tf
Original file line number Diff line number Diff line change
@@ -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" {
}
38 changes: 19 additions & 19 deletions terraform/fabric/fabric-capacity/test/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}
74 changes: 40 additions & 34 deletions terraform/fabric/fabric-capacity/variables.tf
Original file line number Diff line number Diff line change
@@ -1,35 +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 "sku" {
type = string
default = "F2"
description = ""
}

variable "admin_email" {
type = string
description = ""
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"
}

0 comments on commit def9ab2

Please sign in to comment.