From 1228dccae01cc7b80401bf9de3b6a9d6937995ca Mon Sep 17 00:00:00 2001 From: "Elena Xin (Centific Technologies Inc)" Date: Thu, 11 Apr 2024 11:23:54 +0800 Subject: [PATCH 1/2] fix gh issue 25550 --- ..._software_update_configuration_resource.go | 2 +- ...ware_update_configuration_resource_test.go | 64 +++++++++++++++++++ ...oftware_update_configuration.html.markdown | 2 +- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/internal/services/automation/automation_software_update_configuration_resource.go b/internal/services/automation/automation_software_update_configuration_resource.go index e1f370978904..f413a805bd4e 100644 --- a/internal/services/automation/automation_software_update_configuration_resource.go +++ b/internal/services/automation/automation_software_update_configuration_resource.go @@ -628,7 +628,7 @@ func (m SoftwareUpdateConfigurationResource) Arguments() map[string]*pluginsdk.S "occurrence": { Type: pluginsdk.TypeInt, Required: true, - ValidateFunc: validation.IntBetween(1, 5), + ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, -1}), }, "day": { diff --git a/internal/services/automation/automation_software_update_configuration_resource_test.go b/internal/services/automation/automation_software_update_configuration_resource_test.go index 0cdaa020c000..a378adade163 100644 --- a/internal/services/automation/automation_software_update_configuration_resource_test.go +++ b/internal/services/automation/automation_software_update_configuration_resource_test.go @@ -63,6 +63,21 @@ func TestAccSoftwareUpdateConfiguration_linuxBasic(t *testing.T) { }) } +func TestAccSoftwareUpdateConfiguration_occurrence(t *testing.T) { + data := acceptance.BuildTestData(t, automation.SoftwareUpdateConfigurationResource{}.ResourceType(), "test") + r := newSoftwareUpdateConfigurationResource() + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.monthOccurrence(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + // scheduleInfo.advancedSchedule always returns null - https://github.com/Azure/azure-rest-api-specs/issues/24436 + data.ImportStep("schedule.0.advanced", "schedule.0.monthly_occurrence"), + }) +} + func TestAccSoftwareUpdateConfiguration_linuxComplete(t *testing.T) { data := acceptance.BuildTestData(t, automation.SoftwareUpdateConfigurationResource{}.ResourceType(), "test") r := newSoftwareUpdateConfigurationResource() @@ -340,6 +355,55 @@ resource "azurerm_automation_software_update_configuration" "test" { `, a.template(data), data.RandomInteger) } +func (a SoftwareUpdateConfigurationResource) monthOccurrence(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_automation_software_update_configuration" "test" { + automation_account_id = azurerm_automation_account.test.id + name = "acctest-suc-%[2]d" + + linux { + classifications_included = ["Critical", "Security"] + excluded_packages = ["apt"] + included_packages = ["vim"] + reboot = "RebootOnly" + } + + duration = "PT1H1M1S" + virtual_machine_ids = [] + + target { + azure_query { + scope = [azurerm_resource_group.test.id] + locations = [azurerm_resource_group.test.location] + } + + non_azure_query { + function_alias = "savedSearch1" + workspace_id = azurerm_log_analytics_workspace.test.id + } + } + + schedule { + description = "foo-schedule" + start_time = "%[3]s" + expiry_time = "%[4]s" + is_enabled = true + interval = 1 + frequency = "Month" + time_zone = "Etc/UTC" + monthly_occurrence { + occurrence = -1 + day = "Tuesday" + } + } + + depends_on = [azurerm_log_analytics_linked_service.test] +} +`, a.template(data), data.RandomInteger, a.startTime, a.expireTime) +} + func (a SoftwareUpdateConfigurationResource) linuxComplete(data acceptance.TestData) string { return fmt.Sprintf(` diff --git a/website/docs/r/automation_software_update_configuration.html.markdown b/website/docs/r/automation_software_update_configuration.html.markdown index 61c694ea1e63..f14797505122 100644 --- a/website/docs/r/automation_software_update_configuration.html.markdown +++ b/website/docs/r/automation_software_update_configuration.html.markdown @@ -208,7 +208,7 @@ The `monthly_occurrence` block supports the following: * `day` - (Required) Day of the occurrence. Must be one of `Monday`, `Tuesday`, `Wednesday`, `Thursday`, `Friday`, `Saturday`, `Sunday`. -* `occurrence` - (Required) Occurrence of the week within the month. Must be between `1` and `5`. `-1` for last week within the month. +* `occurrence` - (Required) Occurrence of the week within the month. Must be between `1` and `4`. `-1` for last week within the month. ## Attributes Reference From e76974182f9e8fd2ca45521b36e28b6a5a8f60fb Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 23 Oct 2024 22:24:14 -0700 Subject: [PATCH 2/2] Update internal/services/automation/automation_software_update_configuration_resource.go --- .../automation_software_update_configuration_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/automation/automation_software_update_configuration_resource.go b/internal/services/automation/automation_software_update_configuration_resource.go index f413a805bd4e..fc5e69d68b6b 100644 --- a/internal/services/automation/automation_software_update_configuration_resource.go +++ b/internal/services/automation/automation_software_update_configuration_resource.go @@ -628,7 +628,7 @@ func (m SoftwareUpdateConfigurationResource) Arguments() map[string]*pluginsdk.S "occurrence": { Type: pluginsdk.TypeInt, Required: true, - ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, -1}), + ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, -1}), // -1 is last week and 5 is invalid }, "day": {