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

Add a notice to documentation that delete_os_disk_on_termination and delete_data_disks_on_termination are applied only when VM is deleted via Terraform and it will not work in case it was deleted manually #4343

Closed
alex-vasilchenko-md opened this issue Sep 17, 2019 · 1 comment · Fixed by #4478

Comments

@alex-vasilchenko-md
Copy link

alex-vasilchenko-md commented Sep 17, 2019

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

Description

I had following problem: I was creating VMs in Azure for temporary usage and then some of them were deleted manually via UI in Azure portal.
In Terraform file VM had following flags set to true:
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true

Azure API works in a way, that you have to delete resources related to VM manually. Terraform handles it if you create VM with those flags and terminate with Terraform.

Initially I thought it would work like AWS and setting would work same like DeleteOnTermination setting and delete volumes no matter if I do this via Terraform or manually.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html

By default, Amazon EBS root device volumes are automatically deleted when the instance terminates. However, by default, any additional EBS volumes that you attach at launch, or any EBS volumes that you attach to an existing instance persist even after the instance terminates. This behavior is controlled by the volume's DeleteOnTermination attribute, which you can modify. For more information, see Preserving Amazon EBS Volumes on Instance Termination.

I suggest to add a notice in documentation here:
https://www.terraform.io/docs/providers/azurerm/r/virtual_machine.html#delete_os_disk_on_termination
and here:
https://www.terraform.io/docs/providers/azurerm/r/virtual_machine.html#delete_data_disks_on_termination

that would look like this: "This setting works when instance is deleted via Terraform only and don't forget to delete disks manually if you deleted VM manually. It can increase spendings".

New or Affected Resource(s)

  • azurerm_virtual_machine

Potential Terraform Configuration

resource "azurerm_virtual_machine" "instance" {
  name = "${var.azure_vm_size}.${random_id.instance_id.hex}"
  location = "${data.azurerm_resource_group.group.location}"
  resource_group_name = "${data.azurerm_resource_group.group.name}"
  network_interface_ids = [
    "${azurerm_network_interface.nic.id}"
  ]
  vm_size = "${var.azure_vm_size}"
  delete_os_disk_on_termination = true
  delete_data_disks_on_termination = true

  storage_image_reference {
    publisher = "${var.azure_image_publisher}"
    offer = "${var.azure_image_offer}"
    sku = "${var.azure_image_sku}"
    version = "latest"
  }

References

  • #0000
@ghost
Copy link

ghost commented Mar 29, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants