From 1c7da13f9fccd3ac0d50e1dd694b63981e5c448c Mon Sep 17 00:00:00 2001 From: Sean Nixon Date: Fri, 27 Mar 2020 00:17:18 -0500 Subject: [PATCH] Update schema and tests based on review feedback --- ...e_arm_dev_test_global_shutdown_schedule.go | 111 +++++------- ..._dev_test_global_shutdown_schedule_test.go | 160 +++++++++++------- ...est_global_shutdown_schedule.html.markdown | 45 ++--- 3 files changed, 163 insertions(+), 153 deletions(-) diff --git a/azurerm/internal/services/devtestlabs/resource_arm_dev_test_global_shutdown_schedule.go b/azurerm/internal/services/devtestlabs/resource_arm_dev_test_global_shutdown_schedule.go index 33e09c1839cc..8d939dc63b6f 100644 --- a/azurerm/internal/services/devtestlabs/resource_arm_dev_test_global_shutdown_schedule.go +++ b/azurerm/internal/services/devtestlabs/resource_arm_dev_test_global_shutdown_schedule.go @@ -42,42 +42,29 @@ func resourceArmDevTestLabGlobalShutdownSchedule() *schema.Resource { Schema: map[string]*schema.Schema{ "location": azure.SchemaLocation(), - "target_resource_id": { + "virtual_machine_id": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: devtestValidate.GlobalScheduleVirtualMachineID, }, - "status": { - Type: schema.TypeString, + "enabled": { + Type: schema.TypeBool, Optional: true, - Default: dtl.EnableStatusEnabled, - ValidateFunc: validation.StringInSlice([]string{ - string(dtl.EnableStatusEnabled), - string(dtl.EnableStatusDisabled), - }, false), + Default: true, }, - "daily_recurrence": { - Type: schema.TypeList, + "daily_recurrence_time": { + Type: schema.TypeString, Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "time": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringMatch( - regexp.MustCompile("^(0[0-9]|1[0-9]|2[0-3]|[0-9])[0-5][0-9]$"), - "Time of day must match the format HHmm where HH is 00-23 and mm is 00-59", - ), - }, - }, - }, + ValidateFunc: validation.StringMatch( + regexp.MustCompile("^(0[0-9]|1[0-9]|2[0-3]|[0-9])[0-5][0-9]$"), + "Time of day must match the format HHmm where HH is 00-23 and mm is 00-59", + ), }, - "time_zone_id": { + "timezone": { Type: schema.TypeString, Required: true, ValidateFunc: validate.VirtualMachineTimeZoneCaseInsensitive(), @@ -89,26 +76,19 @@ func resourceArmDevTestLabGlobalShutdownSchedule() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Optional: true, - Default: dtl.NotificationStatusDisabled, - ValidateFunc: validation.StringInSlice([]string{ - string(dtl.NotificationStatusEnabled), - string(dtl.NotificationStatusDisabled), - }, false), + "enabled": { + Type: schema.TypeBool, + Required: true, }, "time_in_minutes": { Type: schema.TypeInt, Optional: true, - Computed: true, + Default: 30, ValidateFunc: validation.IntBetween(15, 120), }, "webhook_url": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: validate.NoEmptyStrings, + Type: schema.TypeString, + Optional: true, }, }, }, @@ -124,7 +104,7 @@ func resourceArmDevTestLabGlobalShutdownScheduleCreateUpdate(d *schema.ResourceD ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - targetResourceID := d.Get("target_resource_id").(string) + vmID := d.Get("virtual_machine_id").(string) vm, err := parse.GlobalScheduleVirtualMachineID(vmID) if err != nil { return err @@ -152,30 +132,27 @@ func resourceArmDevTestLabGlobalShutdownScheduleCreateUpdate(d *schema.ResourceD location := azure.NormalizeLocation(d.Get("location").(string)) taskType := "ComputeVmShutdownTask" - t := d.Get("tags").(map[string]interface{}) schedule := dtl.Schedule{ Location: &location, ScheduleProperties: &dtl.ScheduleProperties{ - TargetResourceID: &targetResourceID, + TargetResourceID: &vmID, TaskType: &taskType, }, - Tags: tags.Expand(t), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } - switch status := d.Get("status"); status { - case string(dtl.EnableStatusEnabled): + if d.Get("enabled").(bool) { schedule.ScheduleProperties.Status = dtl.EnableStatusEnabled - case string(dtl.EnableStatusDisabled): + } else { schedule.ScheduleProperties.Status = dtl.EnableStatusDisabled - default: } - if timeZoneId := d.Get("time_zone_id").(string); timeZoneId != "" { + if timeZoneId := d.Get("timezone").(string); timeZoneId != "" { schedule.ScheduleProperties.TimeZoneID = &timeZoneId } - if v, ok := d.GetOk("daily_recurrence"); ok { + if v, ok := d.GetOk("daily_recurrence_time"); ok { dailyRecurrence := expandArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(v) schedule.DailyRecurrence = dailyRecurrence } @@ -230,12 +207,11 @@ func resourceArmDevTestLabGlobalShutdownScheduleRead(d *schema.ResourceData, met } if props := resp.ScheduleProperties; props != nil { - d.Set("target_resource_id", props.TargetResourceID) - d.Set("time_zone_id", props.TimeZoneID) - - d.Set("status", string(props.Status)) + d.Set("virtual_machine_id", props.TargetResourceID) + d.Set("timezone", props.TimeZoneID) + d.Set("enabled", props.Status == dtl.EnableStatusEnabled) - if err := d.Set("daily_recurrence", flattenArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(props.DailyRecurrence)); err != nil { + if err := d.Set("daily_recurrence_time", flattenArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(props.DailyRecurrence)); err != nil { return fmt.Errorf("Error setting `dailyRecurrence`: %#v", err) } @@ -266,28 +242,24 @@ func resourceArmDevTestLabGlobalShutdownScheduleDelete(d *schema.ResourceData, m return nil } -func expandArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(recurrence interface{}) *dtl.DayDetails { - dailyRecurrenceConfigs := recurrence.([]interface{}) - dailyRecurrenceConfig := dailyRecurrenceConfigs[0].(map[string]interface{}) - dailyTime := dailyRecurrenceConfig["time"].(string) - +func expandArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(dailyTime interface{}) *dtl.DayDetails { + time := dailyTime.(string) return &dtl.DayDetails{ - Time: &dailyTime, + Time: &time, } } -func flattenArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(dailyRecurrence *dtl.DayDetails) []interface{} { +func flattenArmDevTestLabGlobalShutdownScheduleRecurrenceDaily(dailyRecurrence *dtl.DayDetails) interface{} { if dailyRecurrence == nil { - return []interface{}{} + return nil } - result := make(map[string]interface{}) - + var result string if dailyRecurrence.Time != nil { - result["time"] = *dailyRecurrence.Time + result = *dailyRecurrence.Time } - return []interface{}{result} + return result } func expandArmDevTestLabGlobalShutdownScheduleNotificationSettings(d *schema.ResourceData) *dtl.NotificationSettings { @@ -296,7 +268,12 @@ func expandArmDevTestLabGlobalShutdownScheduleNotificationSettings(d *schema.Res webhookUrl := notificationSettingsConfig["webhook_url"].(string) timeInMinutes := int32(notificationSettingsConfig["time_in_minutes"].(int)) - notificationStatus := dtl.NotificationStatus(notificationSettingsConfig["status"].(string)) + var notificationStatus dtl.NotificationStatus + if notificationSettingsConfig["enabled"].(bool) { + notificationStatus = dtl.NotificationStatusEnabled + } else { + notificationStatus = dtl.NotificationStatusDisabled + } return &dtl.NotificationSettings{ WebhookURL: &webhookUrl, @@ -320,9 +297,7 @@ func flattenArmDevTestLabGlobalShutdownScheduleNotificationSettings(notification result["time_in_minutes"] = *notificationSettings.TimeInMinutes } - if string(notificationSettings.Status) != "" { - result["status"] = string(notificationSettings.Status) - } + result["enabled"] = notificationSettings.Status == dtl.NotificationStatusEnabled return []interface{}{result} } diff --git a/azurerm/internal/services/devtestlabs/tests/resource_arm_dev_test_global_shutdown_schedule_test.go b/azurerm/internal/services/devtestlabs/tests/resource_arm_dev_test_global_shutdown_schedule_test.go index 1bac27986e24..8159a7a75ff7 100644 --- a/azurerm/internal/services/devtestlabs/tests/resource_arm_dev_test_global_shutdown_schedule_test.go +++ b/azurerm/internal/services/devtestlabs/tests/resource_arm_dev_test_global_shutdown_schedule_test.go @@ -23,33 +23,89 @@ func TestAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownBasic(t *testing Config: testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownBasic(data), Check: resource.ComposeTestCheckFunc( testCheckAzureRMDevTestLabGlobalShutdownScheduleExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "status", "Enabled"), - resource.TestCheckResourceAttr(data.ResourceName, "time_zone_id", "Pacific Standard Time"), + resource.TestCheckResourceAttr(data.ResourceName, "enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "timezone", "Pacific Standard Time"), resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.#", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.status", "Disabled"), - resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence.#", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence.0.time", "0100"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.enabled", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.time_in_minutes", "30"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.webhook_url", ""), + resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence_time", "0100"), resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), resource.TestCheckResourceAttr(data.ResourceName, "tags.environment", "Production"), ), }, data.ImportStep(), + }, + }) +} + +func TestAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownComplete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dev_test_global_shutdown_schedule", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMDevTestLabGlobalShutdownScheduleDestroy, + Steps: []resource.TestStep{ { - Config: testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownBasicUpdate(data), + Config: testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownComplete(data), Check: resource.ComposeTestCheckFunc( testCheckAzureRMDevTestLabGlobalShutdownScheduleExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "status", "Disabled"), - resource.TestCheckResourceAttr(data.ResourceName, "time_zone_id", "Central Standard Time"), + resource.TestCheckResourceAttr(data.ResourceName, "enabled", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "timezone", "Central Standard Time"), resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.#", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.status", "Enabled"), - resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.time_in_minutes", "30"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.time_in_minutes", "15"), resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.webhook_url", "https://www.bing.com/2/4"), - resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence.#", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence.0.time", "1100"), + resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence_time", "1100"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.Environment", "Production"), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownUpdate(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dev_test_global_shutdown_schedule", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMDevTestLabGlobalShutdownScheduleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownBasic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDevTestLabGlobalShutdownScheduleExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "timezone", "Pacific Standard Time"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.enabled", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.time_in_minutes", "30"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.webhook_url", ""), + resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence_time", "0100"), resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), resource.TestCheckResourceAttr(data.ResourceName, "tags.environment", "Production"), ), }, + data.ImportStep(), + { + Config: testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownComplete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMDevTestLabGlobalShutdownScheduleExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "enabled", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "timezone", "Central Standard Time"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.time_in_minutes", "15"), + resource.TestCheckResourceAttr(data.ResourceName, "notification_settings.0.webhook_url", "https://www.bing.com/2/4"), + resource.TestCheckResourceAttr(data.ResourceName, "daily_recurrence_time", "1100"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.Environment", "Production"), + ), + }, }, }) } @@ -61,7 +117,7 @@ func testCheckAzureRMDevTestLabGlobalShutdownScheduleExists(resourceName string) return fmt.Errorf("Not found: %s", resourceName) } - targetResourceID := rs.Primary.Attributes["target_resource_id"] + targetResourceID := rs.Primary.Attributes["virtual_machine_id"] exists, err := testCheckAzureRMDevTestLabGlobalShutdownScheduleExistsInternal(targetResourceID) if err != nil { @@ -81,7 +137,7 @@ func testCheckAzureRMDevTestLabGlobalShutdownScheduleDestroy(s *terraform.State) continue } - targetResourceID := rs.Primary.Attributes["target_resource_id"] + targetResourceID := rs.Primary.Attributes["virtual_machine_id"] exists, err := testCheckAzureRMDevTestLabGlobalShutdownScheduleExistsInternal(targetResourceID) if err != nil { @@ -121,27 +177,31 @@ func testCheckAzureRMDevTestLabGlobalShutdownScheduleExistsInternal(vmID string) func testAccAzureRMDevTestLabGlobalShutdownSchedule_template(data acceptance.TestData) string { return fmt.Sprintf(` +provider "azurerm" { + features {} +} + resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" + name = "acctestRG-dtl-%d" location = "%s" } resource "azurerm_virtual_network" "test" { - name = "acctvn-%d" + name = "acctestVN-%d" address_space = ["10.0.0.0/16"] location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_subnet" "test" { - name = "acctsub-%d" + name = "acctestSN-%d" resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" address_prefix = "10.0.2.0/24" } resource "azurerm_network_interface" "test" { - name = "acctnic-%d" + name = "acctestNIC-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" @@ -152,35 +212,28 @@ resource "azurerm_network_interface" "test" { } } -resource "azurerm_virtual_machine" "test" { - name = "acctvm-%d" +resource "azurerm_linux_virtual_machine" "test" { + name = "acctestVM-%d" location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" network_interface_ids = ["${azurerm_network_interface.test.id}"] - vm_size = "Standard_B2s" + size = "Standard_B2s" + + admin_username = "testadmin" + admin_password = "Password1234!" + disable_password_authentication = false - storage_image_reference { + source_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "18.04-LTS" version = "latest" } - storage_os_disk { - name = "myosdisk-%d" - caching = "ReadWrite" - create_option = "FromImage" - managed_disk_type = "Standard_LRS" - } - - os_profile { - computer_name = "hostname" - admin_username = "testadmin" - admin_password = "Password1234!" - } - - os_profile_linux_config { - disable_password_authentication = false + os_disk { + name = "myosdisk-%d" + caching = "ReadWrite" + storage_account_type = "Standard_LRS" } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) @@ -192,17 +245,13 @@ func testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownBasic(data accep %s resource "azurerm_dev_test_global_shutdown_schedule" "test" { - location = "${azurerm_resource_group.test.location}" - target_resource_id = "${azurerm_virtual_machine.test.id}" - - daily_recurrence { - time = "0100" - } - - time_zone_id = "Pacific Standard Time" + location = "${azurerm_resource_group.test.location}" + virtual_machine_id = "${azurerm_linux_virtual_machine.test.id}" + daily_recurrence_time = "0100" + timezone = "Pacific Standard Time" notification_settings { - status = "Disabled" + enabled = false } tags = { @@ -212,30 +261,27 @@ resource "azurerm_dev_test_global_shutdown_schedule" "test" { `, template) } -func testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownBasicUpdate(data acceptance.TestData) string { +func testAccAzureRMDevTestLabGlobalShutdownSchedule_autoShutdownComplete(data acceptance.TestData) string { template := testAccAzureRMDevTestLabGlobalShutdownSchedule_template(data) return fmt.Sprintf(` %s resource "azurerm_dev_test_global_shutdown_schedule" "test" { location = "${azurerm_resource_group.test.location}" - target_resource_id = "${azurerm_virtual_machine.test.id}" - status = "Disabled" + virtual_machine_id = "${azurerm_linux_virtual_machine.test.id}" + enabled = false - daily_recurrence { - time = "1100" - } - - time_zone_id = "Central Standard Time" + daily_recurrence_time = "1100" + timezone = "Central Standard Time" notification_settings { - time_in_minutes = 30 + time_in_minutes = 15 webhook_url = "https://www.bing.com/2/4" - status = "Enabled" + enabled = true } tags = { - environment = "Production" + Environment = "Production" } } diff --git a/website/docs/r/dev_test_global_shutdown_schedule.html.markdown b/website/docs/r/dev_test_global_shutdown_schedule.html.markdown index 0524125e2743..f4b21ca5a164 100644 --- a/website/docs/r/dev_test_global_shutdown_schedule.html.markdown +++ b/website/docs/r/dev_test_global_shutdown_schedule.html.markdown @@ -6,7 +6,7 @@ description: |- Manages automated shutdown schedules for Azure Resource Manager VMs outside of Dev Test Labs. --- -# azurerm_dev_test_schedule +# azurerm_dev_test_global_shutdown_schedule Manages automated shutdown schedules for Azure Resource Manager VMs outside of Dev Test Labs. @@ -44,36 +44,29 @@ resource "azurerm_network_interface" "sample" { } } -resource "azurerm_virtual_machine" "sample" { +resource "azurerm_linux_virtual_machine" "sample" { name = "SampleVM" location = "${azurerm_resource_group.sample.location}" resource_group_name = "${azurerm_resource_group.sample.name}" network_interface_ids = ["${azurerm_network_interface.sample.id}"] - vm_size = "Standard_B2s" + size = "Standard_B2s" - storage_image_reference { + source_image_reference { publisher = "Canonical" offer = "UbuntuServer" - sku = "18.04-LTS" + sku = "16.04-LTS" version = "latest" } - storage_os_disk { + os_disk { name = "myosdisk-%d" caching = "ReadWrite" - create_option = "FromImage" managed_disk_type = "Standard_LRS" } - os_profile { - computer_name = "hostname" - admin_username = "testadmin" - admin_password = "Password1234!" - } - - os_profile_linux_config { - disable_password_authentication = false - } + admin_username = "testadmin" + admin_password = "Password1234!" + disable_password_authentication = false } resource "azurerm_dev_test_global_shutdown_schedule" "sample" { @@ -101,29 +94,25 @@ The following arguments are supported: * `location` - (Required) The location where the schedule is created. Changing this forces a new resource to be created. -* `target_resource_id` - (Required) The resource ID of the target ARM-based Virtual Machine. Changing this forces a new resource to be created. +* `virtual_machine_id` - (Required) The resource ID of the target ARM-based Virtual Machine. Changing this forces a new resource to be created. -* `status` - (Optional) The status of this schedule. Possible values are `Enabled` and `Disabled`. Defaults to `Enabled`. +* `enabled` - (Optional) Whether to enable the schedule. Possible values are `true` and `false`. Defaults to `true`. -* `time_zone_id` - (Required) The time zone ID (e.g. Pacific Standard time). Refer to this guide for a [full list of accepted time zone names](https://jackstromberg.com/2017/01/list-of-time-zones-consumed-by-azure/). +* `timezone` - (Required) The time zone ID (e.g. Pacific Standard time). Refer to this guide for a [full list of accepted time zone names](https://jackstromberg.com/2017/01/list-of-time-zones-consumed-by-azure/). * `tags` - (Optional) A mapping of tags to assign to the resource. ---- - -A `daily_recurrence` - (Required) - block supports the following: - -* `time` - (Required) The time each day when the schedule takes effect. Must match the format HHmm where HH is 00-23 and mm is 00-59 (e.g. 0930, 2300, etc.) +* `daily_recurrence_time` - (Required) The time each day when the schedule takes effect. Must match the format HHmm where HH is 00-23 and mm is 00-59 (e.g. 0930, 2300, etc.) --- A `notification_settings` - (Required) - block supports the following: -* `status` - (Optional) The status of the notification. Possible values are `Enabled` and `Disabled`. Defaults to `Disabled` +* `enabled` - (Optional) Whether to enable pre-shutdown notifications. Possible values are `true` and `false`. Defaults to `false` -* `time_in_minutes` - Time in minutes between 15 and 120 before a shutdown event at which a notification will be sent. Required if `status` is `Enabled`. Optional otherwise. +* `time_in_minutes` - (Optional) Time in minutes between 15 and 120 before a shutdown event at which a notification will be sent. Defaults to `30`. -* `webhook_url` - The webhook URL to which the notification will be sent. Required if `status` is `Enabled`. Optional otherwise. +* `webhook_url` - The webhook URL to which the notification will be sent. Required if `enabled` is `true`. Optional otherwise. ## Attributes Reference @@ -136,5 +125,5 @@ The following additional attributes are exported: An existing Dev Test Global Shutdown Schedule can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_dev_test_global_shutdown_schedule.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sample-rg/providers/Microsoft.DevTestLab/schedules/compute-vm-SampleVM +terraform import azurerm_dev_test_global_shutdown_schedule.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sample-rg/providers/Microsoft.DevTestLab/schedules/shutdown-computevm-SampleVM ```