Azure Network Frontdoor
This page shows how to write Terraform and Azure Resource Manager for Network Frontdoor and write them securely.
azurerm_frontdoor (Terraform)
The Frontdoor in Network can be configured in Terraform with the resource name azurerm_frontdoor. The following sections describe 8 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_frontdoor" "frontdoorkata" {
name = "frontdoorkata111"
resource_group_name = data.azurerm_resource_group.kata1ResourceGroup.name
enforce_backend_pools_certificate_name_check = true
routing_rule {
resource "azurerm_frontdoor" "front_door" {
name = var.front_door_name
resource_group_name = var.resource_group_name
enforce_backend_pools_certificate_name_check = var.enforce_cert_check
tags = var.tags
resource "azurerm_frontdoor" "example" {
name = var.front_door_name
resource_group_name = data.azurerm_resource_group.resource-group.name
enforce_backend_pools_certificate_name_check = false
routing_rule {
resource "azurerm_frontdoor" "example" {
name = "example-FrontDoor-CentralAPP"
location = "Global"
resource_group_name = azurerm_resource_group.example.name
enforce_backend_pools_certificate_name_check = false
resource "azurerm_frontdoor" "frontdoor" {
name = "fd-appgw-sample"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
enforce_backend_pools_certificate_name_check = false
resource "azurerm_frontdoor" "positive" {
name = "example-FrontDoor"
resource_group_name = azurerm_resource_group.example.name
enforce_backend_pools_certificate_name_check = false
routing_rule {
resource "azurerm_frontdoor" "negative" {
name = "example-FrontDoor"
resource_group_name = azurerm_resource_group.example.name
enforce_backend_pools_certificate_name_check = false
routing_rule {
resource "azurerm_frontdoor" "azfd" {
name = local.azfd_name
resource_group_name = local.rsgr_name
enforce_backend_pools_certificate_name_check = false
routing_rule {
Parameters
-
backend_pool_health_probesoptional computed - map from string to string -
backend_pool_load_balancing_settingsoptional computed - map from string to string -
backend_poolsoptional computed - map from string to string -
backend_pools_send_receive_timeout_secondsoptional - number -
cnameoptional computed - string -
enforce_backend_pools_certificate_name_checkrequired - bool -
friendly_nameoptional - string -
frontend_endpointsoptional computed - map from string to string -
header_frontdoor_idoptional computed - string -
idoptional computed - string -
load_balancer_enabledoptional - bool -
locationoptional computed - string -
namerequired - string -
resource_group_namerequired - string -
routing_rulesoptional computed - map from string to string -
tagsoptional - map from string to string -
backend_poollist block-
health_probe_namerequired - string -
idoptional computed - string -
load_balancing_namerequired - string -
namerequired - string -
backendlist block-
addressrequired - string -
enabledoptional - bool -
host_headerrequired - string -
http_portrequired - number -
https_portrequired - number -
priorityoptional - number -
weightoptional - number
-
-
-
backend_pool_health_probelist block-
enabledoptional - bool -
idoptional computed - string -
interval_in_secondsoptional - number -
namerequired - string -
pathoptional - string -
probe_methodoptional - string -
protocoloptional - string
-
-
backend_pool_load_balancinglist block-
additional_latency_millisecondsoptional - number -
idoptional computed - string -
namerequired - string -
sample_sizeoptional - number -
successful_samples_requiredoptional - number
-
-
frontend_endpointlist block-
custom_https_provisioning_enabledoptional computed - bool -
host_namerequired - string -
idoptional computed - string -
namerequired - string -
session_affinity_enabledoptional - bool -
session_affinity_ttl_secondsoptional - number -
web_application_firewall_policy_link_idoptional - string -
custom_https_configurationlist block-
azure_key_vault_certificate_secret_nameoptional - string -
azure_key_vault_certificate_secret_versionoptional - string -
azure_key_vault_certificate_vault_idoptional - string -
certificate_sourceoptional - string -
minimum_tls_versionoptional computed - string -
provisioning_stateoptional computed - string -
provisioning_substateoptional computed - string
-
-
-
routing_rulelist block-
accepted_protocolsrequired - list of string -
enabledoptional - bool -
frontend_endpointsrequired - list of string -
idoptional computed - string -
namerequired - string -
patterns_to_matchrequired - list of string -
forwarding_configurationlist block-
backend_pool_namerequired - string -
cache_enabledoptional - bool -
cache_query_parameter_strip_directiveoptional - string -
cache_use_dynamic_compressionoptional - bool -
custom_forwarding_pathoptional - string -
forwarding_protocoloptional - string
-
-
redirect_configurationlist block-
custom_fragmentoptional - string -
custom_hostoptional - string -
custom_pathoptional - string -
custom_query_stringoptional - string -
redirect_protocolrequired - string -
redirect_typerequired - string
-
-
-
timeoutssingle block
Explanation in Terraform Registry
Manages an Azure Front Door instance. Azure Front Door Service is Microsoft's highly available and scalable web application acceleration platform and global HTTP(s) load balancer. It provides built-in DDoS protection and application layer security and caching. Front Door enables you to build applications that maximize and automate high-availability and performance for your end-users. Use Front Door with Azure services including Web/Mobile Apps, Cloud Services and Virtual Machines – or combine it with on-premises services for hybrid deployments and smooth cloud migration. Below are some of the key scenarios that Azure Front Door Service addresses:
- Use Front Door to improve application scale and availability with instant multi-region failover
- Use Front Door to improve application performance with SSL offload and routing requests to the fastest available application backend.
- Use Front Door for application layer security and DDoS protection for your application. !>Be Aware: Azure is rolling out a breaking change on Friday 9th April 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. !>BREAKING CHANGE: The
custom_https_provisioning_enabledfield and thecustom_https_configurationblock have been removed from theazurerm_frontdoorresource in thev2.58.0provider due to changes made by the service team. If you wish to enable the custom https configuration functionality within yourazurerm_frontdoorresource moving forward you will need to define a separateazurerm_frontdoor_custom_https_configurationblock in your configuration file. !>BREAKING CHANGE: With the release of thev2.58.0provider, if you run theapplycommand against an existing Front Door resource it will not apply the detected changes. Instead it will persist theexplicit_resource_ordermapping structure to the state file. Once this operation has completed the resource will resume functioning normally.This change in behavior in Terraform is due to an issue where the underlying service teams API is now returning the response JSON out of order from the way it was sent to the resource via Terraform causing unexpected discrepancies in theplanafter the resource has been provisioned. If your pre-existing Front Door instance containscustom_https_configurationblocks there are additional steps that will need to be completed to successfully migrate your Front Door onto thev2.58.0provider which can be found in this guide.
Tips: Best Practices for The Other Azure Network Resources
In addition to the azurerm_network_security_group, Azure Network has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_network_security_group
Ensure to disable RDP port from the Internet
It is better to disable the RDP port from the Internet. RDP access should not be accepted from the Internet (*, 0.0.0.0, /0, internet, any), and consider using the Azure Bastion Service.
azurerm_network_security_rule
Ensure to set a more restrictive CIDR range for ingress from the internet
It is better to set a more restrictive CIDR range not to use very broad subnets. If possible, segments should be divided into smaller subnets.
azurerm_network_watcher_flow_log
Ensure to enable Retention policy for flow logs and set it to enough duration
It is better to enable a retention policy for flow logs. Flow logs show us all network activity in the cloud environment and support us when we face critical incidents.
Microsoft.Network/frontDoors (Azure Resource Manager)
The frontDoors in Microsoft.Network can be configured in Azure Resource Manager with the resource name Microsoft.Network/frontDoors. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"frontdoorName": {
[
{
"ResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-test/providers/Microsoft.Network/frontdoors/frontdoor-A",
"Id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-test/providers/Microsoft.Network/frontdoors/frontdoor-A",
"Identity": null,
"type": "Microsoft.Network/frontDoors",
"name": "[variables('frontDoorName')]",
"location": "[resourceGroup().location]",
"properties": {
"routingRules": [
{
"type": "Microsoft.Network/frontDoors",
"name": "[variables('frontDoorName')]",
"location": "[resourceGroup().location]",
"properties": {
"routingRules": [
{
"type": "Microsoft.Network/frontDoors",
"name": "[variables('frontDoorName')]",
"location": "[resourceGroup().location]",
"properties": {
"routingRules": [
{
"type": "Microsoft.Network/frontDoors",
"name": "[variables('frontDoorName')]",
"location": "[resourceGroup().location]",
"properties": {
"routingRules": [
{
"type": "Microsoft.Network/frontDoors",
"name": "[parameters('frontDoorName')]",
"location": "[variables('frontdoorLocation')]",
"properties": {
"routingRules": [
{
"type": "Microsoft.Network/frontDoors",
"apiVersion": "2020-01-01",
"name": "[parameters('frontDoorName')]",
"location": "global",
"properties": {
"enabledState": "Enabled",
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workflows_trafficcontrol_name": {
"type": "Microsoft.Network/frontDoors",
"name": "[variables('frontDoorName')]",
"location": "[variables('frontdoorLocation')]",
"tags": {},
"properties": {
"routingRules": [
Frequently asked questions
What is Azure Network Frontdoor?
Azure Network Frontdoor is a resource for Network of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Network Frontdoor?
For Terraform, the mattykii/azureFrontDoorwithWebapps, andrewCluey/terraform-azurerm-frontdoor and josepht96/learning source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the Theatreers/Theatreers, Azure/PSRule.Rules.Azure and Azure/azure-resource-manager-schemas source code examples are useful. See the Azure Resource Manager Example section for further details.