Manages a Front Door (standard/premium) Route.
resource "azurerm_resource_group" "example" {
name = "example-cdn-frontdoor"
location = "West Europe"
}
resource "azurerm_dns_zone" "example" {
name = "example.com"
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_cdn_frontdoor_profile" "example" {
name = "example-profile"
resource_group_name = azurerm_resource_group.example.name
sku_name = "Standard_AzureFrontDoor"
}
resource "azurerm_cdn_frontdoor_origin_group" "example" {
name = "example-originGroup"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
load_balancing {
additional_latency_in_milliseconds = 0
sample_size = 16
successful_samples_required = 3
}
}
resource "azurerm_cdn_frontdoor_origin" "example" {
name = "example-origin"
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
enabled = true
certificate_name_check_enabled = false
host_name = "contoso.com"
http_port = 80
https_port = 443
origin_host_header = "www.contoso.com"
priority = 1
weight = 1
}
resource "azurerm_cdn_frontdoor_endpoint" "example" {
name = "example-endpoint"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
}
resource "azurerm_cdn_frontdoor_rule_set" "example" {
name = "ExampleRuleSet"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
}
resource "azurerm_cdn_frontdoor_custom_domain" "contoso" {
name = "contoso-custom-domain"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
dns_zone_id = azurerm_dns_zone.example.id
host_name = join(".", ["contoso", azurerm_dns_zone.example.name])
tls {
certificate_type = "ManagedCertificate"
minimum_tls_version = "TLS12"
}
}
resource "azurerm_cdn_frontdoor_custom_domain" "fabrikam" {
name = "fabrikam-custom-domain"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
dns_zone_id = azurerm_dns_zone.example.id
host_name = join(".", ["fabrikam", azurerm_dns_zone.example.name])
tls {
certificate_type = "ManagedCertificate"
minimum_tls_version = "TLS12"
}
}
resource "azurerm_cdn_frontdoor_route" "example" {
name = "example-route"
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.example.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.example.id]
cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.example.id]
enabled = true
forwarding_protocol = "HttpsOnly"
https_redirect_enabled = true
patterns_to_match = ["/*"]
supported_protocols = ["Http", "Https"]
cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id, azurerm_cdn_frontdoor_custom_domain.fabrikam.id]
link_to_default_domain = false
cache {
query_string_caching_behavior = "IgnoreSpecifiedQueryStrings"
query_strings = ["account", "settings"]
compression_enabled = true
content_types_to_compress = ["text/html", "text/javascript", "text/xml"]
}
}
resource "azurerm_cdn_frontdoor_custom_domain_association" "contoso" {
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.contoso.id
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
}
resource "azurerm_cdn_frontdoor_custom_domain_association" "fabrikam" {
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.fabrikam.id
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
}
The following arguments are supported:
name
- (Required) The name which should be used for this Front Door Route. Valid values must begin with a letter or number, end with a letter or number and may only contain letters, numbers and hyphens with a maximum length of 90 characters. Changing this forces a new Front Door Route to be created.
cdn_frontdoor_endpoint_id
- (Required) The resource ID of the Front Door Endpoint where this Front Door Route should exist. Changing this forces a new Front Door Route to be created.
cdn_frontdoor_origin_group_id
- (Required) The resource ID of the Front Door Origin Group where this Front Door Route should be created.
cdn_frontdoor_origin_ids
- (Required) One or more Front Door Origin resource IDs that this Front Door Route will link to.
forwarding_protocol
- (Optional) The Protocol that will be use when forwarding traffic to backends. Possible values are HttpOnly
, HttpsOnly
or MatchRequest
. Defaults to MatchRequest
.
patterns_to_match
- (Required) The route patterns of the rule.
supported_protocols
- (Required) One or more Protocols supported by this Front Door Route. Possible values are Http
or Https
.
cache
- (Optional) A cache
block as defined below.cdn_frontdoor_custom_domain_ids
- (Optional) The IDs of the Front Door Custom Domains which are associated with this Front Door Route.
cdn_frontdoor_origin_path
- (Optional) A directory path on the Front Door Origin that can be used to retrieve content (e.g. contoso.cloudapp.net/originpath
).
cdn_frontdoor_rule_set_ids
- (Optional) A list of the Front Door Rule Set IDs which should be assigned to this Front Door Route.
enabled
- (Optional) Is this Front Door Route enabled? Possible values are true
or false
. Defaults to true
.
https_redirect_enabled
- (Optional) Automatically redirect HTTP traffic to HTTPS traffic? Possible values are true
or false
. Defaults to true
.
link_to_default_domain
- (Optional) Should this Front Door Route be linked to the default endpoint? Possible values include true
or false
. Defaults to true
.A cache
block supports the following:
query_string_caching_behavior
- (Optional) Defines how the Front Door Route will cache requests that include query strings. Possible values include IgnoreQueryString
, IgnoreSpecifiedQueryStrings
, IncludeSpecifiedQueryStrings
or UseQueryString
. Defaults to IgnoreQueryString
.query_strings
- (Optional) Query strings to include or ignore.
compression_enabled
- (Optional) Is content compression enabled? Possible values are true
or false
. Defaults to false
.
content_types_to_compress
- (Optional) A list of one or more Content types
(formerly known as MIME types
) to compress. Possible values include application/eot
, application/font
, application/font-sfnt
, application/javascript
, application/json
, application/opentype
, application/otf
, application/pkcs7-mime
, application/truetype
, application/ttf
, application/vnd.ms-fontobject
, application/xhtml+xml
, application/xml
, application/xml+rss
, application/x-font-opentype
, application/x-font-truetype
, application/x-font-ttf
, application/x-httpd-cgi
, application/x-mpegurl
, application/x-opentype
, application/x-otf
, application/x-perl
, application/x-ttf
, application/x-javascript
, font/eot
, font/ttf
, font/otf
, font/opentype
, image/svg+xml
, text/css
, text/csv
, text/html
, text/javascript
, text/js
, text/plain
, text/richtext
, text/tab-separated-values
, text/xml
, text/x-script
, text/x-component
or text/x-java-source
.In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the Front Door Route.The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the Front Door Route.read
- (Defaults to 5 minutes) Used when retrieving the Front Door Route.update
- (Defaults to 30 minutes) Used when updating the Front Door Route.delete
- (Defaults to 30 minutes) Used when deleting the Front Door Route.Front Door Routes can be imported using the resource id
, e.g.
terraform import azurerm_cdn_frontdoor_route.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Cdn/profiles/profile1/afdEndpoints/endpoint1/routes/route1