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_managed_disk create fail, but this disk has created and could not delete by using terraform destroy #5254

Closed
SerenaLi279 opened this issue Dec 25, 2019 · 1 comment · Fixed by #6237

Comments

@SerenaLi279
Copy link

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 (and AzureRM Provider) Version

Terraform v0.12.17
terraform-provider-azurerm_v1.37.0_x4
(PS: it works well when use terraform-provider-azurerm_v1.31.0_x4)

Affected Resource(s)

  • "azurerm_managed_disk"

Terraform Configuration Files

resource "azurerm_managed_disk" "disk-02" {
  name                 = "${var.tag_name}-disk-sdd"
  location             = var.location
  resource_group_name  = var.resource_group_name
  storage_account_type = "Standard_LRS"
  create_option        = "Empty"
  disk_size_gb         = "10"
  tags = {
    Name = "${var.tag_name}-disk-02"
  }


  lifecycle {
    ignore_changes = [
        tags,
    ]
  }


}

resource "azurerm_virtual_machine_data_disk_attachment" "attach-disk-02" {
  managed_disk_id    = azurerm_managed_disk.disk-02.id
  virtual_machine_id = azurerm_virtual_machine.vm.id
  lun                = "2"
  caching            = "ReadWrite"

  depends_on = [azurerm_virtual_machine_data_disk_attachment.attach-disk-01]
}

resource "azurerm_managed_disk" "disk-03" {
  name                 = "${var.tag_name}-disk-sde"
  location             = var.location
  resource_group_name  = var.resource_group_name
  storage_account_type = "Standard_LRS"
  create_option        = "Empty"
  disk_size_gb         = "20"
  tags = {
    Name = "${var.tag_name}-disk-03"
  }


  lifecycle {
    ignore_changes = [
        tags,
    ]
  }


}

resource "azurerm_virtual_machine_data_disk_attachment" "attach-disk-03" {
  managed_disk_id    = azurerm_managed_disk.disk-03.id
  virtual_machine_id = azurerm_virtual_machine.vm.id
  lun                = "3"
  caching            = "ReadWrite"

  depends_on = [azurerm_virtual_machine_data_disk_attachment.attach-disk-02]
}

Debug Output

  1. Could find disk-02: serena-centos-cswe-01-disk-sdd creation complete
  2. But could not find the inform for disk-03: serena-centos-cswe-01-disk-sde
    Check this disk-03: serena-centos-cswe-01-disk-sde from azure portal, it exists ----that means it has been created by terraform indeed
2019-12-25 06:04:01,396 DEBUG: module.serena-centos-cswe-01.azurerm_managed_disk.disk-02: Creation complete after 10s [id=/subscriptions/66e8f030-dbe5-4677-bd29-06b963faa0ac/resourceGroups/compaas-01-dev/providers/Microsoft.Compute/disks/serena-centos-cswe-01-disk-sdd]
  1. This disk-03: serena-centos-cswe-01-disk-sde could not be deleted when run terraform destroy, should delete it manually

Expected Behavior

Create successfully

Actual Behavior

2019-12-25 06:10:08,504 DEBUG: Error: compute.DisksClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Compute/disks/serena-centos-cswe-01-disk-sde' under resource group 'compaas-01-dev' was not found."
2019-12-25 06:10:08,504 DEBUG:
2019-12-25 06:10:08,504 DEBUG:   on modules/instance/serena-centos/group_02/main.tf line 242, in resource "azurerm_managed_disk" "disk-03":
2019-12-25 06:10:08,504 DEBUG:  242: resource "azurerm_managed_disk" "disk-03" {
2019-12-25 06:10:08,505 DEBUG:
2019-12-25 06:10:08,505 DEBUG:
2019-12-25 06:10:11,781  INFO:

Steps to Reproduce

This issue does not always happen( I try 5 times and 1 time fail)

  1. terraform apply
@SerenaLi279 SerenaLi279 changed the title azurerm_managed_disk create fail, but disk has created azurerm_managed_disk create fail, but this disk has created and could not delete by using terraform destroy Dec 25, 2019
@ghost
Copy link

ghost commented Apr 24, 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 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants