<p>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 &quot;apply&quot; the provisioning of multiple origins using a dynamic block. Note that &quot;plan&quot; runs without any issues.</p>
<blockquote>
<p>Error: creating Endpoint: (Name &quot;cdn-endpoint-qa-ibkh&quot; / Profile Name &quot;cdn-qa-ibkh&quot; / Resource Group &quot;rg-cdns-ibkh&quot;): cdn.EndpointsClient#Create: Failure sending request: StatusCode=400 -- Original Error: Code=&quot;BadRequest&quot; Message=&quot;In order to enable Multi-Origin on this endpoint, please set DefaultOriginGroup.&quot;
│
│   with module.content_cdns[1].azurerm_cdn_endpoint.default,
│   on modules/azure_cdns/cdn.tf line 23, in resource &quot;azurerm_cdn_endpoint&quot; &quot;default&quot;:
│   23: resource &quot;azurerm_cdn_endpoint&quot; &quot;default&quot; {</p>
</blockquote>
<p>The key section of the above is &quot;In order to enable Multi-Origin on this endpoint, please set DefaultOriginGroup&quot;. I cannot find any documentation or examples about creating or setting the DefaultOriginGroup in Terraform.</p>
<p>Here is a copy of the code for the creation of multiple endpoints.</p>
<pre><code>resource &quot;azurerm_cdn_endpoint&quot; &quot;default&quot; {
  name                          = var.cdn_endpoint_name
  profile_name                  = azurerm_cdn_profile.default.name
  location                      = &quot;global&quot;
  querystring_caching_behaviour = &quot;IgnoreQueryString&quot;
  is_http_allowed               = true
  is_compression_enabled        = false
  
  dynamic &quot;origin&quot; {
    for_each = var.azure_locations_cli
    content {
      name      = &quot;${origin.value}-origin&quot;
      host_name = &quot;${replace(var.storage_account_name, &quot;%%LOCATION%%&quot;, origin.value)}.blob.core.windows.net&quot;
    }
  }
  
  tags = var.cdn_tags
  depends_on = [azurerm_cdn_profile.default]
  
}
  
</code></pre>
<p>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.</p>
<p>I am missing something blindingly obvious, or have I encountered something not yet fully supported by the Azure provider in Terraform?</p>
<p>Any advice or examples are greatly appreciated; thanks in advance.</p>

CC BY-SA 4.0
2022-03-24T15:11:24.080Z
This is not yet possible, since it requires an origin group. There is an open issue where you can vote though: https://github.com/hashicorp/terraform-provider-azurerm/issues/10771.
michidk
CC BY-SA 4.0
2022-11-03T03:32:13.157Z
Looks like there's no way of creating multiple cdn origins or default origin group in terraform. Here's the issue in github: https://github.com/hashicorp/terraform-provider-azurerm/issues/10771
Daniel Fajardo Valenti
<terraform><azure><terraform-module><cdn>
Creating Multi-Origin endpoint groups in Azure using Terraform
BigotesDeGato
# Creating Multi-Origin endpoint groups in Azure using Terraform

(Asked by: username_0 on 2022-01-17)

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.

**Tags:** terraform, azure, terraform-module, cdn

> **Comments:**
> **username_1**: This is not yet possible, since it requires an origin group. There is an open issue where you can vote though: https://github.com/hashicorp/terraform-provider-azurerm/issues/10771.  
> **username_2**: Looks like there's no way of creating multiple cdn origins or default origin group in terraform. Here's the issue in github: https://github.com/hashicorp/terraform-provider-azurerm/issues/10771  

---

## 0 answers

