|
| 1 | +# Terraform Template - CDN (Azure Content Delivery Network) |
| 2 | + |
| 3 | +Costa Rica |
| 4 | + |
| 5 | +[](https://github.com/) |
| 6 | +[brown9804](https://github.com/brown9804) |
| 7 | + |
| 8 | +Last updated: 2026-02-10 |
| 9 | + |
| 10 | +------------------------------------------ |
| 11 | + |
| 12 | +> This template contains Terraform configurations to create an Azure Front Door (Standard/Premium) profile and endpoint suitable for serving media assets (for example, fronting a storage/web origin). |
| 13 | +
|
| 14 | +> [!NOTE] |
| 15 | +> Azure CDN (classic) profiles (for example `Standard_Microsoft`) no longer support new profile creation. This template uses the modern Azure Front Door resources (`azurerm_cdn_frontdoor_*`). |
| 16 | +> The modern replacement for “Microsoft-managed global CDN + edge routing” is Azure Front Door Standard/Premium. It provides the CDN capability, but it’s provisioned via azurerm_cdn_frontdoor_* resources (Front Door profile/endpoint/route/origin), not azurerm_cdn_profile. <br/> |
| 17 | +> - If you already have classic CDN resources: Terraform can often still manage them. |
| 18 | +> - If you’re creating new: you generally need Front Door Standard/Premium (or another supported CDN provider SKU where available), because classic Microsoft CDN can’t be created anymore. |
| 19 | +
|
| 20 | +## File Descriptions |
| 21 | + |
| 22 | +- **main.tf**: Creates the Resource Group, Front Door Profile, Endpoint, Origin Group, Origin, and a default Route. |
| 23 | +- **variables.tf**: Defines the input variables used in the Terraform configuration. |
| 24 | +- **provider.tf**: Configures the Azure provider (uses Azure CLI auth context). |
| 25 | +- **terraform.tfvars**: Provides example values for the variables defined in `variables.tf`. |
| 26 | +- **outputs.tf**: Defines outputs such as CDN profile ID, endpoint ID, and endpoint host name. |
| 27 | + |
| 28 | +## Variables |
| 29 | + |
| 30 | +| Variable Name | Description | Type | Example Value | |
| 31 | +| --- | --- | --- | --- | |
| 32 | +| `resource_group_name` | The name of the resource group to create. | string | `"rg-media-services-dev"` | |
| 33 | +| `location` | Azure region for deployment. | string | `"East US"` | |
| 34 | +| `cdn_profile_name` | Front Door profile name. | string | `"cdn-media-services-dev-001"` | |
| 35 | +| `cdn_sku` | Front Door profile SKU. | string | `"Standard_AzureFrontDoor"` | |
| 36 | +| `cdn_endpoint_name` | Front Door endpoint name. | string | `"cdn-media-dev-001"` | |
| 37 | +| `origin_host` | Origin hostname (no scheme/path). | string | `"myorigin.example.com"` | |
| 38 | +| `tags` | Tags applied to supported resources. | map(string) | `{ env = "dev" }` | |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +1. Authenticate: |
| 43 | + |
| 44 | + ```sh |
| 45 | + az login |
| 46 | + ``` |
| 47 | + |
| 48 | +2. (Optional) Select subscription: |
| 49 | + |
| 50 | + ```sh |
| 51 | + az account set --subscription "<subscription-id-or-name>" |
| 52 | + ``` |
| 53 | + |
| 54 | +3. Initialize: |
| 55 | + |
| 56 | + ```sh |
| 57 | + terraform init -upgrade |
| 58 | + ``` |
| 59 | + |
| 60 | +4. Validate and plan: |
| 61 | + |
| 62 | + ```sh |
| 63 | + terraform validate |
| 64 | + terraform plan |
| 65 | + ``` |
| 66 | + |
| 67 | +5. Apply: |
| 68 | + |
| 69 | + ```sh |
| 70 | + terraform apply -auto-approve |
| 71 | + ``` |
| 72 | + |
| 73 | +## Outputs |
| 74 | + |
| 75 | +| Output Name | Description | |
| 76 | +| --- | --- | |
| 77 | +| `cdn_profile_id` | The ID of the CDN profile. | |
| 78 | +| `cdn_endpoint_id` | The ID of the CDN endpoint. | |
| 79 | +| `cdn_endpoint_host_name` | The host name (FQDN) of the CDN endpoint. | |
| 80 | + |
| 81 | +<!-- START BADGE --> |
| 82 | +<div align="center"> |
| 83 | + <img src="https://img.shields.io/badge/Total%20views-1646-limegreen" alt="Total views"> |
| 84 | + <p>Refresh Date: 2026-02-10</p> |
| 85 | +</div> |
| 86 | +<!-- END BADGE --> |
0 commit comments