Skip to content

azurermCdnEndpoint

A CDN Endpoint is the entity within a CDN Profile containing configuration information regarding caching behaviours and origins. The CDN Endpoint is exposed using the URL format <endpointname>AzureedgeNet.

!> Be Aware: Azure is rolling out a breaking change on Friday 9th April 2021 which may cause issues with the CDN/FrontDoor resources. More information is available in this GitHub issue - however unfortunately this may necessitate a breaking change to the CDN and FrontDoor resources, more information will be posted in the GitHub issue as the necessary changes are identified.

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-resources",
  }
);
const azurermCdnProfileExample = new azurerm.cdnProfile.CdnProfile(
  this,
  "example_1",
  {
    location: azurermResourceGroupExample.location,
    name: "example-cdn",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard_Verizon",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCdnProfileExample.overrideLogicalId("example");
const azurermCdnEndpointExample = new azurerm.cdnEndpoint.CdnEndpoint(
  this,
  "example_2",
  {
    location: azurermResourceGroupExample.location,
    name: "example",
    origin: [
      {
        host_name: "www.contoso.com",
        name: "example",
      },
    ],
    profile_name: azurermCdnProfileExample.name,
    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.*/
azurermCdnEndpointExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the CDN Endpoint. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the CDN Endpoint. Changing this forces a new resource to be created.

  • profileName - (Required) The CDN Profile to which to attach the CDN Endpoint. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

  • isHttpAllowed - (Optional) Defaults to true.

  • isHttpsAllowed - (Optional) Defaults to true.

  • contentTypesToCompress - (Optional) An array of strings that indicates a content types on which compression will be applied. The value for the elements should be MIME types.

  • geoFilter - (Optional) A set of Geo Filters for this CDN Endpoint. Each geoFilter block supports fields documented below.

  • isCompressionEnabled - (Optional) Indicates whether compression is to be enabled.

  • querystringCachingBehaviour - (Optional) Sets query string caching behavior. Allowed values are ignoreQueryString, bypassCaching and useQueryString. notSet value can be used for premiumVerizon CDN profile. Defaults to ignoreQueryString.

  • optimizationType - (Optional) What types of optimization should this CDN Endpoint optimize for? Possible values include dynamicSiteAcceleration, generalMediaStreaming, generalWebDelivery, largeFileDownload and videoOnDemandMediaStreaming.

  • origin - (Required) The set of origins of the CDN endpoint. When multiple origins exist, the first origin will be used as primary and rest will be used as failover options. Each origin block supports fields documented below. Changing this forces a new resource to be created.

  • originHostHeader - (Optional) The host header CDN provider will send along with content requests to origins.

  • originPath - (Optional) The path used at for origin requests.

  • probePath - (Optional) the path to a file hosted on the origin which helps accelerate delivery of the dynamic content and calculate the most optimal routes for the CDN. This is relative to the originPath.

-> NOTE: globalDeliveryRule and deliveryRule are currently only available for microsoftStandard CDN profiles.

  • globalDeliveryRule - (Optional) Actions that are valid for all resources regardless of any conditions. A globalDeliveryRule block as defined below.

  • deliveryRule - (Optional) Rules for the rules engine. An endpoint can contain up until 4 of those rules that consist of conditions and actions. A deliveryRule blocks as defined below.

  • tags - (Optional) A mapping of tags to assign to the resource.


The origin block supports:

  • name - (Required) The name of the origin. This is an arbitrary value. However, this value needs to be unique under the endpoint. Changing this forces a new resource to be created.

  • hostName - (Required) A string that determines the hostname/IP address of the origin server. This string can be a domain name, Storage Account endpoint, Web App endpoint, IPv4 address or IPv6 address. Changing this forces a new resource to be created.

  • httpPort - (Optional) The HTTP port of the origin. Defaults to 80. Changing this forces a new resource to be created.

  • httpsPort - (Optional) The HTTPS port of the origin. Defaults to 443. Changing this forces a new resource to be created.


The geoFilter block supports:

  • relativePath - (Required) The relative path applicable to geo filter.

  • action - (Required) The Action of the Geo Filter. Possible values include allow and block.

  • countryCodes - (Required) A List of two letter country codes (e.g. us, gb) to be associated with this Geo Filter.


A globalDeliveryRule block supports the following:

  • cacheExpirationAction - (Optional) A cacheExpirationAction block as defined above.

  • cacheKeyQueryStringAction - (Optional) A cacheKeyQueryStringAction block as defined above.

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

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

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

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


A deliveryRule block supports the following:

  • name - (Required) The Name which should be used for this Delivery Rule.

  • order - (Required) The order used for this rule. The order values should be sequential and begin at 1.

  • cacheExpirationAction - (Optional) A cacheExpirationAction block as defined above.

  • cacheKeyQueryStringAction - (Optional) A cacheKeyQueryStringAction block as defined above.

  • cookiesCondition - (Optional) A cookiesCondition block as defined above.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


A cacheExpirationAction block supports the following:

  • behavior - (Required) The behavior of the cache. Valid values are bypassCache, override and setIfMissing.

  • duration - (Optional) Duration of the cache. Only allowed when behavior is set to override or setIfMissing. Format: [d.]hh:mm:ss


A cacheKeyQueryStringAction block supports the following:

  • behavior - (Required) The behavior of the cache key for query strings. Valid values are exclude, excludeAll, include and includeAll.

  • parameters - (Optional) Comma separated list of parameter values.


A modifyRequestHeaderAction block supports the following:

  • action - (Required) Action to be executed on a header value. Valid values are append, delete and overwrite.

  • name - (Required) The header name.

  • value - (Optional) The value of the header. Only needed when action is set to append or overwrite.


A modifyResponseHeaderAction block supports the following:

  • action - (Required) Action to be executed on a header value. Valid values are append, delete and overwrite.

  • name - (Required) The header name.

  • value - (Optional) The value of the header. Only needed when action is set to append or overwrite.


A urlRedirectAction block supports the following:

  • redirectType - (Required) Type of the redirect. Valid values are found, moved, permanentRedirect and temporaryRedirect.

  • protocol - (Optional) Specifies the protocol part of the URL. Valid values are matchRequest, http and https.

  • hostname - (Optional) Specifies the hostname part of the URL.

  • path - (Optional) Specifies the path part of the URL. This value must begin with a /.

  • fragment - (Optional) Specifies the fragment part of the URL. This value must not start with a #.

  • queryString - (Optional) Specifies the query string part of the URL. This value must not start with a ? or & and must be in <key>=<value> format separated by &.


A urlRewriteAction block supports the following:

  • sourcePattern - (Required) This value must start with a / and can't be longer than 260 characters.

  • destination - (Required) This value must start with a / and can't be longer than 260 characters.

  • preserveUnmatchedPath - (Optional) Defaults to true.


A cookiesCondition block supports the following:

  • selector - (Required) Name of the cookie.

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of values for the cookie. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A deviceCondition block supports the following:

  • operator - (Optional) Valid values are equal.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Required) Valid values are desktop and mobile.


A httpVersionCondition block supports the following:

  • operator - (Optional) Valid values are equal.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Required) Valid values are 09, 10, 11 and 20.


A postArgCondition block supports the following:

  • selector - (Required) Name of the post arg.

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A queryStringCondition block supports the following:

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A remoteAddressCondition block supports the following:

  • operator - (Required) Valid values are any, geoMatch and ipMatch.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. For geoMatch operator this should be a list of country codes (e.g. us or de). List of IP address if operator equals to ipMatch. This is required if operator is not any.


A requestBodyCondition block supports the following:

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A requestHeaderCondition block supports the following:

  • selector - (Required) Header name.

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of header values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A requestMethodCondition block supports the following:

  • operator - (Optional) Valid values are equal.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Required) Valid values are delete, get, head, options, post and put.


A requestSchemeCondition block supports the following:

  • operator - (Optional) Valid values are equal.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Required) Valid values are http and https.


A requestUriCondition block supports the following:

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A urlFileExtensionCondition block supports the following:

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A urlFileNameCondition block supports the following:

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan and lessThanOrEqual.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


A urlPathCondition block supports the following:

  • operator - (Required) Valid values are any, beginsWith, contains, endsWith, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, regEx and wildcard.

  • negateCondition - (Optional) Defaults to false.

  • matchValues - (Optional) List of string values. This is required if operator is not any.

  • transforms - (Optional) A list of transforms. Valid values are lowercase and uppercase.


Attributes Reference

The following attributes are exported:

  • id - The ID of the CDN Endpoint.

  • fqdn - The Fully Qualified Domain Name of the CDN Endpoint.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the CDN Endpoint.
  • update - (Defaults to 30 minutes) Used when updating the CDN Endpoint.
  • read - (Defaults to 5 minutes) Used when retrieving the CDN Endpoint.
  • delete - (Defaults to 30 minutes) Used when deleting the CDN Endpoint.

Import

CDN Endpoints can be imported using the resourceId, e.g.

terraform import azurerm_cdn_endpoint.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Cdn/profiles/myprofile1/endpoints/myendpoint1