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.6k stars 4.65k forks source link

Support for more custom error page status code for application gateway #23280

Closed jazzywessy closed 1 day ago

jazzywessy commented 1 year ago

Is there an existing issue for this?

Community Note

Description

Currently, azurerm_application_gateway http_listener custom_error_configurations status_code only allow 403 and 502.

However, on azure portal other status code is allowed which will defer from terraform state and cannot be track if it is manually added on azure portal.

New or Affected Resource(s)/Data Source(s)

azurerm_application_gateway

Potential Terraform Configuration

resource "azurerm_application_gateway" "network" {
  name                = "example-appgateway"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  sku {
    name     = "Standard_Small"
    tier     = "Standard"
    capacity = 2
  }

  gateway_ip_configuration {
    name      = "my-gateway-ip-configuration"
    subnet_id = azurerm_subnet.frontend.id
  }

  frontend_port {
    name = local.frontend_port_name
    port = 80
  }

  frontend_ip_configuration {
    name                 = local.frontend_ip_configuration_name
    public_ip_address_id = azurerm_public_ip.example.id
  }

  backend_address_pool {
    name = local.backend_address_pool_name
  }

  backend_http_settings {
    name                  = local.http_setting_name
    cookie_based_affinity = "Disabled"
    path                  = "/path1/"
    port                  = 80
    protocol              = "Http"
    request_timeout       = 60
  }

  http_listener {
    name                           = local.listener_name
    frontend_ip_configuration_name = local.frontend_ip_configuration_name
    frontend_port_name             = local.frontend_port_name
    protocol                       = "Http"
    custom_error_configuration {
      status_code = “400”
      custom_error_page_url = “www.example.net/400.html”
    }
  }

  request_routing_rule {
    name                       = local.request_routing_rule_name
    rule_type                  = "Basic"
    http_listener_name         = local.listener_name
    backend_address_pool_name  = local.backend_address_pool_name
    backend_http_settings_name = local.http_setting_name
  }
}

References

No response

rcskosir commented 1 year ago

@jazzywessy Thank you for taking the time to open this feature request!

psallis commented 1 year ago

Support for the full list of status_codes at both Global and Listener level https://learn.microsoft.com/en-us/azure/application-gateway/custom-error

Adding an un-supported error page via CLI causes a terraform Apply error below,

Failure sending request: StatusCode=400 -- Original Error: Code="ApplicationGatewayCustomErrorStatusCodeIsInvalid" Message="Custom error page has an invalid HTTP status code '500', for applicationGateways /subscriptions/[removed[/resourceGroups/[removed[/providers/Microsoft.Network/applicationGateways/[removed[. Valid status codes are: '[403, 502]'." Details=[]

StefanSchoof commented 11 months ago

The app gateway is using the network 2022-07-01

https://github.com/hashicorp/terraform-provider-azurerm/blob/63db3094d82eed86dc1d76a1dddb5b8b1f571510/internal/services/network/application_gateway_resource.go#L34

and this version has not the new options

https://github.com/tombuildsstuff/kermit/blob/f6cc716272f05bf668d07b537fa3bd6fb6fdf6ef/sdk/network/2022-07-01/network/enums.go#L115-L1119

they come with the network 2022-11-01

https://github.com/tombuildsstuff/kermit/blob/f6cc716272f05bf668d07b537fa3bd6fb6fdf6ef/sdk/network/2022-11-01/network/enums.go#L115-L136

And that takes me the hope, we will get this feature fast :(

kristeey commented 9 months ago

Any updates on this?

StefanSchoof commented 7 months ago

I just noticed, that setting the error pages via powershell, will result into a error (Custom error pages has invalid HTTP status code '500' for . Valid status codes are '[403, 502]') in the next apply.

carnei-ro commented 3 months ago

yeah, I tried to upgrade the API Version and still got the same error 🫠

for those who want to try:

terraform  state replace-provider hashicorp/azurerm registry.terraform.io/carnei-ro/azurerm
terraform plan
tgermain-impirica commented 2 months ago

any update on this? I just received the same error