CodexBloom - AI-Powered Q&A Platform

Terraform not applying changes to Azure VM size due to unexpected dependency issues

πŸ‘€ Views: 4 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-05
terraform azure virtual-machine

I'm currently facing an issue with Terraform where it refuses to apply changes to the size of an Azure VM. I have a configuration that defines a VM and an associated network interface. When I attempt to change the size of the VM from `Standard_DS1_v2` to `Standard_DS2_v2`, the following error occurs: ``` Error: Error updating Virtual Machine 'my-vm' (Resource Group 'my-resource-group'): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The specified VM size is not available in the specified location." ``` I've double-checked the available VM sizes in my Azure region, and `Standard_DS2_v2` should be available. Here’s a snippet of my Terraform configuration: ```hcl resource "azurerm_network_interface" "example" { name = "my-nic" location = "East US" resource_group_name = azurerm_resource_group.example.name ip_configuration { name = "my-ip-config" subnet_id = azurerm_subnet.example.id private_ip_address_allocation = "Dynamic" } } resource "azurerm_virtual_machine" "example" { name = "my-vm" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name network_interface_ids = [azurerm_network_interface.example.id] vm_size = "Standard_DS2_v2" os_profile { computer_name = "hostname" admin_username = "adminuser" admin_password = "P@ssw0rd" } os_profile_linux_config { disable_password_authentication = false } } ``` I have tried removing the VM and re-creating it, but the configuration remains the same, and I continue to run into the same error. Additionally, I made sure to upgrade to the latest version of the Azure provider (v2.80.0), but the issue persists. I also verified that the resource group and region are correctly specified without any typos. Any insights on what might be causing this behavior or how I can debug this issue further would be greatly appreciated.