What properties should be defined in Terraform code for selecting multiple subscriptions in dynamic scope in maintenance configuration?

Fahad Charoliya 0 Reputation points
2024-05-21T11:10:20.1+00:00

In the below code need help to modify terraform code to select multiple subscription in dynamic scope. Setting screenshot attached. mm dyanamic scope.png

resource "azapi_resource" "vm_maintenance_assignment" {
  type      = "Microsoft.Maintenance/configurationAssignments@2023-04-01"
  schema_validation_enabled = false
  name      = "dynamicscope"
  parent_id = "/subscriptions/${var.subscription_id}"
  body = jsonencode({
    properties = {
        filter = {
        osTypes = [ "WIndows","Linux"
        ]
        resourceGroups = [ ""
        ]
        resourceTypes = [
          "Microsoft.Compute/virtualMachines"
        ]
        tagSettings = {
          filterOperator = "All"
          tags = {
            UpdateSlot = ["1"]
            }
        }
        }
      maintenanceConfigurationId = azapi_resource.vm_maintenance.id
      resourceId = "/subscriptions/${var.subscription_id}"
  }
})
}

Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
261 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 21,766 Reputation points MVP
    2024-05-21T12:36:12.0466667+00:00

    Hi,

    There is no way that with single resource of type Microsoft.Maintenance/configurationAssignments to have multiple subscriptions in scope. The way that this is achieved is by creating multiple resources of type Microsoft.Maintenance/configurationAssignments with different parent_id and resourceId values to different subscriptions and referencing the same maintenance configuration in maintenanceConfigurationId.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments