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.53k stars 4.61k forks source link

azurerm_automation_software_update_configuration invalid request #23622

Open DevopsMercenary opened 11 months ago

DevopsMercenary commented 11 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.5.7

AzureRM Provider Version

3.76.0

Affected Resource(s)/Data Source(s)

azurerm_automation_software_update_configuration

Terraform Configuration Files

resource "azurerm_automation_account" "default" {

  name = "${azurerm_linux_virtual_machine.-host.name}vmupdate"

  location            = azurerm_resource_group.default.location
  resource_group_name = azurerm_resource_group.default.name
  sku_name            = "Basic"

  tags = local.tag-map
  lifecycle {
    ignore_changes = [
      tags,
    ]
  }
}

resource "azurerm_automation_software_update_configuration" "default" {

  name                  = azurerm_linux_virtual_machine.-host.name
  automation_account_id = azurerm_automation_account.default.id

  linux {
    classification_included = "Security"
    reboot                  = "IfRequired"
  }

  virtual_machine_ids = [azurerm_linux_virtual_machine.-host.id]

  schedule {
    frequency          = "Week"
    interval           = 1
    is_enabled         = true
    advanced_week_days = ["Sunday"]
    time_zone          = "America/New_York"
  }

  duration = "PT2H2M2S"
}

### Debug Output/Panic Output

```shell
│ Error: creating Software Update Configuration (Subscription: "0f849332-18f0-45f6-abf6-3bcd9058d3eb"
│ Resource Group Name: "host"
│ Automation Account Name: "hostvmupdate"
│ Software Update Configuration Name: "host"): softwareupdateconfiguration.SoftwareUpdateConfigurationClient#Create: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="{\"Message\":\"The request is invalid.\",\"ModelState\":{\"softwareUpdateConfiguration.properties.updateConfiguration\":[\"Software update configuration should specify Classification or IncludedPackageNameMask for any reboot setting other than 'RebootOnly'.\"]}}"
│
│   with azurerm_automation_software_update_configuration.default,
│   on auto-update-automation.tf line 21, in resource "azurerm_automation_software_update_configuration" "default":
│   21: resource "azurerm_automation_software_update_configuration" "default" {
│
│ creating Software Update Configuration (Subscription: "0f849332-18f0-45f6-abf6-3bcd9058d3eb"
│ Resource Group Name: "host"
│ Automation Account Name: "hostvmupdate"
│ Software Update Configuration Name: "host"): softwareupdateconfiguration.SoftwareUpdateConfigurationClient#Create: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest"
│ Message="{\"Message\":\"The request is invalid.\",\"ModelState\":{\"softwareUpdateConfiguration.properties.updateConfiguration\":[\"Software update configuration should specify Classification or IncludedPackageNameMask for any reboot setting other than
│ 'RebootOnly'.\"]}}"

Expected Behaviour

azurerm_automation_software_update_configuration.default: Creating...
azurerm_automation_software_update_configuration.default: Creation complete after 1s [id=/subscriptions/0f849332-18f0-45f6-abf6-3bcd9058d3eb/resourceGroups/host/providers/Microsoft.Automation/automationAccounts/hostvmupdate/softwareUpdateConfigurations/host]
Releasing state lock. This may take a few moments...

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Actual Behaviour

See debug output

Steps to Reproduce

terraform apply

Important Factoids

N/A

References

No response

DevopsMercenary commented 11 months ago

Downgrade to 3.75.0 works fine

wuxu92 commented 11 months ago

Hi @DevopsMercenary Thanks for filing this issue. This is a known break that #23564 has fixed it. Could you please have a try with v3.77.0 when it is released? Also, you can use classifications_included, instead of deprecated classification_included, to specify the classification property which should works in the latest 3.76.0 version.

  linux {
    classifications_included = ["Security"]
    reboot                  = "IfRequired"
  }
DevopsMercenary commented 11 months ago

Thanks. I'll verify this in a little bit.

Please update the docs. The example code is still classification_included = "Security"

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_software_update_configuration