diff --git a/main.tf b/main.tf index 7e8d5c6..64a5e73 100644 --- a/main.tf +++ b/main.tf @@ -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 ? [{}] : [] } @@ -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, ) } @@ -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" @@ -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 diff --git a/variables.tf b/variables.tf index b4aacc2..9c2f1e2 100644 --- a/variables.tf +++ b/variables.tf @@ -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 = ""