Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_cdn_endpoint : OriginHostHeader must match the regex #8870

Closed
jfcoz opened this issue Oct 13, 2020 · 4 comments · Fixed by #11852
Closed

azurerm_cdn_endpoint : OriginHostHeader must match the regex #8870

jfcoz opened this issue Oct 13, 2020 · 4 comments · Fixed by #11852

Comments

@jfcoz
Copy link

jfcoz commented Oct 13, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.12.29
+ provider.azuread v0.11.0
+ provider.azurerm v2.22.0
+ provider.random v2.3.0
+ provider.tls v2.2.0

Affected Resource(s)

  • azurerm_cdn_endpoint

Terraform Configuration Files

From documentation :

origin_host_header - (Optional) The host header CDN provider will send along with content requests to origins. Defaults to the host name of the origin.

When using azurerm_cdn_endpoint without a origin_host_header we get this error.

Error: Error waiting for CDN Endpoint "…" (Profile "…" / Resource Group "…") to finish creating: Code="BadRequest" Message="{\"ErrorMessage\":\"Errors found in Model: OriginHostHeader must match the regex '(^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9_\\\\-]*[a-zA-Z0-9])\\\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\\\-]*[A-Za-z0-9])$)|((?:[:0-9A-Fa-f]+))'.\"}"

From https://docs.microsoft.com/en-us/rest/api/cdn/endpoints/create :

properties.originHostHeader | string | The host header value sent to the origin with each request. This property at Endpoint can only be set allowed when endpoint uses single origin. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default.

With origin_host_header = "", same error.

Manual setup via portal works.

References

@steve-88
Copy link

Any update on this? I want a blank origin_host_header but "" and null do not work

@rikribbers
Copy link
Contributor

ran into the same issue. in the API specs ( https://docs.microsoft.com/en-us/rest/api/cdn/endpoints/create )

The host header value sent to the origin with each request. This property at Endpoint can only be set allowed when endpoint uses single origin. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default.

So depending on your origin it is required.

katbyte pushed a commit that referenced this issue May 25, 2021
…_header` (#11852)

Confirmed with service team, the request payload can't contain an empty string for the origin_host_header, otherwise, the service will raise following error:

{
  "error": {
    "code": "BadRequest",
    "message": "OriginHostHeader \"\" is invalid. It must be a valid domain name, IP version 4, or IP version 6."
  }
}
Also update the document of this property to remove the line about default, since that is not true.

Meanwhile, this should fix some of the acctest failures.

Fixes #8870, #11107.
@katbyte katbyte added this to the v2.61.0 milestone May 25, 2021
@ghost
Copy link

ghost commented May 27, 2021

This has been released in version 2.61.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.61.0"
}
# ... other configuration ...

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants