terraform-provider-azurerm: azurerm_virtual_machine_data_disk_attachment attach fails for more than 1 disks.

Community Note

  • Please vote on this issue by adding a 👍 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 Version

0.10.4

Affected Resource(s)

  • azurerm_virtual_machine_data_disk_attachment

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_0[0]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_0[1]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[0]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[1]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_2[0]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_2[1]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_3[0]
  + module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_3[1]
module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_0[0]: Creating...
module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_0[1]: Creating...
module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_0[1]: Creation complete after 1m1s (ID: /subscriptions/02a2bcea-0861-437c-9a66-...02/dataDisks/usw90cavesd1602_datadisk0)
module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_0[0]: Creation complete after 1m36s (ID: /subscriptions/02a2bcea-0861-437c-9a66-...01/dataDisks/usw90cavesd1601_datadisk0)
module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[0]: Creating...
module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[1]: Creating...
* module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[1]: 1 error(s) occurred:
* azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1.1: Error updating Virtual Machine "usw90cavesd1602" (Resource Group "usw90cavelastic16_rg") with Disk "usw90cavesd1602_datadisk1": compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: 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 6309.'."
* module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[0]: 1 error(s) occurred:
* azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1.0: Error updating Virtual Machine "usw90cavesd1601" (Resource Group "usw90cavelastic16_rg") with Disk "usw90cavesd1601_datadisk1": compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: 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 6309.'."

Panic Output

Expected Behavior

Trying to create 2 VMS and 4 data disks on each and attach them. All 4 disks should be attached successfully.

Actual Behavior

Both the VMs get 1st disk attached successfully and for other disks get the following error:

* module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[1]: 1 error(s) occurred:
* azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1.1: Error updating Virtual Machine "usw90cavesd1602" (Resource Group "usw90cavelastic16_rg") with Disk "usw90cavesd1602_datadisk1": compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: 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 6309.'."
* module.elastic16.azurerm_virtual_machine_data_disk_attachment.esddisk_attach_1[0]: 1 error(s) occurred:

Steps to Reproduce

  1. terraform apply

Important Factoids

References

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 31 (10 by maintainers)

Most upvoted comments

hey @stonefury

Thanks for the repro - I’ve opened #1950 which includes a fix for this (and an acceptance test now we’ve been able to isolate it) - thanks for the help here 😃

Thanks!

Having a similar problem as @stonefury , I am destroying a VM with a data disk attachment, I am now using 1.14.0 as well and still get the error on first destroy, I get this error.

  • azurerm_virtual_machine_data_disk_attachment.avm-datadisk.1: Error removing Disk “avm-00001-web-data-disk1-dev-1-b0479f” from Virtual Machine “avm-00001-web-dev-1-b0479f” (Resource Group “bOOYA-00001-dev-a944f8”): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 – Original Error: 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 1526.’.”

I am also running a azurerm_virtual_machine_extension resource that pushes a powershell script via a template_file resource

publisher = “Microsoft.Compute” type = “CustomScriptExtension” type_handler_version = “1.9”

first pass at destroy fails, second one works.

@tombuildsstuff I seem to still have the issue with attaching disks and I just had my destroy operation fail with the same operation. But re-running the tf plan cleaned up the ones that bombed, which is OK, at least a re-run cleaned it.

So here is my take on the error seen when attaching data disks. I have perhaps a special case, I am spinning up VMs with SQL server on them, and I am installing SqlIaasExtension. It seems like I must make this a dependency on my entire VM. Only when it’s created and all disks are attached should I apply the extension. My suspicion is if the extension is applied while the data disks are being attached, then it creates that error condition. In my case I am applying 15+ disks, so it takes quite a while and gives enough time for this to happen.

}

resource "azurerm_virtual_machine_extension" "AZW1WSQLSAS_sql_extension" {
  depends_on           = ["module.AZW1WSQLSAS"] . # need this it seems to avoid attach failure.
  name                 = "SqlIaasExtension"
  location             = "${local.workspace["location"]}"
....

I can put my code up on github soon so the problem can be reproduced.

I would really like to know how this works for everyone else, just to make sure I’m not making some stupid mistake. terraform --version does show me 1.14.0. 😃