terraform-provider-azurerm
terraform-provider-azurerm copied to clipboard
Error "Cannot disable or delete the last origin when the origin group is still associated with a route or a rule. Please disassociate the origin group and try again."
trafficstars
Is there an existing issue for this?
- [X] I have searched the existing issues
Community Note
- Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave comments along the lines of "+1", "me too" or "any updates", 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 and review the contribution guide to help.
Issue
Updating the name of the resource azurerm_cdn_frontdoor_origin, along with updating the attribute host_name causes the resource to be recreated. However, Terraform fails with an error.
Consequence: The new origin is added to the origin group while the old origin remains present.
Fix: Running terraform apply again.
Terraform Version
1.9.7
AzureRM Provider Version
4.3.0
Affected Resource(s)/Data Source(s)
azurerm_cdn_frontdoor_origin
Terraform Configuration Files
Before:
resource "azurerm_cdn_frontdoor_origin" "fdo_old_name" {
(...)
host_name = "<old_hostname>"
(...)
}
resource "azurerm_cdn_frontdoor_route" "route" {
(..)
cdn_frontdoor_origin_ids = [
azurerm_cdn_frontdoor_origin.fdo_old_name.id
]
(...)
}
After:
resource "azurerm_cdn_frontdoor_origin" "fdo_new_name" {
(...)
host_name = "<new_hostname>"
(...)
}
resource "azurerm_cdn_frontdoor_route" "route" {
(..)
cdn_frontdoor_origin_ids = [
azurerm_cdn_frontdoor_origin.fdo_new_name.id
]
(...)
}
Debug Output/Panic Output
Error: deleting Front Door Origin: (Origin Name "<old_name>" / Origin Group Name "---REDACTED---" / Profile Name "---REDACTED---" / Resource Group "---REDACTED---"): cdn.AFDOriginsClient#Delete: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="Cannot disable or delete the last origin when the origin group is still associated with a route or a rule. Please disassociate the origin group and try again."
Expected Behaviour
Terraform should be able to replace the resource in-place.
Actual Behaviour
Terraform failed to update the resource on the first apply, and needed a second one to finalize the state.
Steps to Reproduce
Simply run a terraform apply.
Important Factoids
No response
References
No response