Error: Terraform azapi deployment of Microsoft.Maintenance/configurationAssignments for dynamic scope with Update Manager

Kowsigan Alagarajah 25 Reputation points
2024-02-28T13:47:35.4366667+00:00

Hello
I try to deploy: Microsoft.Maintenance/configurationAssignments in terraform with azapi (version 2023-04-01) on Maintenance configuration already created in terraform in the same template

The goal is to use the dynamic scope to the maintenance config.

I followed this doc : https://learn.microsoft.com/en-us/azure/templates/microsoft.maintenance/configurationassignments?pivots=deployment-language-terraform#property-values-2 This leads however to the following error

--------------------------------------------------------------------------------
│ RESPONSE 500: 500 Internal Server Error
│ ERROR CODE UNAVAILABLE
│ --------------------------------------------------------------------------------
│ {
│   "Message": "An error has occurred."
│ }
│ --------------------------------------------------------------------------------
│
│
│   with azapi_resource.test,
│   on new.tf line 26, in resource "azapi_resource" "test"
│   26: 

Terraform Code snippet :

resource "azapi_resource" "test" {
  type = "Microsoft.Maintenance/configurationAssignments@2023-04-01"
  name = "toto"
  parent_id = "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  body = jsonencode({
  properties = {
    filter = {
      resourceTypes = [
        "Microsoft.Compute/virtualMachines"
      ],
      resourceGroups = [
      ],
      tagSettings = {
        tags = {
          tag1 = [
            "value1",
          ]
        },
        filterOperator = "All"
      },
      locations = [
        "West US 2"
      ]
    },
    maintenanceConfigurationId = "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/RSG/providers/microsoft.maintenance/maintenanceconfigurations/maintenanceconfigurationname1",
    resourceId = "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/"
  }
})
}

Thank you for your help

Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
320 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.