Skip to content

libre-devops/terraform-azurerm-dev-center

Repository files navigation

# Dev Center Resource
resource "azurerm_dev_center" "dev_centers" {
  for_each            = { for dc in var.dev_centers : dc.name => dc }
  location            = each.value.location
  name                = each.value.name
  resource_group_name = each.value.rg_name
  tags                = each.value.tags

  dynamic "identity" {
    for_each = each.value.identity_type == "SystemAssigned" ? [each.value.identity_type] : []
    content {
      type = each.value.identity_type
    }
  }

  dynamic "identity" {
    for_each = each.value.identity_type == "SystemAssigned, UserAssigned" ? [each.value.identity_type] : []
    content {
      type         = each.value.identity_type
      identity_ids = try(each.value.identity_ids, [])
    }
  }

  dynamic "identity" {
    for_each = each.value.identity_type == "UserAssigned" ? [each.value.identity_type] : []
    content {
      type         = each.value.identity_type
      identity_ids = length(try(each.value.identity_ids, [])) > 0 ? each.value.identity_ids : []
    }
  }
}

# Network Connection Resource
resource "azurerm_dev_center_network_connection" "network_connections" {
  for_each = { for dc in var.dev_centers : dc.name => dc if contains(keys(dc), "network_connection") && dc.network_connection != null }

  name                = each.value.network_connection.name != null ? each.value.network_connection.name : "netcon-${each.key}"
  resource_group_name = azurerm_dev_center.dev_centers[each.key].resource_group_name
  location            = azurerm_dev_center.dev_centers[each.key].location
  domain_join_type    = each.value.network_connection.domain_join_type
  subnet_id           = each.value.network_connection.subnet_id

  # Optional attributes
  domain_name       = try(each.value.network_connection.domain_name, null)
  domain_password   = try(each.value.network_connection.domain_password, null)
  domain_username   = try(each.value.network_connection.domain_username, null)
  organization_unit = try(each.value.network_connection.organization_unit, null)

  tags = azurerm_dev_center.dev_centers[each.key].tags
}


resource "azurerm_dev_center_project" "projects" {
  for_each = {
    for dc in var.dev_centers : dc.name => dc
    if lookup(dc, "create_project", false) == true
  }

  dev_center_id              = azurerm_dev_center.dev_centers[each.key].id
  location                   = azurerm_dev_center.dev_centers[each.key].location
  name                       = each.value.project.name != null ? each.value.project.name : "proj-${each.key}"
  resource_group_name        = azurerm_dev_center.dev_centers[each.key].resource_group_name
  description                = try(each.value.project.description, "Default project description for ${each.key}")
  maximum_dev_boxes_per_user = try(each.value.project.maximum_dev_boxes_per_user, null)
  tags                       = try(each.value.project.tags, azurerm_dev_center.dev_centers[each.key].tags)
}

Requirements

No requirements.

Providers

Name Version
azurerm n/a

Modules

No modules.

Resources

Name Type
azurerm_dev_center.dev_centers resource
azurerm_dev_center_network_connection.network_connections resource
azurerm_dev_center_project.projects resource

Inputs

Name Description Type Default Required
dev_centers List of Dev Centers to create, along with optional compute gallery configuration
list(object({
name = string
location = optional(string, "uksouth")
rg_name = string
tags = optional(map(string))
identity_type = optional(string)
identity_ids = optional(list(string))

# Network connection related fields
network_connection = optional(object({
name = optional(string)
domain_join_type = optional(string, "AzureADJoin")
subnet_id = string
domain_name = optional(string)
domain_password = optional(string)
domain_username = optional(string)
organization_unit = optional(string)
tags = optional(map(string))
}))

create_project = optional(bool, false) # Flag to create a Dev Center project
project = optional(object({
name = optional(string)
description = optional(string)
maximum_dev_boxes_per_user = optional(number, 0)
tags = optional(map(string))
}))
}))
n/a yes

Outputs

Name Description
dev_center_identities The identities of the Dev Centers
dev_center_ids The IDs of the Dev Centers
dev_center_names The default name of the Dev Centers
dev_center_network_connection_ids The IDs of the Dev Center Network Connections
dev_center_project_id The ID of the created Dev Center Project
dev_center_project_location The location of the created Dev Center Project
dev_center_project_max_dev_boxes The maximum dev boxes per user for the created Dev Center Project
dev_center_project_name The name of the created Dev Center Project
dev_center_project_resource_group The resource group of the created Dev Center Project
dev_center_project_uri The URI of the created Dev Center Project
dev_center_tags The tags of the Dev Centers
dev_center_uri The URI of the Dev Centers

About

A module used to deploy Azure Dev Center

Resources

License

Stars

Watchers

Forks

Packages

No packages published