Skip to content

Commit c041d71

Browse files
authored
sample cdn template
1 parent 22400ea commit c041d71

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

3_networking/cdn/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# main.tf
2+
# This file contains the main configuration for creating an Azure CDN Profile and Endpoint.
3+
4+
# Resource Group
5+
resource "azurerm_resource_group" "cdn" {
6+
name = var.resource_group_name
7+
location = var.location
8+
}
9+
10+
# CDN Profile
11+
resource "azurerm_cdn_profile" "cdn" {
12+
name = var.cdn_profile_name
13+
location = azurerm_resource_group.cdn.location
14+
resource_group_name = azurerm_resource_group.cdn.name
15+
sku = var.cdn_sku
16+
tags = var.tags
17+
}
18+
19+
# CDN Endpoint
20+
resource "azurerm_cdn_endpoint" "cdn" {
21+
name = var.cdn_endpoint_name
22+
profile_name = azurerm_cdn_profile.cdn.name
23+
location = azurerm_resource_group.cdn.location
24+
resource_group_name = azurerm_resource_group.cdn.name
25+
origin_host_header = var.origin_host
26+
is_http_allowed = true
27+
is_https_allowed = true
28+
29+
origin {
30+
name = "origin1"
31+
host_name = var.origin_host
32+
http_port = 80
33+
https_port = 443
34+
}
35+
}

3_networking/cdn/outputs.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# outputs.tf
2+
# This file defines the outputs for the Azure CDN configuration.
3+
4+
output "cdn_profile_id" {
5+
description = "The ID of the CDN profile"
6+
value = azurerm_cdn_profile.cdn.id
7+
}
8+
9+
output "cdn_endpoint_id" {
10+
description = "The ID of the CDN endpoint"
11+
value = azurerm_cdn_endpoint.cdn.id
12+
}

3_networking/cdn/provider.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# provider.tf
2+
# This file configures the Azure provider to interact with Azure resources.
3+
# It specifies the required provider and its version, along with provider-specific configurations.
4+
5+
terraform {
6+
required_version = ">= 1.8, < 2.0"
7+
# Specify the required provider and its version
8+
required_providers {
9+
azurerm = {
10+
source = "hashicorp/azurerm" # Source of the AzureRM provider
11+
version = "~> 4.16.0" # Version of the AzureRM provider
12+
}
13+
}
14+
}
15+
16+
provider "azurerm" {
17+
features {} # Enable all features for the AzureRM provider
18+
subscription_id = var.subscription_id # Use the subscription ID variable
19+
}

3_networking/cdn/terraform.tfvars

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# terraform.tfvars
2+
# This file provides default values for the variables defined in variables.tf.
3+
# These values can be overridden by specifying different values during Terraform execution.
4+
5+
# Azure Subscription
6+
subscription_id = "" # "your-subscription-id"
7+
8+
# Resource Group
9+
resource_group_name = "RG-cdn-test"
10+
location = "eastus"
11+
12+
# CDN Configuration
13+
cdn_profile_name = "mycdnprofiletestbr"
14+
cdn_sku = "Standard_Microsoft"
15+
cdn_endpoint_name = "mycdnendpointtestbr"
16+
origin_host = "myorigintestbr.example.com"
17+
tags = {
18+
Environment = "CDN"
19+
Owner = "IT"
20+
}

3_networking/cdn/variables.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# variables.tf
2+
# This file defines the input variables used in the Terraform configuration.
3+
4+
variable "subscription_id" {
5+
description = "The Azure subscription ID"
6+
type = string
7+
}
8+
9+
variable "resource_group_name" {
10+
description = "The name of the resource group"
11+
type = string
12+
}
13+
14+
variable "location" {
15+
description = "The Azure region to deploy resources"
16+
type = string
17+
}
18+
19+
variable "cdn_profile_name" {
20+
description = "The name of the CDN profile"
21+
type = string
22+
}
23+
24+
variable "cdn_sku" {
25+
description = "The SKU for the CDN profile (Standard_Microsoft, Standard_Akamai, Standard_Verizon, Premium_Verizon)"
26+
type = string
27+
default = "Standard_Microsoft"
28+
}
29+
30+
variable "cdn_endpoint_name" {
31+
description = "The name of the CDN endpoint"
32+
type = string
33+
}
34+
35+
variable "origin_host" {
36+
description = "The hostname of the origin server"
37+
type = string
38+
}
39+
40+
variable "tags" {
41+
description = "A map of tags to assign to resources"
42+
type = map(string)
43+
default = {}
44+
}

0 commit comments

Comments
 (0)