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

azurerm_windows_virtual_machine cannot be created with hotpatching enabled using a valid SKU. #26153

Open chrisnavar opened 1 month ago

chrisnavar commented 1 month ago

Is there an existing issue for this?

Community Note

Terraform Version

1.8.4

AzureRM Provider Version

3.101.0

Affected Resource(s)/Data Source(s)

azurerm_windows_virtual_machine

Terraform Configuration Files

resource "azurerm_windows_virtual_machine" "vm" {
  name                  = "vm"
  resource_group_name   = "rg"
  location              = "westeurope"
  zone                  = "1"
  size                  = "Standard_D2ds_v5"
  admin_username        = "admin"
  admin_password        = "P@ssw0rd"
  network_interface_ids = [ azurerm_network_interface.vm_nic00.id ] 
  computer_name         = "vm"
  patch_mode            = "AutomaticByPlatform"
  provision_vm_agent    = true
  license_type          = "Windows_Server"
  hotpatching_enabled   = true

  boot_diagnostics {
    storage_account_uri = null
  }

  source_image_reference {
    publisher = "microsoftwindowsserver"
    offer     = "windowsserver"
    sku       = "2022-datacenter-azure-edition-core"
    version   = "20348.2402.240510"
  }

  os_disk { 
    storage_account_type = "Premium_LRS"
    caching              = "ReadWrite"
    disk_size_gb         = 127
    name                 = "vm-OSDisk"
  }
}

Debug Output/Panic Output

Error: "hotpatching_enabled" is currently only supported on "2022-datacenter-azure-edition-core", "2022-datacenter-azure-edition-core-smalldisk", "2022-datacenter-azure-edition-hotpatch" or "2022-datacenter-azure-edition-hotpatch-smalldisk" image reference skus

Expected Behaviour

Terraform should create the virtual machine when hotpatching_enabled = true as the SKU supports the functionality.

Actual Behaviour

Terraform prevents the virtual machine from being created and outputs the above error.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

chrisnavar commented 1 month ago

If I do the same deployment of the above configuration file with the hotpatching_enabled parameter set on 'false' it works as per normal behaviour, but then if I modify again this hotpatching_enabled parameter to 'true', terraform completes successfully the changes on the already deployed VM.