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.47k stars 4.56k forks source link

WVD Hostpool name length more than 24 characters #9138

Open rmunilla opened 3 years ago

rmunilla commented 3 years ago

Community Note

Description

Currently it is possible to create Windows Virtual Desktop Hostpools through Terraform but name must have length less than 24. In the portal and with pwsh it is possible to assign a name longer than 24.

Thanks for the amazing work!

Affected Resource(s)

Terraform Configuration Files

resource "azurerm_virtual_desktop_host_pool" "pooleddepthfirst" {
  location            = data.azurerm_resource_group.main.location
  resource_group_name = data.azurerm_resource_group.main.name

  name                     = var.pooleddepthfirst.name
  friendly_name            = var.pooleddepthfirst.friendly_name
  description              = var.pooleddepthfirst.description
  type                     = var.pooleddepthfirst.type
  maximum_sessions_allowed = var.pooleddepthfirst.maximum_sessions_allowed
  load_balancer_type       = var.pooleddepthfirst.load_balancer_type
}
variable "pooleddepthfirst" {
  type = object({
    name                     = string
    friendly_name            = string
    description              = string
    type                     = string
    maximum_sessions_allowed = number
    load_balancer_type       = string
  })
  description = "Parameters object to configure pool"
}
pooleddepthfirst = {
  name                     = "wvdpool-pooled-dev-s-eastus"
  friendly_name            = "testpool"
  description              = "A pooled host pool - testpool"
  type                     = "Pooled"
  maximum_sessions_allowed = 30
  load_balancer_type       = "DepthFirst"
}

Debug Output

Error: Checking for presence of existing Virtual Desktop Host Pool "wvdpool-pooled-dev-s-eastus" (Resource Group "WVD-ruben0001dev"): desktopvirtualization.HostPoolsClient#Get: Invalid input: autorest/validation: validation failed: parameter=hostPoolName constraint=MaxLength value="wvdpool-pooled-dev-s-eastus" details: value length must be less than or equal to 24

  on resource.azure.pool.tf line 1, in resource "azurerm_virtual_desktop_host_pool" "pooleddepthfirst":
   1: resource "azurerm_virtual_desktop_host_pool" "pooleddepthfirst" {

Expected Behavior

Host pool is created

Actual Behavior

Host pool is not created as it tries to refresh the state for the resource and name is longer than 24

Steps to Reproduce

  1. terraform apply

Important Factoids

References

neil-yechenwei commented 3 years ago

Thanks for opening this issue. I assume it's API limitation. WVD Hostpool API doesn't allow the name which is longer than 24. So I assume it's not terraform issue.

ArcturusZhang commented 3 years ago

@neil-yechenwei could you please confirm whether the name of a hostpool can exceed 24 characters? If so this should be a swagger issue. The error reported in this issue is encoded in swagger and generated to SDK. Check the code here: https://github.com/terraform-providers/terraform-provider-azurerm/blob/9b9ee99dfb639132878f5cf37ce92bfd6d0e4b03/vendor/github.com/Azure/azure-sdk-for-go/services/preview/desktopvirtualization/mgmt/2019-12-10-preview/desktopvirtualization/hostpools.go#L252 Which is generated from the swagger here: https://github.com/Azure/azure-rest-api-specs/blob/51420e70ff2fbcc2443e76f389ef384a1adf1a89/specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/preview/2019-12-10-preview/desktopvirtualization.json#L2957

neil-yechenwei commented 3 years ago

@ArcturusZhang , after tested on Azure Portal, seems this resource could be created successfully with the name which is longer than 24. It's an swagger property validation issue. So I raised an issue on Azure/azure-rest-api-specs#11642.