Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ locals {
coalescelist(azurerm_resource_group.rg.*.name, [var.resource_group_name]), 0)
location = element(
coalescelist(azurerm_resource_group.rg.*.location, [var.location]), 0)
cdn_location = coalesce(var.cdn_location, var.location)
if_static_website_enabled = var.enable_static_website ? [{}] : []
}

Expand Down Expand Up @@ -70,7 +71,7 @@ resource "azurerm_cdn_profile" "cdn-profile" {
count = var.enable_static_website && var.enable_cdn_profile ? 1 : 0
name = var.cdn_profile_name
resource_group_name = local.resource_group_name
location = local.location
location = local.cdn_location
sku = var.cdn_sku_profile
tags = merge({ "Name" = format("%s", var.cdn_profile_name) }, var.tags, )
}
Expand All @@ -86,7 +87,7 @@ resource "azurerm_cdn_endpoint" "cdn-endpoint" {
count = var.enable_static_website && var.enable_cdn_profile ? 1 : 0
name = random_string.unique.0.result
profile_name = azurerm_cdn_profile.cdn-profile.0.name
location = local.location
location = local.cdn_location
resource_group_name = local.resource_group_name
origin_host_header = azurerm_storage_account.storeacc.primary_web_host
querystring_caching_behaviour = "IgnoreQueryString"
Expand All @@ -99,7 +100,7 @@ resource "azurerm_cdn_endpoint" "cdn-endpoint" {
}

resource "null_resource" "add_custom_domain" {
count = var.custom_domain_name != null ? 1 : 0
count = var.custom_domain_name != null ? 1 : 0
triggers = { always_run = timestamp() }
depends_on = [
azurerm_cdn_endpoint.cdn-endpoint
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ variable "location" {
default = ""
}

variable "cdn_location" {
description = "The location of the CDN profile and endpoint. Will be defaulted to 'location' if not set. Possible values are global,australiaeast,australiasoutheast,brazilsouth,canadacentral,canadaeast,centralindia,centralus,eastasia,eastus,eastus2,japaneast,japanwest,northcentralus,northeurope,southcentralus,southindia,southeastasia,westeurope,westindia,westus,westcentralus"
default = null
}

variable "storage_account_name" {
description = "The name of the storage account to be created"
default = ""
Expand Down