Azurerm_linux_virtual_machine (or windows)

Community Note

  • Please vote on this issue by adding a :+1: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.14.8

Affected Resource(s)

  • azurerm_linux_virtual_machine
  • azurerm_windows_virtual_machine

Terraform Configuration Files

resource "azurerm_linux_virtual_machine" "linux" {
  name                  = "linuxVM"
  location              = azurerm_resource_group.main.location
  resource_group_name   = azurerm_resource_group.main.name
  network_interface_ids = [azurerm_network_interface.linux.id]
  size                  = var.linux_vm_size
  license_type          = "RHEL_BYOS"

  source_image_reference {
    publisher = "redhat"
    offer     = "rhel-byos"
    sku       = "rhel-lvm83"
    version   = "latest"
  }

  plan {
    name      = "rhel-lvm83"
    product   = "rhel-byos"
    publisher = "redhat"
  }

  os_disk {
    name                 = "Linux-OS-Disk"
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  computer_name                   = "linuxVM"
  admin_username                  = var.linux_admin_user
  disable_password_authentication = true
  # admin_password                  = random_password.linux.result
  admin_ssh_key {
    username   = var.linux_admin_user
    public_key = local.ssh_key
  }

  boot_diagnostics {
    storage_account_uri = ""
  }

  # Install some packages
  provisioner "local-exec" {
    working_dir = "${path.root}/../ansible"
    command     = "/bin/bash -c 'source venv/bin/activate && ansible-playbook linux.yml -v'"
  }

  tags = {
    kind = "linux"
  }

  depends_on = [azurerm_marketplace_agreement.rhel_byos]
}

Debug Output

azurerm_linux_virtual_machine.linux: Importing from ID "/subscriptions/xxxxxxxx-xxxx-xxxx
-xxxx-xxxxxxxxxxxx/resourceGroups/ced-ad-lab-dev-rg/providers/Microsoft.Compute/virtualMachines/linuxVM"...

Error: The "azurerm_linux_virtual_machine" resource doesn't support attaching OS Disks - please use the `azurerm_virtual_machine` resource instead

Panic Output

Expected Behaviour

Could import resource : see here

Actual Behaviour

Steps to Reproduce

  1. terraform import azurerm_linux_virtual_machine.linux /subscriptions/xxxxxxxx-xxxx-xxxx -xxxx-xxxxxxxxxxxx/resourceGroups/ced-ad-lab-dev-rg/providers/Microsoft.Compute/virtualMachines/linuxVM

Important Factoids

References

  • #0000

In case this is a GitHub issue, you should provide the link and not just copy/paste the issue content.