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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_maintenance_assignment_virtual_machine does not remove a deleted VM attachment #26538

Open
1 task done
SurveySky opened this issue Jul 4, 2024 · 0 comments
Open
1 task done

Comments

@SurveySky
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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 comments along the lines of "+1", "me too" or "any updates", 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 and review the contribution guide to help.

Terraform Version

1.3.0

AzureRM Provider Version

3.107.0

Affected Resource(s)/Data Source(s)

azurerm_maintenance_assignment_virtual_machine

Terraform Configuration Files

resource "azurerm_maintenance_configuration" "main" {
  name                     = "${var.prefix}-mc"
  resource_group_name      = var.resource_group_name
  location                 = var.location
  scope                    = var.scope
  visibility               = var.visibility
  in_guest_user_patch_mode = var.in_guest_user_patch_mode
  tags                     = var.tags

  install_patches {
    windows {
      classifications_to_include = var.windows_classifications_to_include
      kb_numbers_to_exclude      = var.windows_kb_numbers_to_exclude
      kb_numbers_to_include      = var.windows_kb_numbers_to_include
    }
    linux {
      classifications_to_include    = var.linux_classifications_to_include
      package_names_mask_to_exclude = var.linux_package_names_mask_to_exclude
      package_names_mask_to_include = var.linux_package_names_mask_to_include
    }
    reboot = var.install_patches_reboot
  }

  window {
    start_date_time      = var.window_configuration.start_date_time
    expiration_date_time = var.window_configuration.expiration_date_time
    duration             = var.window_configuration.duration
    time_zone            = var.window_configuration.time_zone
    recur_every          = var.window_configuration.recur_every
  }
}

resource "azurerm_maintenance_assignment_virtual_machine" "main" {
  for_each                     = { for idx, val in var.virtual_machines : idx => val }
  location                     = var.location
  maintenance_configuration_id = azurerm_maintenance_configuration.main.id
  virtual_machine_id           = each.value
}

Debug Output/Panic Output

No error output.

Expected Behaviour

Expected behaviour is that 'azurerm_maintenance_assignment_virtual_machine' would notice that the VM is no longer there and would remove the attachment, instead of just updating the state and leaving attachment in the Azure portal.

Actual Behaviour

I provided a snippet of a module, which is for our patching solution. This module expects variable 'var.virtual_machines' - a list of vm ids. We have another module which creates VMs. When one of the vm is deleted, and the id of the vm is removed from the 'var.virtual_machines' variable, the attachment resource is not deleted. This creates a lot of manual work in the Azure portal.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant