Reputation: 791
how can i add a redirect rule for the azurerm_application_gateway? Over the azure portal there is a checkbox "redirect configure", but i didn't find an terraform element therefore.
Upvotes: 1
Views: 3419
Reputation: 55
So this is now possible from terraform you can use the redirect_configuration block here are the docs: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_gateway#redirect_configuration
Here is a list of things you will need to add azurerm_application_gateway resource:
Note: If you do not set host_name on the http_listener you will have to create multiple frontend_port blocks.
It will look something like this:
resource "azurerm_application_gateway" "example" {
...
# Https Port
frontend_port {
name = "port-https"
port = 443
}
# Http Port
frontend_port {
name = "port-http"
port = 80
}
# Https Listener
http_listener {
name = "https-listener"
frontend_ip_configuration_name = "<frontend_ip_configuration_name>"
frontend_port_name = "port-https"
host_name = "<host_name>"
protocol = "Https"
require_sni = true
ssl_certificate_name = "<ssl_certificate_name>"
}
# Http Listener
http_listener {
name = "http-listener"
frontend_ip_configuration_name = "<frontend_ip_configuration_name>"
frontend_port_name = "port-http"
host_name = "<host_name>"
protocol = "Http"
}
# Request routing rule for Https
request_routing_rule {
name = "routing-https"
http_listener_name = "https-listener"
backend_address_pool_name = "<backend_address_pool_name>"
backend_http_settings_name = "<backend_http_settings_name>"
rule_type = "Basic"
}
# Request routing rule for Http
request_routing_rule {
name = "routing-http"
http_listener_name = "http-listener"
redirect_configuration_name = "redirect-config-https"
rule_type = "Basic"
}
# Request Configuration for Https
redirect_configuration {
name = "redirect-config-https"
target_listener_name = "https-listener"
redirect_type = "Permanent"
include_path = true
include_query_string = true
}
...
}
Upvotes: 2
Reputation: 72191
according to this template there should be a redirect rule property which is missing in terraform. so my guess is - you cant.
thanks to a link posted in the comments here's an issue you should track: https://github.com/terraform-providers/terraform-provider-azurerm/issues/1576
Upvotes: 0