From 27dd819a169aea39b665d04cffa15c6ebbd1e825 Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Fri, 13 Jun 2025 06:05:24 -0600 Subject: [PATCH 1/4] cdn overview --- 3_networking/cdn/README.md | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 3_networking/cdn/README.md diff --git a/3_networking/cdn/README.md b/3_networking/cdn/README.md new file mode 100644 index 0000000..6f0d43e --- /dev/null +++ b/3_networking/cdn/README.md @@ -0,0 +1,62 @@ +# Terraform Template - Azure CDN (Content Delivery Network) + +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 CDN profile and endpoint. + +

+ image +

+ + +## File Descriptions + +- **main.tf**: Contains the main configuration for creating the Azure CDN profile and endpoint. +- **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 CDN profile ID and endpoint host name. + +## Variables + +| 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 | `"RG-cdn-test"` | +| `location` | The Azure region to deploy resources | string | `"eastus"` | +| `cdn_profile_name` | The name of the CDN profile | string | `"mycdnprofile"` | +| `cdn_sku` | The SKU for the CDN profile | string | `"Standard_Microsoft"` | +| `cdn_endpoint_name` | The name of the CDN endpoint | string | `"mycdnendpoint"` | +| `origin_host` | The hostname of the origin server | string | `"myorigin.example.com"` | +| `tags` | A map of tags to assign to resources | map | `{ Environment = "CDN", Owner = "IT" }` | + +## Usage + +1. Clone the repository and navigate to the cdn 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 | +|-------------------------|---------------------------------------------| +| `cdn_profile_id` | The ID of the CDN profile | +| `cdn_endpoint_id` | The ID of the CDN endpoint | +| `cdn_endpoint_host_name`| The host name of the CDN endpoint | + +
+

Total Visitors

+ Visitor Count +
From 92af7b8f0bf9e6cc653d9c717ab9e8fb79212008 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Jun 2025 12:05:44 +0000 Subject: [PATCH 2/4] Update last modified date in Markdown files --- 3_networking/cdn/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3_networking/cdn/README.md b/3_networking/cdn/README.md index 6f0d43e..6afe4af 100644 --- a/3_networking/cdn/README.md +++ b/3_networking/cdn/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-13 ---------- From 8b9a28455bfd1f0ad2592037ba22b0df373ce6fe Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Fri, 13 Jun 2025 06:07:16 -0600 Subject: [PATCH 3/4] img --- 3_networking/cdn/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3_networking/cdn/README.md b/3_networking/cdn/README.md index 6afe4af..626e935 100644 --- a/3_networking/cdn/README.md +++ b/3_networking/cdn/README.md @@ -12,7 +12,7 @@ Last updated: 2025-06-13 > This template contains Terraform configurations to create and manage an Azure CDN profile and endpoint.

- image + image

From c041d715e2a4c25857b7a521be755d5bf53a15d8 Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Fri, 13 Jun 2025 06:07:55 -0600 Subject: [PATCH 4/4] sample cdn template --- 3_networking/cdn/main.tf | 35 ++++++++++++++++++++++++ 3_networking/cdn/outputs.tf | 12 +++++++++ 3_networking/cdn/provider.tf | 19 +++++++++++++ 3_networking/cdn/terraform.tfvars | 20 ++++++++++++++ 3_networking/cdn/variables.tf | 44 +++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 3_networking/cdn/main.tf create mode 100644 3_networking/cdn/outputs.tf create mode 100644 3_networking/cdn/provider.tf create mode 100644 3_networking/cdn/terraform.tfvars create mode 100644 3_networking/cdn/variables.tf diff --git a/3_networking/cdn/main.tf b/3_networking/cdn/main.tf new file mode 100644 index 0000000..7ed7c01 --- /dev/null +++ b/3_networking/cdn/main.tf @@ -0,0 +1,35 @@ +# main.tf +# This file contains the main configuration for creating an Azure CDN Profile and Endpoint. + +# Resource Group +resource "azurerm_resource_group" "cdn" { + name = var.resource_group_name + location = var.location +} + +# CDN Profile +resource "azurerm_cdn_profile" "cdn" { + name = var.cdn_profile_name + location = azurerm_resource_group.cdn.location + resource_group_name = azurerm_resource_group.cdn.name + sku = var.cdn_sku + tags = var.tags +} + +# CDN Endpoint +resource "azurerm_cdn_endpoint" "cdn" { + name = var.cdn_endpoint_name + profile_name = azurerm_cdn_profile.cdn.name + location = azurerm_resource_group.cdn.location + resource_group_name = azurerm_resource_group.cdn.name + origin_host_header = var.origin_host + is_http_allowed = true + is_https_allowed = true + + origin { + name = "origin1" + host_name = var.origin_host + http_port = 80 + https_port = 443 + } +} \ No newline at end of file diff --git a/3_networking/cdn/outputs.tf b/3_networking/cdn/outputs.tf new file mode 100644 index 0000000..d0d0fe8 --- /dev/null +++ b/3_networking/cdn/outputs.tf @@ -0,0 +1,12 @@ +# outputs.tf +# This file defines the outputs for the Azure CDN configuration. + +output "cdn_profile_id" { + description = "The ID of the CDN profile" + value = azurerm_cdn_profile.cdn.id +} + +output "cdn_endpoint_id" { + description = "The ID of the CDN endpoint" + value = azurerm_cdn_endpoint.cdn.id +} diff --git a/3_networking/cdn/provider.tf b/3_networking/cdn/provider.tf new file mode 100644 index 0000000..f3f9b2d --- /dev/null +++ b/3_networking/cdn/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/cdn/terraform.tfvars b/3_networking/cdn/terraform.tfvars new file mode 100644 index 0000000..5804aee --- /dev/null +++ b/3_networking/cdn/terraform.tfvars @@ -0,0 +1,20 @@ +# 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-cdn-test" +location = "eastus" + +# CDN Configuration +cdn_profile_name = "mycdnprofiletestbr" +cdn_sku = "Standard_Microsoft" +cdn_endpoint_name = "mycdnendpointtestbr" +origin_host = "myorigintestbr.example.com" +tags = { + Environment = "CDN" + Owner = "IT" +} \ No newline at end of file diff --git a/3_networking/cdn/variables.tf b/3_networking/cdn/variables.tf new file mode 100644 index 0000000..4900e20 --- /dev/null +++ b/3_networking/cdn/variables.tf @@ -0,0 +1,44 @@ +# 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 "cdn_profile_name" { + description = "The name of the CDN profile" + type = string +} + +variable "cdn_sku" { + description = "The SKU for the CDN profile (Standard_Microsoft, Standard_Akamai, Standard_Verizon, Premium_Verizon)" + type = string + default = "Standard_Microsoft" +} + +variable "cdn_endpoint_name" { + description = "The name of the CDN endpoint" + type = string +} + +variable "origin_host" { + description = "The hostname of the origin server" + type = string +} + +variable "tags" { + description = "A map of tags to assign to resources" + type = map(string) + default = {} +} \ No newline at end of file