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 [personal host pool scaling plan AVD] #22601

Open JohanVanneuville opened 1 year ago

JohanVanneuville commented 1 year ago

Is there an existing issue for this?

Community Note

Description

Please include support for personal host pools in the scaling plan resource If I try to add this parameter in the file host_pool_type = "Personal" it doesn't work.

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

azurerm 3.65.0

Potential Terraform Configuration

resource "azurerm_virtual_desktop_scaling_plan" "avd-scalingplan" {
  name                = "sp-prod-jvn-avd-we-01"
  location            = data.azurerm_virtual_desktop_host_pool.hp-personal.location
  resource_group_name = data.azurerm_virtual_desktop_host_pool.hp-personal.resource_group_name
  friendly_name       = "Production week days scaling plan"
  description         = "Production week days scaling plan"
  depends_on = [
    data.azurerm_virtual_desktop_host_pool.hp-personal
  ]
  time_zone           = "Romance standard Time"
  host_pool_type = "Personal"

References

No response

JohanVanneuville commented 9 months ago

add news about this? The feature is GA

ghost commented 9 months ago

same problem here, looking forward to using this new feature with TF

matthiasantierens commented 9 months ago

Running into the same problem. Thought that I was missing a param but then discovered this issue.

audunsolemdal commented 7 months ago

From reading the API spec it seems that the Microsoft.DesktopVirtualization/scalingPlans resource currently does not support creating schedules containing attributes which are specific to personal host pool types.

I would suggest that the existing azurerm_virtual_desktop_scaling_plan resource should support omitting a schedules block and support setting hostPoolType = "Personal". This is however not supported in the latest GA spec 2023-09-05.

Based on the latest API 2023-11-01-preview I assume a new resource would need to be created for this to work natively using the azurerm provider , e.g. azurerm_virtual_desktop_personal_scaling_plan

Workaround for now using AzApi

resource "azapi_resource" "weekdays_personal_schedule_root" {
  count = var.enable_scaling ? 1 : 0
  type      = "Microsoft.DesktopVirtualization/scalingPlans@2023-11-01-preview"
  name      = "t-gis-avd-scaling"
  location  = azurerm_virtual_desktop_host_pool.main.location
  parent_id = azurerm_resource_group.main.id
  body = jsonencode({
    properties = {
      timeZone     = "W. Europe Standard Time",
      hostPoolType = "Personal",
      exclusionTag = "no-schedule",
      schedules    = [],
      hostPoolReferences = [
        {
          hostPoolArmPath    = azurerm_virtual_desktop_host_pool.main.id,
          scalingPlanEnabled = true
        }
      ],
  } })
}

resource "azapi_resource" "weekdays_personal_schedule" {
  count = var.enable_scaling ? 1 : 0
  type  = "Microsoft.DesktopVirtualization/scalingPlans/personalSchedules@2023-11-01-preview"
  name  = "Weekdays"
  parent_id = azapi_resource.weekdays_personal_schedule_root[0].id
  body = jsonencode({
    properties = {
      daysOfWeek = [
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday"
      ]

      rampUpStartTime = {
        hour   = 7,
        minute = 0
      },
      rampUpAutoStartHosts            = "None",
      rampUpStartVMOnConnect          = "Enable",
      rampUpMinutesToWaitOnDisconnect = 45,
      rampUpActionOnDisconnect        = "Hibernate",
      rampUpMinutesToWaitOnLogoff     = 30,
      rampUpActionOnLogoff            = "Hibernate",

      peakStartTime = {
        hour   = 8,
        minute = 0
      },
      peakStartVMOnConnect          = "Enable",
      peakMinutesToWaitOnDisconnect = 60,
      peakActionOnDisconnect        = "Hibernate",
      peakMinutesToWaitOnLogoff     = 60,
      peakActionOnLogoff            = "Hibernate",

      rampDownStartTime = {
        hour   = 16,
        minute = 30
      },
      rampDownStartVMOnConnect          = "Enable",
      rampDownMinutesToWaitOnDisconnect = 45,
      rampDownActionOnDisconnect        = "Hibernate",
      rampDownMinutesToWaitOnLogoff     = 30,
      rampDownActionOnLogoff            = "Hibernate",

      offPeakStartTime = {
        hour   = 17,
        minute = 30
      },
      offPeakStartVMOnConnect          = "Enable",
      offPeakMinutesToWaitOnDisconnect = 20,
      offPeakActionOnDisconnect        = "Hibernate",
      offPeakMinutesToWaitOnLogoff     = 15,
      offPeakActionOnLogoff            = "Hibernate",
    }
  })
}
rs-eviden commented 3 months ago

Any good news on this feature?