Updated Front Door Classic code sample (#244)
This commit is contained in:
parent
2d6bb88c73
commit
e34f713c9e
@ -1,5 +1,18 @@
|
||||
resource "random_pet" "rg-name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = random_pet.rg-name.id
|
||||
location = var.resource_group_location
|
||||
}
|
||||
|
||||
resource "random_id" "front_door_name" {
|
||||
byte_length = 8
|
||||
}
|
||||
|
||||
locals {
|
||||
front_door_name = "${random_pet.prefix.id}-afd"
|
||||
front_door_name = "afd-${lower(random_id.front_door_name.hex)}"
|
||||
front_door_frontend_endpoint_name = "frontEndEndpoint"
|
||||
front_door_load_balancing_settings_name = "loadBalancingSettings"
|
||||
front_door_health_probe_settings_name = "healthProbeSettings"
|
7
quickstart/101-front-door-classic/outputs.tf
Normal file
7
quickstart/101-front-door-classic/outputs.tf
Normal file
@ -0,0 +1,7 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "frontDoorEndpointHostName" {
|
||||
value = azurerm_frontdoor.main.frontend_endpoint[0].host_name
|
||||
}
|
@ -1,19 +1,16 @@
|
||||
# Configure the Azure provider
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_version = ">=1.0"
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 3.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~> 3.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
@ -2,131 +2,21 @@
|
||||
|
||||
This template deploys an [Azure Front Door (classic)](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/frontdoor).
|
||||
|
||||
## Resources
|
||||
## Terraform resource types
|
||||
|
||||
| Terraform Resource Type | Description |
|
||||
| - | - |
|
||||
| `azurerm_resource_group` | The resource group for all the deployed resources. |
|
||||
| `azurerm_frontdoor` | The Front Door (classic). |
|
||||
| `random_id` | A random identifier generator to generate a unique Front Door resource name. |
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
- [random_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id)
|
||||
- [azurerm_frontdoor](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/frontdoor)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default Value |
|
||||
|-|-|-|
|
||||
| `location` | The location for all the deployed resources. | `westus2` |
|
||||
| `resource_group_name` | The name of the resource group to deploy. | `FrontDoor` |
|
||||
| `backend_address` | The host name or IP address of the backend application. | |
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
| `backend_address` | The host name or IP address of the backend application. | www.bing.com |
|
||||
|
||||
## Example
|
||||
|
||||
```bash
|
||||
$ terraform plan -out main.tfplan
|
||||
|
||||
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
|
||||
+ create
|
||||
|
||||
Terraform will perform the following actions:
|
||||
|
||||
# azurerm_frontdoor.my_front_door will be created
|
||||
+ resource "azurerm_frontdoor" "my_front_door" {
|
||||
+ backend_pool_health_probes = (known after apply)
|
||||
+ backend_pool_load_balancing_settings = (known after apply)
|
||||
+ backend_pools = (known after apply)
|
||||
+ cname = (known after apply)
|
||||
+ explicit_resource_order = (known after apply)
|
||||
+ frontend_endpoints = (known after apply)
|
||||
+ header_frontdoor_id = (known after apply)
|
||||
+ id = (known after apply)
|
||||
+ load_balancer_enabled = true
|
||||
+ name = (known after apply)
|
||||
+ resource_group_name = "FrontDoor"
|
||||
+ routing_rules = (known after apply)
|
||||
|
||||
+ backend_pool {
|
||||
+ health_probe_name = "healthProbeSettings"
|
||||
+ id = (known after apply)
|
||||
+ load_balancing_name = "loadBalancingSettings"
|
||||
+ name = "backendPool"
|
||||
|
||||
+ backend {
|
||||
+ address = "<your backend hostname>"
|
||||
+ enabled = true
|
||||
+ host_header = "<your backend hostname>"
|
||||
+ http_port = 80
|
||||
+ https_port = 443
|
||||
+ priority = 1
|
||||
+ weight = 50
|
||||
}
|
||||
}
|
||||
|
||||
+ backend_pool_health_probe {
|
||||
+ enabled = true
|
||||
+ id = (known after apply)
|
||||
+ interval_in_seconds = 120
|
||||
+ name = "healthProbeSettings"
|
||||
+ path = "/"
|
||||
+ probe_method = "GET"
|
||||
+ protocol = "Http"
|
||||
}
|
||||
|
||||
+ backend_pool_load_balancing {
|
||||
+ additional_latency_milliseconds = 0
|
||||
+ id = (known after apply)
|
||||
+ name = "loadBalancingSettings"
|
||||
+ sample_size = 4
|
||||
+ successful_samples_required = 2
|
||||
}
|
||||
|
||||
+ frontend_endpoint {
|
||||
+ host_name = (known after apply)
|
||||
+ id = (known after apply)
|
||||
+ name = "frontEndEndpoint"
|
||||
+ session_affinity_enabled = false
|
||||
+ session_affinity_ttl_seconds = 0
|
||||
}
|
||||
|
||||
+ routing_rule {
|
||||
+ accepted_protocols = [
|
||||
+ "Http",
|
||||
+ "Https",
|
||||
]
|
||||
+ enabled = true
|
||||
+ frontend_endpoints = [
|
||||
+ "frontEndEndpoint",
|
||||
]
|
||||
+ id = (known after apply)
|
||||
+ name = "routingRule"
|
||||
+ patterns_to_match = [
|
||||
+ "/*",
|
||||
]
|
||||
|
||||
+ forwarding_configuration {
|
||||
+ backend_pool_name = "backendPool"
|
||||
+ cache_enabled = false
|
||||
+ cache_query_parameter_strip_directive = "StripAll"
|
||||
+ cache_use_dynamic_compression = false
|
||||
+ forwarding_protocol = "MatchRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# azurerm_resource_group.my_resource_group will be created
|
||||
+ resource "azurerm_resource_group" "my_resource_group" {
|
||||
+ id = (known after apply)
|
||||
+ location = "westus2"
|
||||
+ name = "FrontDoor"
|
||||
}
|
||||
|
||||
# random_id.front_door_name will be created
|
||||
+ resource "random_id" "front_door_name" {
|
||||
+ b64_std = (known after apply)
|
||||
+ b64_url = (known after apply)
|
||||
+ byte_length = 8
|
||||
+ dec = (known after apply)
|
||||
+ hex = (known after apply)
|
||||
+ id = (known after apply)
|
||||
}
|
||||
|
||||
Plan: 3 to add, 0 to change, 0 to destroy.
|
||||
```
|
||||
To see how to run this example, see [Quickstart: Create a Front Door (classic) using Terraform](https://learn.microsoft.com/azure/frontdoor/quickstart-create-front-door-terraform).
|
@ -1,9 +0,0 @@
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = "${random_pet.prefix.id}-rg"
|
||||
location = var.location
|
||||
}
|
||||
|
||||
resource "random_pet" "prefix" {
|
||||
prefix = var.prefix
|
||||
length = 1
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
variable "location" {
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "westus2"
|
||||
description = "Location for all resources."
|
||||
default = "eastus"
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
default = "rg"
|
||||
}
|
||||
|
||||
variable "backend_address" {
|
||||
type = string
|
||||
description = "Backend address."
|
||||
default = "www.bing.com"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "prefix" {
|
||||
type = string
|
||||
default = "front-door-classic"
|
||||
description = "Prefix of the resource name"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user