Skip to content

Commit fb65cea

Browse files
authored
Merge pull request Azure#121 from johndowns/quickstart-101-front-door-classic
Add quickstart for Front Door (classic)
2 parents bf90566 + 497661a commit fb65cea

File tree

5 files changed

+231
-0
lines changed

5 files changed

+231
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
locals {
2+
front_door_name = "afd-${lower(random_id.front_door_name.hex)}"
3+
front_door_frontend_endpoint_name = "frontEndEndpoint"
4+
front_door_load_balancing_settings_name = "loadBalancingSettings"
5+
front_door_health_probe_settings_name = "healthProbeSettings"
6+
front_door_routing_rule_name = "routingRule"
7+
front_door_backend_pool_name = "backendPool"
8+
}
9+
10+
resource "azurerm_frontdoor" "my_front_door" {
11+
name = local.front_door_name
12+
resource_group_name = azurerm_resource_group.my_resource_group.name
13+
14+
frontend_endpoint {
15+
name = local.front_door_frontend_endpoint_name
16+
host_name = "${local.front_door_name}.azurefd.net"
17+
session_affinity_enabled = false
18+
}
19+
20+
backend_pool_load_balancing {
21+
name = local.front_door_load_balancing_settings_name
22+
sample_size = 4
23+
successful_samples_required = 2
24+
}
25+
26+
backend_pool_health_probe {
27+
name = local.front_door_health_probe_settings_name
28+
path = "/"
29+
protocol = "Http"
30+
interval_in_seconds = 120
31+
}
32+
33+
backend_pool {
34+
name = local.front_door_backend_pool_name
35+
backend {
36+
host_header = var.backend_address
37+
address = var.backend_address
38+
http_port = 80
39+
https_port = 443
40+
weight = 50
41+
priority = 1
42+
}
43+
44+
load_balancing_name = local.front_door_load_balancing_settings_name
45+
health_probe_name = local.front_door_health_probe_settings_name
46+
}
47+
48+
routing_rule {
49+
name = local.front_door_routing_rule_name
50+
accepted_protocols = ["Http", "Https"]
51+
patterns_to_match = ["/*"]
52+
frontend_endpoints = [local.front_door_frontend_endpoint_name]
53+
forwarding_configuration {
54+
forwarding_protocol = "MatchRequest"
55+
backend_pool_name = local.front_door_backend_pool_name
56+
}
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Configure the Azure provider
2+
terraform {
3+
required_providers {
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = "~> 3.27.0"
7+
}
8+
9+
random = {
10+
source = "hashicorp/random"
11+
version = "~> 3.4.3"
12+
}
13+
}
14+
15+
required_version = ">= 1.1.0"
16+
}
17+
18+
provider "azurerm" {
19+
features {}
20+
}
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Azure Front Door (classic)
2+
3+
This template deploys an [Azure Front Door (classic)](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/frontdoor).
4+
5+
## Resources
6+
7+
| Terraform Resource Type | Description |
8+
| - | - |
9+
| `azurerm_resource_group` | The resource group for all the deployed resources. |
10+
| `azurerm_frontdoor` | The Front Door (classic). |
11+
| `random_id` | A random identifier generator to generate a unique Front Door resource name. |
12+
13+
## Variables
14+
15+
| Name | Description | Default Value |
16+
|-|-|-|
17+
| `location` | The location for all the deployed resources. | `westus2` |
18+
| `resource_group_name` | The name of the resource group to deploy. | `FrontDoor` |
19+
| `backend_address` | The host name or IP address of the backend application. | |
20+
21+
## Example
22+
23+
```bash
24+
$ terraform plan -out main.tfplan
25+
26+
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
27+
+ create
28+
29+
Terraform will perform the following actions:
30+
31+
# azurerm_frontdoor.my_front_door will be created
32+
+ resource "azurerm_frontdoor" "my_front_door" {
33+
+ backend_pool_health_probes = (known after apply)
34+
+ backend_pool_load_balancing_settings = (known after apply)
35+
+ backend_pools = (known after apply)
36+
+ cname = (known after apply)
37+
+ explicit_resource_order = (known after apply)
38+
+ frontend_endpoints = (known after apply)
39+
+ header_frontdoor_id = (known after apply)
40+
+ id = (known after apply)
41+
+ load_balancer_enabled = true
42+
+ name = (known after apply)
43+
+ resource_group_name = "FrontDoor"
44+
+ routing_rules = (known after apply)
45+
46+
+ backend_pool {
47+
+ health_probe_name = "healthProbeSettings"
48+
+ id = (known after apply)
49+
+ load_balancing_name = "loadBalancingSettings"
50+
+ name = "backendPool"
51+
52+
+ backend {
53+
+ address = "<your backend hostname>"
54+
+ enabled = true
55+
+ host_header = "<your backend hostname>"
56+
+ http_port = 80
57+
+ https_port = 443
58+
+ priority = 1
59+
+ weight = 50
60+
}
61+
}
62+
63+
+ backend_pool_health_probe {
64+
+ enabled = true
65+
+ id = (known after apply)
66+
+ interval_in_seconds = 120
67+
+ name = "healthProbeSettings"
68+
+ path = "/"
69+
+ probe_method = "GET"
70+
+ protocol = "Http"
71+
}
72+
73+
+ backend_pool_load_balancing {
74+
+ additional_latency_milliseconds = 0
75+
+ id = (known after apply)
76+
+ name = "loadBalancingSettings"
77+
+ sample_size = 4
78+
+ successful_samples_required = 2
79+
}
80+
81+
+ frontend_endpoint {
82+
+ host_name = (known after apply)
83+
+ id = (known after apply)
84+
+ name = "frontEndEndpoint"
85+
+ session_affinity_enabled = false
86+
+ session_affinity_ttl_seconds = 0
87+
}
88+
89+
+ routing_rule {
90+
+ accepted_protocols = [
91+
+ "Http",
92+
+ "Https",
93+
]
94+
+ enabled = true
95+
+ frontend_endpoints = [
96+
+ "frontEndEndpoint",
97+
]
98+
+ id = (known after apply)
99+
+ name = "routingRule"
100+
+ patterns_to_match = [
101+
+ "/*",
102+
]
103+
104+
+ forwarding_configuration {
105+
+ backend_pool_name = "backendPool"
106+
+ cache_enabled = false
107+
+ cache_query_parameter_strip_directive = "StripAll"
108+
+ cache_use_dynamic_compression = false
109+
+ forwarding_protocol = "MatchRequest"
110+
}
111+
}
112+
}
113+
114+
# azurerm_resource_group.my_resource_group will be created
115+
+ resource "azurerm_resource_group" "my_resource_group" {
116+
+ id = (known after apply)
117+
+ location = "westus2"
118+
+ name = "FrontDoor"
119+
}
120+
121+
# random_id.front_door_name will be created
122+
+ resource "random_id" "front_door_name" {
123+
+ b64_std = (known after apply)
124+
+ b64_url = (known after apply)
125+
+ byte_length = 8
126+
+ dec = (known after apply)
127+
+ hex = (known after apply)
128+
+ id = (known after apply)
129+
}
130+
131+
Plan: 3 to add, 0 to change, 0 to destroy.
132+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "azurerm_resource_group" "my_resource_group" {
2+
name = var.resource_group_name
3+
location = var.location
4+
}
5+
6+
resource "random_id" "front_door_name" {
7+
byte_length = 8
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
variable "location" {
2+
type = string
3+
default = "westus2"
4+
}
5+
6+
variable "resource_group_name" {
7+
type = string
8+
default = "FrontDoor"
9+
}
10+
11+
variable "backend_address" {
12+
type = string
13+
}

0 commit comments

Comments
 (0)