From 6d64665474b0aaa440ed2b8672a56d25dd086f70 Mon Sep 17 00:00:00 2001 From: Rob Gil Date: Wed, 18 Dec 2019 18:45:25 -0500 Subject: [PATCH] 169163334 - Adds CDN module Basic CDN module with configurable origin. --- terraform/modules/cdn/main.tf | 31 ++++++++++++++++++++++++++++++ terraform/modules/cdn/outputs.tf | 0 terraform/modules/cdn/variables.tf | 31 ++++++++++++++++++++++++++++++ terraform/providers/dev/cdn.tf | 8 ++++++++ 4 files changed, 70 insertions(+) create mode 100644 terraform/modules/cdn/main.tf create mode 100644 terraform/modules/cdn/outputs.tf create mode 100644 terraform/modules/cdn/variables.tf create mode 100644 terraform/providers/dev/cdn.tf diff --git a/terraform/modules/cdn/main.tf b/terraform/modules/cdn/main.tf new file mode 100644 index 00000000..5debd443 --- /dev/null +++ b/terraform/modules/cdn/main.tf @@ -0,0 +1,31 @@ +resource "random_id" "server" { + keepers = { + azi_id = 1 + } + + byte_length = 8 +} + +resource "azurerm_resource_group" "cdn" { + name = "${var.name}-${var.environment}-cdn" + location = var.region +} + +resource "azurerm_cdn_profile" "cdn" { + name = "${var.name}-${var.environment}-profile" + location = azurerm_resource_group.cdn.location + resource_group_name = azurerm_resource_group.cdn.name + sku = var.sku +} + +resource "azurerm_cdn_endpoint" "cdn" { + name = "${var.name}-${var.environment}-${random_id.server.hex}" + profile_name = azurerm_cdn_profile.cdn.name + location = azurerm_resource_group.cdn.location + resource_group_name = azurerm_resource_group.cdn.name + + origin { + name = "${var.name}-${var.environment}-origin" + host_name = var.origin_host_name + } +} diff --git a/terraform/modules/cdn/outputs.tf b/terraform/modules/cdn/outputs.tf new file mode 100644 index 00000000..e69de29b diff --git a/terraform/modules/cdn/variables.tf b/terraform/modules/cdn/variables.tf new file mode 100644 index 00000000..a026ffed --- /dev/null +++ b/terraform/modules/cdn/variables.tf @@ -0,0 +1,31 @@ +variable "region" { + type = string + description = "Region this module and resources will be created in" +} + +variable "name" { + type = string + description = "Unique name for the services in this module" +} + +variable "environment" { + type = string + description = "Environment these resources reside (prod, dev, staging, etc)" +} + +variable "owner" { + type = string + description = "Owner of the environment and resources created in this module" +} + +variable "sku" { + type = string + description = "SKU of which CDN to use" + default = "Standard_Verizon" +} + +variable "origin_host_name" { + type = string + description = "Subdomain to use for the origin in requests to the CDN" +} + diff --git a/terraform/providers/dev/cdn.tf b/terraform/providers/dev/cdn.tf new file mode 100644 index 00000000..3b379b90 --- /dev/null +++ b/terraform/providers/dev/cdn.tf @@ -0,0 +1,8 @@ +module "cdn" { + source = "../../modules/cdn" + origin_host_name = "staging.atat.code.mil" + owner = var.owner + environment = var.environment + name = var.name + region = var.region +}