Skip to content

azurermCdnFrontdoorRoute

Manages a Front Door (standard/premium) Route.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-cdn-frontdoor",
  }
);
const azurermCdnFrontdoorProfileExample =
  new azurerm.cdnFrontdoorProfile.CdnFrontdoorProfile(this, "example_1", {
    name: "example-profile",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnFrontdoorProfileExample.overrideLogicalId("example");
const azurermDnsZoneExample = new azurerm.dnsZone.DnsZone(this, "example_2", {
  name: "example.com",
  resource_group_name: azurermResourceGroupExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermDnsZoneExample.overrideLogicalId("example");
const azurermFrontdoorEndpointExample =
  new azurerm.frontdoorEndpoint.FrontdoorEndpoint(this, "example_3", {
    cdn_frontdoor_profile_id: azurermCdnFrontdoorProfileExample.id,
    name: "example-endpoint",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermFrontdoorEndpointExample.overrideLogicalId("example");
const azurermCdnFrontdoorCustomDomainContoso =
  new azurerm.cdnFrontdoorCustomDomain.CdnFrontdoorCustomDomain(
    this,
    "contoso",
    {
      cdn_frontdoor_profile_id: azurermCdnFrontdoorProfileExample.id,
      dns_zone_id: azurermDnsZoneExample.id,
      host_name: `\${join(".", ["contoso", ${azurermDnsZoneExample.name}])}`,
      name: "contoso-custom-domain",
      tls: [
        {
          certificate_type: "ManagedCertificate",
          minimum_tls_version: "TLS12",
        },
      ],
    }
  );
const azurermCdnFrontdoorCustomDomainFabrikam =
  new azurerm.cdnFrontdoorCustomDomain.CdnFrontdoorCustomDomain(
    this,
    "fabrikam",
    {
      cdn_frontdoor_profile_id: azurermCdnFrontdoorProfileExample.id,
      dns_zone_id: azurermDnsZoneExample.id,
      host_name: `\${join(".", ["fabrikam", ${azurermDnsZoneExample.name}])}`,
      name: "fabrikam-custom-domain",
      tls: [
        {
          certificate_type: "ManagedCertificate",
          minimum_tls_version: "TLS12",
        },
      ],
    }
  );
const azurermCdnFrontdoorOriginGroupExample =
  new azurerm.cdnFrontdoorOriginGroup.CdnFrontdoorOriginGroup(
    this,
    "example_6",
    {
      cdn_frontdoor_profile_id: azurermCdnFrontdoorProfileExample.id,
      name: "example-originGroup",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnFrontdoorOriginGroupExample.overrideLogicalId("example");
const azurermCdnFrontdoorOriginExample =
  new azurerm.cdnFrontdoorOrigin.CdnFrontdoorOrigin(this, "example_7", {
    cdn_frontdoor_origin_group_id: azurermCdnFrontdoorOriginGroupExample.id,
    certificate_name_check_enabled: false,
    enabled: true,
    host_name: "contoso.com",
    http_port: 80,
    https_port: 443,
    name: "example-origin",
    origin_host_header: "www.contoso.com",
    priority: 1,
    weight: 1,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnFrontdoorOriginExample.overrideLogicalId("example");
const azurermCdnFrontdoorRouteExample =
  new azurerm.cdnFrontdoorRoute.CdnFrontdoorRoute(this, "example_8", {
    cache: [
      {
        compression_enabled: true,
        content_types_to_compress: ["text/html", "text/javascript", "text/xml"],
        query_string_caching_behavior: "IgnoreSpecifiedQueryStrings",
        query_strings: ["account", "settings"],
      },
    ],
    cdn_frontdoor_custom_domain_ids: [
      azurermCdnFrontdoorCustomDomainContoso.id,
      azurermCdnFrontdoorCustomDomainFabrikam.id,
    ],
    cdn_frontdoor_endpoint_id: "${azurerm_cdn_frontdoor_endpoint.example.id}",
    cdn_frontdoor_origin_group_id: azurermCdnFrontdoorOriginGroupExample.id,
    cdn_frontdoor_origin_ids: [azurermCdnFrontdoorOriginExample.id],
    cdn_frontdoor_rule_set_ids: [
      "${azurerm_cdn_frontdoor_rule_set.example.id}",
    ],
    enabled: true,
    forwarding_protocol: "HttpsOnly",
    https_redirect_enabled: true,
    link_to_default_domain: false,
    name: "example-route",
    patterns_to_match: ["/*"],
    supported_protocols: ["Http", "Https"],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnFrontdoorRouteExample.overrideLogicalId("example");
const azurermCdnFrontdoorCustomDomainAssociationContoso =
  new azurerm.cdnFrontdoorCustomDomainAssociation.CdnFrontdoorCustomDomainAssociation(
    this,
    "contoso_9",
    {
      cdn_frontdoor_custom_domain_id: azurermCdnFrontdoorCustomDomainContoso.id,
      cdn_frontdoor_route_ids: [azurermCdnFrontdoorRouteExample.id],
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnFrontdoorCustomDomainAssociationContoso.overrideLogicalId("contoso");
const azurermCdnFrontdoorCustomDomainAssociationFabrikam =
  new azurerm.cdnFrontdoorCustomDomainAssociation.CdnFrontdoorCustomDomainAssociation(
    this,
    "fabrikam_10",
    {
      cdn_frontdoor_custom_domain_id:
        azurermCdnFrontdoorCustomDomainFabrikam.id,
      cdn_frontdoor_route_ids: [azurermCdnFrontdoorRouteExample.id],
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnFrontdoorCustomDomainAssociationFabrikam.overrideLogicalId(
  "fabrikam"
);

Arguments Reference

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.

  • cdnFrontdoorEndpointId - (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.

  • cdnFrontdoorOriginGroupId - (Required) The resource ID of the Front Door Origin Group where this Front Door Route should be created.

  • cdnFrontdoorOriginIds - (Required) One or more Front Door Origin resource IDs that this Front Door Route will link to.

  • forwardingProtocol - (Optional) The Protocol that will be use when forwarding traffic to backends. Possible values are httpOnly, httpsOnly or matchRequest.

  • patternsToMatch - (Required) The route patterns of the rule.

  • supportedProtocols - (Required) One or more Protocols supported by this Front Door Route. Possible values are http or https.

\~> NOTE: If httpsRedirectEnabled is set to true the supportedProtocols field must contain both http and https values.

  • cache - (Optional) A cache block as defined below.

\~> NOTE: To disable caching, do not provide the cache block in the configuration file.

  • cdnFrontdoorCustomDomainIds - (Optional) The IDs of the Front Door Custom Domains which are associated with this Front Door Route.

  • cdnFrontdoorOriginPath - (Optional) A directory path on the Front Door Origin that can be used to retrieve content (e.g. contosoCloudappNet/originpath).

  • cdnFrontdoorRuleSetIds - (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.

  • httpsRedirectEnabled - (Optional) Automatically redirect HTTP traffic to HTTPS traffic? Possible values are true or false. Defaults to true.

\~> NOTE: The httpsRedirectEnabled rule is the first rule that will be executed.

  • linkToDefaultDomain - (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:

  • queryStringCachingBehavior - (Optional) Defines how the Front Door Route will cache requests that include query strings. Possible values include ignoreQueryString, ignoreSpecifiedQueryStrings, includeSpecifiedQueryStrings or useQueryString. Defaults it ignoreQueryString.

\~> NOTE: The value of the queryStringCachingBehavior determines if the queryStrings field will be used as an include list or an ignore list.

  • queryStrings - (Optional) Query strings to include or ignore.

  • compressionEnabled - (Optional) Is content compression enabled? Possible values are true or false. Defaults to false.

\~> NOTE: Content won't be compressed when the requested content is smaller than 1Kb or larger than 8Mb(inclusive).

  • contentTypesToCompress - (Optional) A list of one or more contentTypes (formerly known as mimeTypes) to compress. Possible values include application/eot, application/font, application/fontSfnt, application/javascript, application/json, application/opentype, application/otf, application/pkcs7Mime, application/truetype, application/ttf, application/vndMsFontobject, application/xhtml+xml, application/xml, application/xml+rss, application/xFontOpentype, application/xFontTruetype, application/xFontTtf, application/xHttpdCgi, application/xMpegurl, application/xOpentype, application/xOtf, application/xPerl, application/xTtf, application/xJavascript, 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/tabSeparatedValues, text/xml, text/xScript, text/xComponent or text/xJavaSource.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Front Door Route.

Timeouts

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.

Import

Front Door Routes can be imported using the resourceId, 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