terraformazure-web-app-serviceterraform-provider-azurehashicorp

Terraform does not have endtime attribute for monitor_autoscale_setting resource


I am trying to create a auto scale configuration for App Service Plan on weekends (Repeat specific days)

As per the Azure portal, it shows the option for endtime where as in Terraform code there is no attribute for it to specify

Terraform code snippet

 profile {
    name = "Weekends"

    capacity {
      default = 1
      minimum = 1
      maximum = 1
    }

    recurrence {
      timezone = "Pacific Standard Time"
      days     = ["Saturday", "Sunday"]
      hours    = [0]
      minutes = [ 0 ]
    }

Azure Portal

enter image description here

Terraform document - https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting.html#example-usage-for-fixed-dates

enter image description here

Is there a way to add the endtime using terraform ?


Solution

  • This is not a supported feature of the API.

    The detailed explanation is in this github issue: https://github.com/hashicorp/terraform-provider-azurerm/issues/5810

    Per a couple of the comments above, this appears to be the Azure API behaviour requiring two distinct profiles here, one at the start and one at the end. Whilst the Azure Portal may have a single screen for this, it's pretty common for the Azure Portal to represent things differently to the API, including highlighting things as two-way relationships when they're one-way relationships in the API (and having the Portal call out to multiple APIs as required) - which whilst makes sense in the Portal (since this is a one-time change) isn't necessarily something we can map in Terraform.

    As such in this example I believe the API's requiring that two autoscaling settings are created here, one to start and one to stop the event (which is already supported, as outlined above) - and so I'm going to close this issue for the moment.