Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does azurerm_windows_virtual_machine support creation from image with managed data disks #5767

Closed
rbarna1 opened this issue Feb 14, 2020 · 6 comments

Comments

@rbarna1
Copy link

rbarna1 commented Feb 14, 2020

Reviewing the docs on the new azurerm_windows_virtual_machine resource, I dont see any reason why this shouldnt work.
We use terraform to create Windows Server images that have managed data disks.
In v0.11 with the Azure provider, when we subsequently make VMs from those images no mention of the managed disk snapshots is required....they simply come w/ the image. In v0.12 we get the following error. I want to see if this is SUPPOSED to work before opening an Issue:

Error: Error creating Windows Virtual Machine "BBVM1-vm" (Resource Group "BBVM1"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="StorageProfile.dataDisks.lun does not have required value(s) for image specified in storage profile." Target="storageProfile"
on modules\vm-base\main.tf line 47, in resource "azurerm_windows_virtual_machine" "config":
47: resource "azurerm_windows_virtual_machine" "config" {

Our old v0.11 version

resource "azurerm_virtual_machine" "config" {
  count                            = "${contains(var.servers_needed, var.computer_name) ? 1 : 0}"
  name                             = "${local.name}-vm"
  location                         = "${azurerm_resource_group.config.location}"
  license_type                     = "Windows_Server"
  resource_group_name              = "${azurerm_resource_group.config.name}"
  network_interface_ids            = ["${azurerm_network_interface.config.id}"]
  vm_size                          = "${var.virtual_machine_size}"
  delete_os_disk_on_termination    = true
  delete_data_disks_on_termination = true

  storage_image_reference {
    id = "${data.azurerm_image.search.id}"
  }

  storage_os_disk {
    name              = "${local.name}-os-disk"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "StandardSSD_LRS"
  }

  os_profile {
    computer_name  = "${local.name}"
    admin_username = "${var.admin_username}"
    admin_password = "${var.admin_password}"
  }

  os_profile_windows_config {
    provision_vm_agent        = true
    enable_automatic_upgrades = false

    additional_unattend_config {
      pass         = "oobeSystem"
      component    = "Microsoft-Windows-Shell-Setup"
      setting_name = "AutoLogon"
      content      = "<AutoLogon><Password><Value>${var.admin_password}</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>${var.admin_username}</Username></AutoLogon>"
    }

    additional_unattend_config {
      pass         = "oobeSystem"
      component    = "Microsoft-Windows-Shell-Setup"
      setting_name = "FirstLogonCommands"
      content      = "${file("${path.root}/FirstLogonCommands.xml")}"
    }
  }
}

Our new v0.12 with the current beta azurerm_windows_virtual_machine

resource "azurerm_windows_virtual_machine" "config" {
  count                 = contains(var.servers_needed, var.computer_name) ? 1 : 0
  name                  = "${local.name}-vm"
  location              = azurerm_resource_group.config[0].location
  resource_group_name   = azurerm_resource_group.config[0].name
  network_interface_ids = [azurerm_network_interface.config[0].id]
  size                  = var.virtual_machine_size
  source_image_id       = data.azurerm_image.search.id
  computer_name         = local.name
  admin_username        = var.admin_username
  admin_password        = var.admin_password

  os_disk {
    name                 = "${local.name}-os-disk"
    caching              = "ReadWrite"
    storage_account_type = "StandardSSD_LRS"
  }

  additional_unattend_content {
    setting = "AutoLogon"
    content = "<AutoLogon><Password><Value>${var.admin_password}</Value></Password><Enabled>true</Enabled><LogonCount>1</LogonCount><Username>${var.admin_username}</Username></AutoLogon>"
  }

  additional_unattend_content {
    setting = "FirstLogonCommands"
    content = file("${path.root}/FirstLogonCommands.xml")
  }
}
@BClev

This comment has been minimized.

@tombuildsstuff

This comment has been minimized.

@rbarna1

This comment has been minimized.

@rbarna1
Copy link
Author

rbarna1 commented Feb 19, 2020

Ok, so no traction here.
@tombuildsstuff I see you marked this as an enhancement. Does that mean you think this ought to work but that it appears not to? Or should I post this another way to get some visibility.

@rbarna1
Copy link
Author

rbarna1 commented Mar 5, 2020

Converting to bug:
#6004

@rbarna1 rbarna1 closed this as completed Mar 5, 2020
@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants