Problem
When using the azurerm_virtual_machine_scale_set
resource in your terraform configuration and you run into a crash with an error similar to this:
2022-03-07T14:59:03Z !!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
.
.
.
2022-03-07T14:59:03Z * module.mymodulename.azurerm_virtual_machine_scale_set.main: 1 error occurred:
2022-03-07T14:59:03Z * module.mymodulename.azurerm_virtual_machine_scale_set.main: azurerm_virtual_machine_scale_set.main: unexpected EOF
.
.
.
2022-03-07T14:59:03Z panic: runtime error: invalid memory address or nil pointer dereference
Cause
You're likely to see a crash like this if you're using the now deprecated azurerm_virtual_machine_scale_set
resource with newer/unsupported features of other resources and since the Azure API doesn't support such operations, Terraform crashed.
The resource last updated in provider v2.50 (data source in v2.57), The azurerm_virtual_machine_scale_set
resource is now feature-frozen and has been replaced with 2 new resources: azurerm_linux_virtual_machine_scale_set
and azurerm_windows_virtual_machine_scale_set
. Per our registry website documentation:
The azurerm_virtual_machine_scale_set resource has been superseded by the azurerm_linux_virtual_machine_scale_set and azurerm_windows_virtual_machine_scale_set resources. The existing azurerm_virtual_machine_scale_set resource will continue to be available throughout the 2.x releases however is in a feature-frozen state to maintain compatibility - new functionality will instead be added to the azurerm_linux_virtual_machine_scale_set and azurerm_windows_virtual_machine_scale_set resources.
Link: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_scale_set#disclaimers
You can also find more explanation regarding this from our provider Engineers here.
Solution
The solution to get out of this bind requires that you replace the old azurerm_virtual_machine_scale_set
with either of the 2 new resources as suits your use-case: azurerm_linux_virtual_machine_scale_set
or azurerm_windows_virtual_machine_scale_set
.
You can replace them by using the terraform state mv command or importing the existing scale set resource by following the respective resource's import documentation on its registry page.
IMPORTANT NOTES
-
Please note that from AzureRM provider v2.86 onwards, the
azurerm_linux/windows_virtual_machine_scale_set
resources will be using only the Uniform Orchestration Mode.- For the Flexible Orchestration Mode, please use the
azurerm_orchestrated_virtual_machine_scale_set
resource instead (also strictly Flexible from v2.86 onwards). - For a comparison of Virtual Machine Scale Set (VMSS) Orchestration Modes and their compatibility with Availability sets, please see here.
- For the Flexible Orchestration Mode, please use the
- If you're on an AzureRM 1.x release, please note that the new scale set resources were released in v2.0, so you'll need to upgrade your provider to implement the fix. Please see this link for the Upgrade guide to v2.0.
-
Please also note that as a Support organization we no longer assist with AzureRM 1.x releases because it is now EOL (End Of Life). Please see this link for our general EOL policies.
Hope that helps. Thank you.