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

azurerm_virtual_machine_data_disk_attachment - Error on Destroy #1942

Closed
nirmalparekh1984 opened this issue Sep 18, 2018 · 2 comments
Closed

Comments

@nirmalparekh1984
Copy link

nirmalparekh1984 commented Sep 18, 2018

Terraform Version

Terraform v0.11.7

  • provider.azurerm v1.15.0
  • provider.template v1.0.0

Affected Resource(s)

azurerm_virtual_machine_data_disk_attachment

Terraform Configuration Files

resource "azurerm_managed_disk" "md" {
  count                = "${var.number_of_vm * var.disks_per_vm}"
  name                 = "data-${local.naming_standard}-${count.index}-${terraform.workspace}"
  location             = "${data.azurerm_resource_group.rg.location}"
  resource_group_name  = "${data.azurerm_resource_group.rg.name}"
  storage_account_type = "Premium_LRS"
  create_option        = "${var.create_option}"
  source_resource_id   = "${data.azurerm_subscription.current.id}/resourceGroups/${data.azurerm_resource_group.rg.name}/providers/Microsoft.Compute/disks/${element(var.disk_names, count.index)}"
  disk_size_gb         = "${var.data_disk_size}"
}


resource "azurerm_virtual_machine_data_disk_attachment" "attach_disk" {
  depends_on         = ["azurerm_virtual_machine.vm"]
  count              = "${var.number_of_vm * var.disks_per_vm }"
  managed_disk_id    = "${element(azurerm_managed_disk.md.*.id, count.index)}"
  virtual_machine_id = "${element(local.vm_id, count.index % var.number_of_vm)}"
  lun                = "${count.index/var.number_of_vm}"
  caching            = "ReadWrite"
}

Expected Behavior

It should Destroy all the Managed Disk

Actual Behavior

azurerm_virtual_machine_data_disk_attachment.attach_disk.0: Error removing Disk "data-qa-ue1-cntr-asvmssystemcenter-2-b-q1-east" from Virtual Machine "vm-cntr-b-q1-0" (Resource Group "rg-apps-qa-ue1-asvmssystemcenter"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidRequestContent" Message="The request content was invalid and could not be deserialized: 'Could not find member 'resources' on object of type 'ResourceDefinition'. Path 'resources', line 1, position 2053.'."

Steps to Reproduce

  1. Create Managed Disk using
    resource "azurerm_managed_disk" "md" {
    count = "${var.number_of_vm * var.disks_per_vm}"
    name = "data-${local.naming_standard}-${count.index}-${terraform.workspace}"
    location = "${data.azurerm_resource_group.rg.location}"
    resource_group_name = "${data.azurerm_resource_group.rg.name}"
    storage_account_type = "Premium_LRS"
    create_option = "EMPTY"
    disk_size_gb = "50"
    }

  2. Create VM

  3. Attach Disk using azurerm_virtual_machine_data_disk_attachment

  4. Destroy
    It fails on Destroy

@tombuildsstuff
Copy link
Contributor

hey @nirmalparekh1984

Thanks for opening this issue :)

Taking a quick look into this there's now a means of reproducing this in the original issue - as such I've re-opened the original issue (#1600) which I'm going to close this in favour of - please subscribe to that issue for updates

Thanks!

@ghost
Copy link

ghost commented Mar 5, 2019

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 Mar 5, 2019
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

2 participants