hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.51k stars 4.6k forks source link

Support for Dev Center Network Connections #26648

Open damienaicheh opened 1 month ago

damienaicheh commented 1 month ago

Is there an existing issue for this?

Community Note

Description

Dev Centers needs to be connected to internal networks using Network Connections.

Those 2 elements are missing:

New or Affected Resource(s)/Data Source(s)

azurerm_dev_center

Potential Terraform Configuration

No response

References

https://github.com/hashicorp/terraform-provider-azurerm/issues/23367

webstean commented 1 month ago

Example azapi config, if that helps:

resource "azapi_resource" "devbox-networkconnections" {
  for_each = azurerm_dev_center.devbox
  ## one per region
  ## for_each = local.regions

  type = "Microsoft.DevCenter/networkConnections@2023-04-01"
  name = "${each.value.name}-network01"

  // resource group id for the parent id!!
  ## parent_id = azurerm_resource_group.devcenter[each.key].id
  parent_id = azurerm_resource_group.devcenter-connection[each.key].id
  location  = each.value.location
  body = jsonencode({
    properties = {
      domainJoinType = "AzureADJoin"
      ## HybridAzureADJoin needs the following:
      ##  domainName = "string"
      ##  domainPassword = "string"
      ##  domainUsername = "string"
      ##  organizationUnit = "string"

      ## needs to be new - so cannot already exist, so we let azure manage this itself 
      ## networkingResourceGroupName = "${var.prefix}-devcenter-network-rg"
      subnetId = data.azurerm_subnet.lab.id
    }
  })
  tags = each.value.tags
  lifecycle {
    create_before_destroy = true
  }
}
damienaicheh commented 3 weeks ago

Hi @webstean, thanks for the support.

I saw that we have the ability to create nework connections now with the ressources azurerm_dev_center_network_connection however we need the az api resource to attach it to the dev center:

resource "azapi_resource" "example" {
  type      = "Microsoft.DevCenter/devcenters/attachednetworks@2022-11-11-preview"
  name      = "ExampleNetworkConnection"
  parent_id = azurerm_dev_center.this.id
  body = jsonencode({
    properties = {
      networkConnectionId = azurerm_dev_center_network_connection.this.id
    }
  })
}

To be more precise, this resource is missing @rcskosir