1

I am attempting to provision multiple origins, which are storage accounts (blobs) in different regions. Whilst provisioning the CDN profiles (multiple environments) and a single origin for each is straightforward, the following error (which I assume is from Azure itself) is shown during "apply" the provisioning of multiple origins using a dynamic block. Note that "plan" runs without any issues.

Error: creating Endpoint: (Name "cdn-endpoint-qa-ibkh" / Profile Name "cdn-qa-ibkh" / Resource Group "rg-cdns-ibkh"): cdn.EndpointsClient#Create: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="In order to enable Multi-Origin on this endpoint, please set DefaultOriginGroup." │ │ with module.content_cdns[1].azurerm_cdn_endpoint.default, │ on modules/azure_cdns/cdn.tf line 23, in resource "azurerm_cdn_endpoint" "default": │ 23: resource "azurerm_cdn_endpoint" "default" {

The key section of the above is "In order to enable Multi-Origin on this endpoint, please set DefaultOriginGroup". I cannot find any documentation or examples about creating or setting the DefaultOriginGroup in Terraform.

Here is a copy of the code for the creation of multiple endpoints.

resource "azurerm_cdn_endpoint" "default" {
  name                          = var.cdn_endpoint_name
  profile_name                  = azurerm_cdn_profile.default.name
  location                      = "global"
  querystring_caching_behaviour = "IgnoreQueryString"
  is_http_allowed               = true
  is_compression_enabled        = false
  
  dynamic "origin" {
    for_each = var.azure_locations_cli
    content {
      name      = "${origin.value}-origin"
      host_name = "${replace(var.storage_account_name, "%%LOCATION%%", origin.value)}.blob.core.windows.net"
    }
  }
  
  tags = var.cdn_tags
  depends_on = [azurerm_cdn_profile.default]
  
}
  

I know that there is probably a workaround using local exec with Azure CLI, but I'd prefer not to use that unless there is no other option.

I am missing something blindingly obvious, or have I encountered something not yet fully supported by the Azure provider in Terraform?

Any advice or examples are greatly appreciated; thanks in advance.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.