hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.52k stars 4.6k forks source link

azurerm_maintenance_configuration fails when assigning more than one maintenance configuration: Confirm API version #23772

Open A1lard opened 10 months ago

A1lard commented 10 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.6.3

AzureRM Provider Version

3.79.0

Affected Resource(s)/Data Source(s)

maintenance configuration assignment

Terraform Configuration Files

resource "azurerm_maintenance_configuration" "definition_updates" {
  name                      = "Definition_Updates"
  resource_group_name       = module.resource_group.output_resource_group[0].name
  location                  = module.resource_group.output_resource_group[0].location
  scope                     = "InGuestPatch"
  in_guest_user_patch_mode  = "User"

  window {
    start_date_time         = "2022-10-25 01:00"
    duration                = "03:00"
    time_zone               = "W. Europe Standard Time"
    recur_every             = "6Hour"
  }

  install_patches {
    reboot = "IfRequired"

    windows {
      classifications_to_include = ["Definition"]
    }
  }
}

resource "azurerm_maintenance_assignment_virtual_machine" "patch_window" {
  location                     = var.location
  maintenance_configuration_id = (
    var.maintenance_configuration == "Ring_0" ? module.variables.azurerm_maintenance_configuration_patch_window_ring_0_id : 
      (var.maintenance_configuration == "Ring_1" ? module.variables.azurerm_maintenance_configuration_patch_window_ring_1_id : 
        (var.maintenance_configuration == "Ring_2" ? module.variables.azurerm_maintenance_configuration_patch_window_ring_2_id : ""
        )
      )
    )
  virtual_machine_id           = azurerm_windows_virtual_machine.virtual_machine.id
}
resource "azurerm_maintenance_assignment_virtual_machine" "Definition_Updates" {
  location                     = var.location
  maintenance_configuration_id = module.variables.azurerm_maintenance_configuration_definition_updates
  virtual_machine_id           = azurerm_windows_virtual_machine.virtual_machine.id
}

Debug Output/Panic Output

Plan: 2 to add, 0 to change, 0 to destroy.
module.virtualmachine2.azurerm_maintenance_assignment_virtual_machine.definition_updates: Creating...
module.virtualmachine.azurerm_maintenance_assignment_virtual_machine.definition_updates: Creating...
╷
│ Error: checking for presence of existing Scoped Configuration Assignment (Scope: "/subscriptions/*ID*/resourceGroups/*resourcegroup*/providers/Microsoft.Compute/virtualMachines/*VM*"

│ Configuration Assignment Name: "Definition_Updates"): configurationassignments.ConfigurationAssignmentsClient#Get: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidResource" Message="Invalid configurationAssignmentName: Definition_Updates. Confirm api version."
│ 
│   with module.virtualmachine.azurerm_maintenance_assignment_virtual_machine.definition_updates,
│   on ../../modules/virtual_machine/maintenance_assignment.tf line 15, in resource "azurerm_maintenance_assignment_virtual_machine" "definition_updates":
│   15: resource "azurerm_maintenance_assignment_virtual_machine" "definition_updates" {
│

Expected Behaviour

The expected behaviour is that the maintenance configuration named "Definition_Updates" is assigned to the vm's.

Actual Behaviour

Error during the plan stage mentioning: Confirm API version while checking the presence of an existing scope.

Steps to Reproduce

When I manually remove the vm from the maintenance assignment on the tenant and run our main code I get the error "Confirm API version"

The issue occurs when trying to add 2 different maintenance configurations on 1 vm. When I remark one of the two maintenance assignments I dont get the code but when I want to add both of our maintenance assignments I get the error: Confirm API version.

Things I tried to fix this issue:

Important Factoids

No response

References

No response

rob31231232 commented 10 months ago

Same issue here

rob31231232 commented 10 months ago

Looks like the same issue as #20397 but now with an other error message. @ziyeqf last time you solved this issue. Maybe you know why this happends?

tiwonl commented 10 months ago

Same issue here!

ziyeqf commented 10 months ago

Hi @A1lard, thanks for reporting.

I can reproduce your issue. We are reaching out to maintenance team to diagnostic. Will update here once we get a solution.

Thanks

Kockieee commented 9 months ago

Any update on this?

ziyeqf commented 9 months ago

Any update on this?

It's will be updated on the service side, and it's still in progress.

ppiorkow commented 7 months ago

Any update on this?

Ps. I have same issue with terraform v1.6.1, hashicorp/azurerm v3.88.0.

ziyeqf commented 7 months ago

Any update on this?

Ps. I have same issue with terraform v1.6.1, hashicorp/azurerm v3.88.0.

Hi @ppiorkow, sorry for the inconvenience, the fix has not been released on the service yet, have push the service team to release that.

RemiHG commented 7 months ago

Hi, If that can help to escalade, I also have the same issue. Terraform v1.2.4, hashicorp/azurerm v3.67.0 Thanks to have a look. Rémi

A1lard commented 6 months ago

@ziyeqf Is it possible to tell when this fix will be released?

ziyeqf commented 5 months ago

Hi @A1lard, per our testing the issue has been fixed. Could you please give it another try? And if the issue is fixed please close this GIthub issue.

Thanks!

r-anis commented 2 weeks ago

https://discuss.hashicorp.com/t/assigning-maintenance-configuration-to-multiple-existing-virtual-machines/66397 seems resolved the issue.