Skip to content

Commit 5b4a9d0

Browse files
authored
Merge pull request #219237 from johndowns/front-door-terraform-samples
Front Door - Update Terraform samples
2 parents 6d9a9be + b929f2c commit 5b4a9d0

File tree

5 files changed

+71
-297
lines changed

5 files changed

+71
-297
lines changed

articles/frontdoor/TOC.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,18 @@
100100
items:
101101
- name: Standard/Premium
102102
items:
103-
- name: Resource Manager Templates
103+
- name: Bicep and Resource Manager Templates
104104
href: front-door-quickstart-template-samples.md?pivots=front-door-standard-premium
105+
- name: Terraform
106+
href: terraform-samples.md?pivots=front-door-standard-premium
105107
- name: Classic
106108
items:
107-
- name: Resource Manager Templates
109+
- name: Bicep and Resource Manager Templates
108110
href: front-door-quickstart-template-samples.md?pivots=front-door-classic
109111
- name: Deploy custom domain - Azure CLI
110112
href: scripts/custom-domain.md
113+
- name: Terraform
114+
href: terraform-samples.md?pivots=front-door-classic
111115
- name: CDN
112116
items:
113117
- name: Code samples

articles/frontdoor/create-front-door-terraform.md

Lines changed: 7 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Quickstart: Create a Azure Front Door Standard/Premium profile using Terraform'
2+
title: 'Quickstart: Create an Azure Front Door Standard/Premium profile using Terraform'
33
description: This quickstart describes how to create an Azure Front Door Standard/Premium using Terraform.
44
services: front-door
55
author: johndowns
@@ -33,205 +33,27 @@ The steps in this article were tested with the following Terraform and Terraform
3333

3434
1. Create a file named `providers.tf` and insert the following code:
3535

36-
```terraform
37-
# Configure the Azure provider
38-
terraform {
39-
required_providers {
40-
azurerm = {
41-
source = "hashicorp/azurerm"
42-
version = "~> 3.27.0"
43-
}
44-
45-
random = {
46-
source = "hashicorp/random"
47-
}
48-
}
49-
50-
required_version = ">= 1.1.0"
51-
}
52-
53-
provider "azurerm" {
54-
features {}
55-
}
56-
```
36+
[!code-terraform[master](../../terraform/quickstart/101-front-door-standard-premium/providers.tf)]
5737

5838
1. Create a file named `resource-group.tf` and insert the following code:
5939

60-
```terraform
61-
resource "azurerm_resource_group" "my_resource_group" {
62-
name = var.resource_group_name
63-
location = var.location
64-
}
65-
```
40+
[!code-terraform[master](../../terraform/quickstart/101-front-door-standard-premium/resource-group.tf)]
6641

6742
1. Create a file named `app-service.tf` and insert the following code:
6843

69-
```terraform
70-
locals {
71-
app_name = "myapp-${lower(random_id.app_name.hex)}"
72-
app_service_plan_name = "AppServicePlan"
73-
}
74-
75-
resource "azurerm_service_plan" "app_service_plan" {
76-
name = local.app_service_plan_name
77-
location = var.location
78-
resource_group_name = azurerm_resource_group.my_resource_group.name
79-
80-
sku_name = var.app_service_plan_sku_name
81-
os_type = "Windows"
82-
worker_count = var.app_service_plan_capacity
83-
}
84-
85-
resource "azurerm_windows_web_app" "app" {
86-
name = local.app_name
87-
location = var.location
88-
resource_group_name = azurerm_resource_group.my_resource_group.name
89-
service_plan_id = azurerm_service_plan.app_service_plan.id
90-
91-
https_only = true
92-
93-
site_config {
94-
ftps_state = "Disabled"
95-
minimum_tls_version = "1.2"
96-
ip_restriction = [ {
97-
service_tag = "AzureFrontDoor.Backend"
98-
ip_address = null
99-
virtual_network_subnet_id = null
100-
action = "Allow"
101-
priority = 100
102-
headers = [ {
103-
x_azure_fdid = [ azurerm_cdn_frontdoor_profile.my_front_door.resource_guid ]
104-
x_fd_health_probe = []
105-
x_forwarded_for = []
106-
x_forwarded_host = []
107-
} ]
108-
name = "Allow traffic from Front Door"
109-
} ]
110-
}
111-
}
112-
```
44+
[!code-terraform[master](../../terraform/quickstart/101-front-door-standard-premium/app-service.tf)]
11345

11446
1. Create a file named `front-door.tf` and insert the following code:
11547

116-
```terraform
117-
locals {
118-
front_door_profile_name = "MyFrontDoor"
119-
front_door_endpoint_name = "afd-${lower(random_id.front_door_endpoint_name.hex)}"
120-
front_door_origin_group_name = "MyOriginGroup"
121-
front_door_origin_name = "MyAppServiceOrigin"
122-
front_door_route_name = "MyRoute"
123-
}
124-
125-
resource "azurerm_cdn_frontdoor_profile" "my_front_door" {
126-
name = local.front_door_profile_name
127-
resource_group_name = azurerm_resource_group.my_resource_group.name
128-
sku_name = var.front_door_sku_name
129-
}
130-
131-
resource "azurerm_cdn_frontdoor_endpoint" "my_endpoint" {
132-
name = local.front_door_endpoint_name
133-
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.my_front_door.id
134-
}
135-
136-
resource "azurerm_cdn_frontdoor_origin_group" "my_origin_group" {
137-
name = local.front_door_origin_group_name
138-
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.my_front_door.id
139-
session_affinity_enabled = true
140-
141-
load_balancing {
142-
sample_size = 4
143-
successful_samples_required = 3
144-
}
145-
146-
health_probe {
147-
path = "/"
148-
request_type = "HEAD"
149-
protocol = "Https"
150-
interval_in_seconds = 100
151-
}
152-
}
153-
154-
resource "azurerm_cdn_frontdoor_origin" "my_app_service_origin" {
155-
name = local.front_door_origin_name
156-
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.my_origin_group.id
157-
158-
enabled = true
159-
host_name = azurerm_windows_web_app.app.default_hostname
160-
http_port = 80
161-
https_port = 443
162-
origin_host_header = azurerm_windows_web_app.app.default_hostname
163-
priority = 1
164-
weight = 1000
165-
certificate_name_check_enabled = true
166-
}
167-
168-
resource "azurerm_cdn_frontdoor_route" "my_route" {
169-
name = local.front_door_route_name
170-
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.my_endpoint.id
171-
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.my_origin_group.id
172-
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.my_app_service_origin.id]
173-
174-
supported_protocols = ["Http", "Https"]
175-
patterns_to_match = ["/*"]
176-
forwarding_protocol = "HttpsOnly"
177-
link_to_default_domain = true
178-
https_redirect_enabled = true
179-
}
180-
```
48+
[!code-terraform[master](../../terraform/quickstart/101-front-door-standard-premium/front-door.tf)]
18149

18250
1. Create a file named `variables.tf` and insert the following code:
18351

184-
```terraform
185-
variable "location" {
186-
type = string
187-
default = "westus2"
188-
}
189-
190-
variable "resource_group_name" {
191-
type = string
192-
default = "FrontDoor"
193-
}
194-
195-
variable "app_service_plan_sku_name" {
196-
type = string
197-
default = "S1"
198-
}
199-
200-
variable "app_service_plan_capacity" {
201-
type = number
202-
default = 1
203-
}
204-
205-
variable "app_service_plan_sku_tier_name" {
206-
type = string
207-
default = "Standard"
208-
}
209-
210-
variable "front_door_sku_name" {
211-
type = string
212-
default = "Standard_AzureFrontDoor"
213-
validation {
214-
condition = contains(["Standard_AzureFrontDoor", "Premium_AzureFrontDoor"], var.front_door_sku_name)
215-
error_message = "The SKU value must be Standard_AzureFrontDoor or Premium_AzureFrontDoor."
216-
}
217-
}
218-
219-
resource "random_id" "app_name" {
220-
byte_length = 8
221-
}
222-
223-
resource "random_id" "front_door_endpoint_name" {
224-
byte_length = 8
225-
}
226-
```
52+
[!code-terraform[master](../../terraform/quickstart/101-front-door-standard-premium/variables.tf)]
22753

22854
1. Create a file named `outputs.tf` and insert the following code:
22955

230-
```terraform
231-
output "frontDoorEndpointHostName" {
232-
value = azurerm_cdn_frontdoor_endpoint.my_endpoint.host_name
233-
}
234-
```
56+
[!code-terraform[master](../../terraform/quickstart/101-front-door-standard-premium/outputs.tf)]
23557

23658
## Initialize Terraform
23759

articles/frontdoor/front-door-quickstart-template-samples.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Azure Resource Manager template samples - Azure Front Door
3-
description: Learn about Resource Manager template samples for Azure Front Door, including templates for creating a basic Front Door and configuring Front Door rate limiting.
3+
description: Learn about Resource Manager template samples for Azure Front Door, including templates for creating a basic Front Door profile and configuring Front Door rate limiting.
44
services: frontdoor
55
documentationcenter: ""
66
author: duongau
@@ -12,9 +12,9 @@ ms.date: 03/10/2022
1212
ms.author: duau
1313
zone_pivot_groups: front-door-tiers
1414
---
15-
# Azure Resource Manager deployment model templates for Front Door
15+
# Bicep and Azure Resource Manager deployment model templates for Front Door
1616

17-
The following table includes links to Azure Resource Manager deployment model templates for Azure Front Door.
17+
The following table includes links to Bicep and Azure Resource Manager deployment model templates for Azure Front Door.
1818

1919
::: zone pivot="front-door-standard-premium"
2020

@@ -55,7 +55,7 @@ The following table includes links to Azure Resource Manager deployment model te
5555
| Template | Description |
5656
| ---| ---|
5757
| [Create a basic Front Door](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.network/front-door-create-basic)| Creates a basic Front Door configuration with a single backend. |
58-
| [Create a Front Door with multiple backends and backend pools and URL based routing](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.network/front-door-create-multiple-backends)| Creates a Front Door with load balancing configured for multiple backends in ta backend pool and also across backend pools based on URL path. |
58+
| [Create a Front Door with multiple backends and backend pools and URL based routing](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.network/front-door-create-multiple-backends)| Creates a Front Door with load balancing configured for multiple backends in a backend pool and also across backend pools based on URL path. |
5959
| [Onboard a custom domain and managed TLS certificate with Front Door](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.network/front-door-custom-domain)| Add a custom domain to your Front Door and use a Front Door-managed TLS certificate. |
6060
| [Onboard a custom domain and customer-managed TLS certificate with Front Door](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.network/front-door-custom-domain-customer-certificate)| Add a custom domain to your Front Door and use your own TLS certificate by using Key Vault. |
6161
| [Create Front Door with geo filtering](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.network/front-door-geo-filtering)| Create a Front Door that allows/blocks traffic from certain countries/regions. |

articles/frontdoor/quickstart-create-front-door-terraform.md

Lines changed: 4 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -33,121 +33,19 @@ The steps in this article were tested with the following Terraform and Terraform
3333

3434
1. Create a file named `providers.tf` and insert the following code:
3535

36-
```terraform
37-
# Configure the Azure provider
38-
terraform {
39-
required_providers {
40-
azurerm = {
41-
source = "hashicorp/azurerm"
42-
version = "~> 3.27.0"
43-
}
44-
45-
random = {
46-
source = "hashicorp/random"
47-
}
48-
}
49-
50-
required_version = ">= 1.1.0"
51-
}
52-
53-
provider "azurerm" {
54-
features {}
55-
}
56-
```
36+
[!code-terraform[master](../../terraform/quickstart/101-front-door-classic/providers.tf)]
5737

5838
1. Create a file named `resource-group.tf` and insert the following code:
5939

60-
```terraform
61-
resource "azurerm_resource_group" "my_resource_group" {
62-
name = var.resource_group_name
63-
location = var.location
64-
}
65-
```
40+
[!code-terraform[master](../../terraform/quickstart/101-front-door-classic/resource-group.tf)]
6641

6742
1. Create a file named `front-door.tf` and insert the following code:
6843

69-
```terraform
70-
locals {
71-
front_door_name = "afd-${lower(random_id.front_door_name.hex)}"
72-
front_door_frontend_endpoint_name = "frontEndEndpoint"
73-
front_door_load_balancing_settings_name = "loadBalancingSettings"
74-
front_door_health_probe_settings_name = "healthProbeSettings"
75-
front_door_routing_rule_name = "routingRule"
76-
front_door_backend_pool_name = "backendPool"
77-
}
78-
79-
resource "azurerm_frontdoor" "my_front_door" {
80-
name = local.front_door_name
81-
resource_group_name = azurerm_resource_group.my_resource_group.name
82-
83-
frontend_endpoint {
84-
name = local.front_door_frontend_endpoint_name
85-
host_name = "${local.front_door_name}.azurefd.net"
86-
session_affinity_enabled = false
87-
}
88-
89-
backend_pool_load_balancing {
90-
name = local.front_door_load_balancing_settings_name
91-
sample_size = 4
92-
successful_samples_required = 2
93-
}
94-
95-
backend_pool_health_probe {
96-
name = local.front_door_health_probe_settings_name
97-
path = "/"
98-
protocol = "Http"
99-
interval_in_seconds = 120
100-
}
101-
102-
backend_pool {
103-
name = local.front_door_backend_pool_name
104-
backend {
105-
host_header = var.backend_address
106-
address = var.backend_address
107-
http_port = 80
108-
https_port = 443
109-
weight = 50
110-
priority = 1
111-
}
112-
113-
load_balancing_name = local.front_door_load_balancing_settings_name
114-
health_probe_name = local.front_door_health_probe_settings_name
115-
}
116-
117-
routing_rule {
118-
name = local.front_door_routing_rule_name
119-
accepted_protocols = ["Http", "Https"]
120-
patterns_to_match = ["/*"]
121-
frontend_endpoints = [local.front_door_frontend_endpoint_name]
122-
forwarding_configuration {
123-
forwarding_protocol = "MatchRequest"
124-
backend_pool_name = local.front_door_backend_pool_name
125-
}
126-
}
127-
}
128-
```
44+
[!code-terraform[master](../../terraform/quickstart/101-front-door-classic/front-door.tf)]
12945

13046
1. Create a file named `variables.tf` and insert the following code:
13147

132-
```terraform
133-
variable "location" {
134-
type = string
135-
default = "westus2"
136-
}
137-
138-
variable "resource_group_name" {
139-
type = string
140-
default = "FrontDoor"
141-
}
142-
143-
variable "backend_address" {
144-
type = string
145-
}
146-
147-
resource "random_id" "front_door_name" {
148-
byte_length = 8
149-
}
150-
```
48+
[!code-terraform[master](../../terraform/quickstart/101-front-door-classic/variables.tf)]
15149

15250
1. Create a file named `terraform.tfvars` and insert the following code, being sure to update the value to your own backend hostname:
15351

0 commit comments

Comments
 (0)