From e749f7040e1ae902b117db2291ac9ab2e5bf7bff Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:38:30 -0600 Subject: [PATCH 1/6] init --- 3_networking/front-door/README.md | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 3_networking/front-door/README.md diff --git a/3_networking/front-door/README.md b/3_networking/front-door/README.md new file mode 100644 index 0000000..d58b102 --- /dev/null +++ b/3_networking/front-door/README.md @@ -0,0 +1,62 @@ +# Terraform Template - Azure Front Door + +Costa Rica + +[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) +[brown9804](https://github.com/brown9804) + +Last updated: 2025-06-11 + +---------- + +> This template contains Terraform configurations to create and manage an Azure Front Door Standard/Premium profile, including frontend endpoint, backend pool, health probe, and routing rule. + +> [!NOTE] +> This Front Door configuration uses best practices for global HTTP/HTTPS load balancing and health monitoring. + +

+ image +

+ +## File Descriptions + +- **main.tf**: Contains the main configuration for creating the Azure Front Door profile and its associated resources. +- **variables.tf**: Defines the input variables used in the Terraform configuration. +- **terraform.tfvars**: Provides default values for the variables defined in `variables.tf`. +- **outputs.tf**: Defines the outputs such as Front Door profile ID and frontend endpoint hostname. + +## Variables + +: Below is a list of variables used in this template, their expected values, types, and examples: + +| Variable Name | Description | Type | Example Value | +|---------------------- |--------------------------------------------------|--------|-----------------------------| +| `subscription_id` | The Azure subscription ID | string | `"00000000-0000-0000-0000-000000000000"` | +| `resource_group_name` | The name of the resource group | string | `"my-frontdoor-rg"` | +| `location` | The Azure region to deploy resources | string | `"eastus"` | +| `front_door_name` | The name of the Azure Front Door profile | string | `"myfrontdoorprofile"` | +| `backend_host` | The backend host (FQDN or IP) for Front Door | string | `"mybackend.example.com"` | + +## Usage + +1. Clone the repository and navigate to the front-door directory. +2. Update the `terraform.tfvars` file with your values. +3. Initialize and apply the Terraform configuration: + +```bash +terraform init +terraform plan +terraform apply +``` + +## Outputs + +| Output Name | Description | +|------------------------------|---------------------------------------------| +| `front_door_id` | The ID of the Front Door profile | +| `front_door_frontend_endpoint` | The frontend endpoint hostname of Front Door | + +
+

Total Visitors

+ Visitor Count +
From 837788bfc6d6e699aaa1b7a88a55ac2086b5bb8a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 12 Jun 2025 19:38:49 +0000 Subject: [PATCH 2/6] Update last modified date in Markdown files --- 3_networking/front-door/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3_networking/front-door/README.md b/3_networking/front-door/README.md index d58b102..fcad870 100644 --- a/3_networking/front-door/README.md +++ b/3_networking/front-door/README.md @@ -5,7 +5,7 @@ Costa Rica [![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [brown9804](https://github.com/brown9804) -Last updated: 2025-06-11 +Last updated: 2025-06-12 ---------- From 6788002632abe18b7b561645aace49466ee0ebeb Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:39:41 -0600 Subject: [PATCH 3/6] visual ref --- 3_networking/front-door/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3_networking/front-door/README.md b/3_networking/front-door/README.md index fcad870..89217a8 100644 --- a/3_networking/front-door/README.md +++ b/3_networking/front-door/README.md @@ -15,7 +15,7 @@ Last updated: 2025-06-12 > This Front Door configuration uses best practices for global HTTP/HTTPS load balancing and health monitoring.

- image + image

## File Descriptions @@ -27,7 +27,7 @@ Last updated: 2025-06-12 ## Variables -: Below is a list of variables used in this template, their expected values, types, and examples: +> Below is a list of variables used in this template, their expected values, types, and examples: | Variable Name | Description | Type | Example Value | |---------------------- |--------------------------------------------------|--------|-----------------------------| From 6a2edcb671d944dbf0919d07ea0649d66a72f722 Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:40:09 -0600 Subject: [PATCH 4/6] sample front door --- 3_networking/front-door/main.tf | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 3_networking/front-door/main.tf diff --git a/3_networking/front-door/main.tf b/3_networking/front-door/main.tf new file mode 100644 index 0000000..1b1eb2f --- /dev/null +++ b/3_networking/front-door/main.tf @@ -0,0 +1,61 @@ +# main.tf +# Azure Front Door Standard/Premium configuration with required origin group and origin + +resource "azurerm_resource_group" "fd" { + name = var.resource_group_name + location = var.location +} + +resource "azurerm_cdn_frontdoor_profile" "fd" { + name = var.front_door_name + resource_group_name = azurerm_resource_group.fd.name + sku_name = "Standard_AzureFrontDoor" +} + +resource "azurerm_cdn_frontdoor_endpoint" "fd" { + name = var.frontend_endpoint_name + cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.fd.id +} + +resource "azurerm_cdn_frontdoor_origin_group" "fd" { + name = "originGroup1" + cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.fd.id + + health_probe { + interval_in_seconds = 30 + path = var.health_probe_path + protocol = var.health_probe_protocol + request_type = "GET" + } + + load_balancing { + sample_size = 4 + successful_samples_required = 3 + } +} + +resource "azurerm_cdn_frontdoor_origin" "fd" { + name = "origin1" + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.fd.id + host_name = var.backend_host + http_port = 80 + https_port = 443 + enabled = true + origin_host_header = var.backend_host + priority = 1 + weight = 1000 + certificate_name_check_enabled = true +} + +resource "azurerm_cdn_frontdoor_route" "routing_rule" { + name = var.routing_rule_name + cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.fd.id + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.fd.id + cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.fd.id] + supported_protocols = var.accepted_protocols + patterns_to_match = var.patterns_to_match + forwarding_protocol = "MatchRequest" + enabled = true + https_redirect_enabled = false + link_to_default_domain = true +} From 85f2b506d976ae8ec2ee99d2a22f83dda8a4f972 Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:40:53 -0600 Subject: [PATCH 5/6] front door sample --- 3_networking/front-door/outputs.tf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 3_networking/front-door/outputs.tf diff --git a/3_networking/front-door/outputs.tf b/3_networking/front-door/outputs.tf new file mode 100644 index 0000000..234b9a2 --- /dev/null +++ b/3_networking/front-door/outputs.tf @@ -0,0 +1,12 @@ +# outputs.tf +# This file defines the outputs for the Front Door configuration. + +output "front_door_id" { + description = "The ID of the Front Door profile" + value = azurerm_cdn_frontdoor_profile.fd.id +} + +output "front_door_frontend_endpoint" { + description = "The frontend endpoint hostname of the Front Door" + value = azurerm_cdn_frontdoor_endpoint.fd.host_name +} From c7e5e16521004ab0472d7a5af940f9b3565aa664 Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:42:57 -0600 Subject: [PATCH 6/6] front door sample --- 3_networking/front-door/provider.tf | 19 ++++++++ 3_networking/front-door/terraform.tfvars | 26 ++++++++++ 3_networking/front-door/variables.tf | 61 ++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 3_networking/front-door/provider.tf create mode 100644 3_networking/front-door/terraform.tfvars create mode 100644 3_networking/front-door/variables.tf diff --git a/3_networking/front-door/provider.tf b/3_networking/front-door/provider.tf new file mode 100644 index 0000000..f3f9b2d --- /dev/null +++ b/3_networking/front-door/provider.tf @@ -0,0 +1,19 @@ +# provider.tf +# This file configures the Azure provider to interact with Azure resources. +# It specifies the required provider and its version, along with provider-specific configurations. + +terraform { + required_version = ">= 1.8, < 2.0" + # Specify the required provider and its version + required_providers { + azurerm = { + source = "hashicorp/azurerm" # Source of the AzureRM provider + version = "~> 4.16.0" # Version of the AzureRM provider + } + } +} + +provider "azurerm" { + features {} # Enable all features for the AzureRM provider + subscription_id = var.subscription_id # Use the subscription ID variable +} diff --git a/3_networking/front-door/terraform.tfvars b/3_networking/front-door/terraform.tfvars new file mode 100644 index 0000000..ca6fdb3 --- /dev/null +++ b/3_networking/front-door/terraform.tfvars @@ -0,0 +1,26 @@ +# terraform.tfvars +# This file provides default values for the variables defined in variables.tf. +# These values can be overridden by specifying different values during Terraform execution. + +# Azure Subscription +subscription_id = "" # your-subscription-id + +# Resource Group +resource_group_name = "RG-frontdoor-test" +location = "eastus" + +# Front Door Configuration +front_door_name = "myfrontdoorprofilebrown" +backend_host = "mybackendtestbrown.example.com" + +# Frontend Endpoint Configuration +frontend_endpoint_name = "frontendEndpoint" + +# Health Probe Configuration +health_probe_path = "/" +health_probe_protocol = "Http" + +# Routing Rule Configuration +routing_rule_name = "routingRule1" +accepted_protocols = ["Http", "Https"] +patterns_to_match = ["/*"] diff --git a/3_networking/front-door/variables.tf b/3_networking/front-door/variables.tf new file mode 100644 index 0000000..c5ab9b3 --- /dev/null +++ b/3_networking/front-door/variables.tf @@ -0,0 +1,61 @@ +# variables.tf +# This file defines the input variables used in the Terraform configuration. + +variable "subscription_id" { + description = "The Azure subscription ID" + type = string +} + +variable "resource_group_name" { + description = "The name of the resource group" + type = string +} + +variable "location" { + description = "The Azure region to deploy resources" + type = string +} + +variable "front_door_name" { + description = "The name of the Azure Front Door Standard profile" + type = string +} + +variable "backend_host" { + description = "The backend host (FQDN or IP) where Front Door will route traffic" + type = string +} + +variable "frontend_endpoint_name" { + description = "The name of the Front Door frontend endpoint" + type = string +} + +variable "health_probe_path" { + description = "The path used for health probing" + type = string + default = "/" +} + +variable "health_probe_protocol" { + description = "The protocol for health probing (Http or Https)" + type = string + default = "Http" +} + +variable "routing_rule_name" { + description = "The name of the routing rule" + type = string +} + +variable "accepted_protocols" { + description = "List of accepted protocols for routing" + type = list(string) + default = ["Http", "Https"] +} + +variable "patterns_to_match" { + description = "URL patterns for request matching" + type = list(string) + default = ["/*"] +}