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.46k stars 4.53k forks source link

azurerm_automation_software_update_configuration monthly_occurrence not allowing "-1" #25550

Open laner1977 opened 2 months ago

laner1977 commented 2 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.7.5

AzureRM Provider Version

3.95.0

Affected Resource(s)/Data Source(s)

azurerm_automation_software_update_configuration

Terraform Configuration Files

data "azurerm_automation_account" "Windows_Automation_Account" {
  name                = "Windows-Automation-Account"
  resource_group_name = "Windows-Automation-Account-RG"
}

resource "azurerm_automation_software_update_configuration" "ScheduleWindows" {
  name                  = "Windows-Automation"
  automation_account_id = azurerm_automation_account.Windows_Automation_Account.id
  target {
    azure_query {
      tag_filter = "All"
      tags {
        tag    = "UpdateGroup"
        values = "Cluster01"
      }
    }
  }
  schedule {
    is_enabled = true
    frequency  = "Month"
    time_zone  = "Etc/UTC"
    interval   = 1
    start_time = "10:00"
    monthly_occurrence {
      day        = "Thursday"
      occurrence = "-1"
    }
  }

  windows {
    classifications_included = ["Critical", "Security"]
    reboot                   = "Always"
  }
  duration = "PT3H"
}

Debug Output/Panic Output

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: expected schedule.0.monthly_occurrence.0.occurrence to be in the range (1 - 5), got -1
│
│   with module.automationAccount.azurerm_automation_software_update_configuration.ScheduleWindows["Windows-Automation"],
│   on main.tf line 149, in resource "azurerm_automation_software_update_configuration" "ScheduleWindows":
│  149:       occurrence = "-1"
│
╵

Expected Behaviour

According to https://registry.terraform.io/providers/hashicorp/azurerm/3.95.0/docs/resources/automation_software_update_configuration, the values for "occurrence" are expected to be 1-5 or -1. 1 meaning the first occurrence of the day and -1 meaning the last occurrence. When using occurrence = "-1" it is expected that the occurrence be set to "Last"

Actual Behaviour

Planning failed. Terraform encountered an error while generating this plan.

Error: expected schedule.0.monthly_occurrence.0.occurrence to be in the range (1 - 5), got -1

Steps to Reproduce

terraform plan

Important Factoids

No response

References

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

sinbai commented 2 months ago

Hi @laner1977 thanks for pointing this out. I have submitted PR to fix this issue. Could you please follow it for more updates?