Terraform-provider-azurerm: azurerm_virtual_machine_extension does not depend properly on azurerm_virtual_machine

Created on 2 Jul 2019  ยท  3Comments  ยท  Source: terraform-providers/terraform-provider-azurerm

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

Affected Resource(s)

  • azurerm_virtual_machine_extension
  • azurerm_virtual_machine

Terraform Configuration Files

resource "azurerm_virtual_machine_extension" "monitoringagent" {
  name                 = "OmsAgentForLinux"
  location             = azurerm_resource_group.vm.location
  resource_group_name  = azurerm_resource_group.vm.name
  virtual_machine_name = azurerm_virtual_machine.vm.name
  publisher            = "Microsoft.EnterpriseCloud.Monitoring"
  type                 = "OmsAgentForLinux"
  type_handler_version = "1.11"
  auto_upgrade_minor_version = true 
  settings = jsonencode({workspaceId : var.oms_workspaceId})
  protected_settings = jsonencode({workspaceKey : var.oms_workspaceKey})
}

Debug Output

Panic Output

Expected Behavior

When I taint the VM, I expect the extension to be removed and reinstalled.

Actual Behavior

Terraform just wants to destroy/create the VM, which gives me a shiny new VM without the extension.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
bug servicvirtual-machine

Most helpful comment

As a workaround, we add a tag to the VM like

resource "azurerm_virtual_machine" "vm" {
 lifecycle {
    ignore_changes = ["tags"]
  }
tags {
    created = "${timestamp()}"
  }

and use the value of this tag in the extensionname

resource "azurerm_virtual_machine_extension" "vmExtOms" {
  depends_on = ["azurerm_virtual_machine.vm"]
  name                 = "OMS_${replace(azurerm_virtual_machine.vm.tags.created, ":", ".")}"

All 3 comments

As a workaround, we add a tag to the VM like

resource "azurerm_virtual_machine" "vm" {
 lifecycle {
    ignore_changes = ["tags"]
  }
tags {
    created = "${timestamp()}"
  }

and use the value of this tag in the extensionname

resource "azurerm_virtual_machine_extension" "vmExtOms" {
  depends_on = ["azurerm_virtual_machine.vm"]
  name                 = "OMS_${replace(azurerm_virtual_machine.vm.tags.created, ":", ".")}"

๐Ÿ‘‹

Taking a look through here it appears this'll be fixed via #2456 - rather than having multiple issues open tracking the same thing I'm going to close this issue in favour of that one; would you mind subscribing to #2456 for updates?

Thanks!

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!

Was this page helpful?
0 / 5 - 0 ratings