From ab1e60bc8be6a099a3943e3a3863b36b7eb3aa41 Mon Sep 17 00:00:00 2001 From: Andrea Macaro Date: Sun, 29 Sep 2024 23:43:54 +0200 Subject: [PATCH 1/2] support more status_code on custom_error_configuration --- .../network/application_gateway_resource.go | 10 +-- .../application_gateway_resource_test.go | 70 +++++++++++++++++++ .../docs/r/application_gateway.html.markdown | 2 +- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/internal/services/network/application_gateway_resource.go b/internal/services/network/application_gateway_resource.go index 2f31b168469a..72613945d51f 100644 --- a/internal/services/network/application_gateway_resource.go +++ b/internal/services/network/application_gateway_resource.go @@ -514,10 +514,7 @@ func resourceApplicationGateway() *pluginsdk.Resource { "status_code": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(applicationgateways.ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree), - string(applicationgateways.ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo), - }, false), + ValidateFunc: validation.StringInSlice(applicationgateways.PossibleValuesForApplicationGatewayCustomErrorStatusCode(), false), }, "custom_error_page_url": { @@ -1519,10 +1516,7 @@ func resourceApplicationGateway() *pluginsdk.Resource { "status_code": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(applicationgateways.ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree), - string(applicationgateways.ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo), - }, false), + ValidateFunc: validation.StringInSlice(applicationgateways.PossibleValuesForApplicationGatewayCustomErrorStatusCode(), false), }, "custom_error_page_url": { diff --git a/internal/services/network/application_gateway_resource_test.go b/internal/services/network/application_gateway_resource_test.go index 0ee0de00fb24..5533f5a6a585 100644 --- a/internal/services/network/application_gateway_resource_test.go +++ b/internal/services/network/application_gateway_resource_test.go @@ -6305,10 +6305,45 @@ resource "azurerm_application_gateway" "test" { custom_error_page_url = "http://azure.com/error403_listener.html" } + custom_error_configuration { + status_code = "HttpStatus404" + custom_error_page_url = "http://azure.com/error404_listener.html" + } + + custom_error_configuration { + status_code = "HttpStatus405" + custom_error_page_url = "http://azure.com/error405_listener.html" + } + + custom_error_configuration { + status_code = "HttpStatus408" + custom_error_page_url = "http://azure.com/error408_listener.html" + } + + custom_error_configuration { + status_code = "HttpStatus400" + custom_error_page_url = "http://azure.com/error400_listener.html" + } + custom_error_configuration { status_code = "HttpStatus502" custom_error_page_url = "http://azure.com/error502_listener.html" } + + custom_error_configuration { + status_code = "HttpStatus503" + custom_error_page_url = "http://azure.com/error503_listener.html" + } + + custom_error_configuration { + status_code = "HttpStatus504" + custom_error_page_url = "http://azure.com/error504_listener.html" + } + + custom_error_configuration { + status_code = "HttpStatus500" + custom_error_page_url = "http://azure.com/error500_listener.html" + } } custom_error_configuration { @@ -6316,11 +6351,46 @@ resource "azurerm_application_gateway" "test" { custom_error_page_url = "http://azure.com/error.html" } + custom_error_configuration { + status_code = "HttpStatus404" + custom_error_page_url = "http://azure.com/error.html" + } + + custom_error_configuration { + status_code = "HttpStatus405" + custom_error_page_url = "http://azure.com/error.html" + } + + custom_error_configuration { + status_code = "HttpStatus408" + custom_error_page_url = "http://azure.com/error.html" + } + + custom_error_configuration { + status_code = "HttpStatus400" + custom_error_page_url = "http://azure.com/error.html" + } + custom_error_configuration { status_code = "HttpStatus502" custom_error_page_url = "http://azure.com/error.html" } + custom_error_configuration { + status_code = "HttpStatus503" + custom_error_page_url = "http://azure.com/error.html" + } + + custom_error_configuration { + status_code = "HttpStatus504" + custom_error_page_url = "http://azure.com/error.html" + } + + custom_error_configuration { + status_code = "HttpStatus500" + custom_error_page_url = "http://azure.com/error.html" + } + request_routing_rule { name = local.request_routing_rule_name rule_type = "Basic" diff --git a/website/docs/r/application_gateway.html.markdown b/website/docs/r/application_gateway.html.markdown index 4a28c064cb07..922347a0b228 100644 --- a/website/docs/r/application_gateway.html.markdown +++ b/website/docs/r/application_gateway.html.markdown @@ -579,7 +579,7 @@ A `exclusion` block supports the following: A `custom_error_configuration` block supports the following: -* `status_code` - (Required) Status code of the application gateway customer error. Possible values are `HttpStatus403` and `HttpStatus502` +* `status_code` - (Required) Status code of the application gateway customer error. Possible values are `HttpStatus400`, `HttpStatus403`, `HttpStatus404`, `HttpStatus405`, `HttpStatus408`, `HttpStatus500`, `HttpStatus502`, `HttpStatus503` and `HttpStatus504` * `custom_error_page_url` - (Required) Error page URL of the application gateway customer error. From 2ad24d5e7b05fb43dd10db0d247487f67e65c94c Mon Sep 17 00:00:00 2001 From: Andrea Macaro Date: Thu, 17 Oct 2024 09:17:46 +0200 Subject: [PATCH 2/2] fix ci with gofmt --- internal/services/network/application_gateway_resource.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/network/application_gateway_resource.go b/internal/services/network/application_gateway_resource.go index 72613945d51f..6f5b3c456dca 100644 --- a/internal/services/network/application_gateway_resource.go +++ b/internal/services/network/application_gateway_resource.go @@ -512,8 +512,8 @@ func resourceApplicationGateway() *pluginsdk.Resource { Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "status_code": { - Type: pluginsdk.TypeString, - Required: true, + Type: pluginsdk.TypeString, + Required: true, ValidateFunc: validation.StringInSlice(applicationgateways.PossibleValuesForApplicationGatewayCustomErrorStatusCode(), false), }, @@ -1514,8 +1514,8 @@ func resourceApplicationGateway() *pluginsdk.Resource { Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "status_code": { - Type: pluginsdk.TypeString, - Required: true, + Type: pluginsdk.TypeString, + Required: true, ValidateFunc: validation.StringInSlice(applicationgateways.PossibleValuesForApplicationGatewayCustomErrorStatusCode(), false), },