-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_frontdoor_route_disable_link_to_default_domain not working as expected - execution order issue? #18656
Comments
@slime-uk, thank you for opening this issue. This resource is very difficult to shoehorn into Terraform because the API and Terraform are diametrically opposed to how they work. I understand your frustration with the |
@WodansSon Thank you for the detailed reply and explanation which I do sort of follow! Also, many thanks for all the hard work getting the new AzFD resources into TF AzureRM provider! Many many thanks. FYI - For now, I have removed the "azurerm_cdn_frontdoor_route_disable_link_to_default_domain" resource from our TF configuration and have restored our AzAPI implementation which after all the above code then "patches" the existing (TF created now) AzFD routes and does the new associations to the custom domains and disables the links to default domain - this is working very well.
Again, many thanks! |
* Initial check-in... * Churn while I work out the logic... * So close... * Fix lint error... * Fix case sensitivity and move toward association * Almost there... total redesign... * Done... now write test cases... * Last of the case insensitive fix... * Add nil checks to helper functions * Fix race condition with route resource * Add note to docs for route race condition * Add third route to example * Fix lint error * terrafmt * Fix up some loose ends and test cases * Fix comment spacing * Terrafmt test * Remove import check for association * last minute changes * Remove associate_with_cdn_frontdoor_route_id * remove validation from read func * refactor disable link resource * Update nil error message * fix typo in var name * Update website/docs/r/cdn_frontdoor_route_disable_link_to_default_domain.html.markdown Co-authored-by: Tom Harvey <[email protected]> * Update website/docs/r/cdn_frontdoor_route.html.markdown Co-authored-by: Tom Harvey <[email protected]> * Update website/docs/r/cdn_frontdoor_custom_domain_association.html.markdown Co-authored-by: Tom Harvey <[email protected]> * Update website/docs/r/cdn_frontdoor_custom_domain_association.html.markdown Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_association_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_association_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_helpers.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_origin_group_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_origin_group_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update internal/services/cdn/cdn_frontdoor_origin_group_resource.go Co-authored-by: Tom Harvey <[email protected]> * Update website/docs/r/cdn_frontdoor_custom_domain_association.html.markdown Co-authored-by: Tom Harvey <[email protected]> * remove all Insensitively from resource * Update website/docs/r/cdn_frontdoor_custom_domain_association.html.markdown Co-authored-by: Tom Harvey <[email protected]> * Address PR comments * Fix frontmatter issue with doc * Remove extra space from H1 * remove friendly parse function Co-authored-by: Tom Harvey <[email protected]>
This functionality has been released in v3.27.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Hi @WodansSon After seeing and reading your latest PR, and v3.27.0 provider change log, I removed our last remaining AzAPI resource and added in new resource "azurerm_cdn_frontdoor_custom_domain_association" "example-afd-origingrp-routes-cd-assoc" to manage the custom domain to route associations. I uplifted to 3.27.0 and changed my map of routes to custom domains, to be custom domains to AzFD routes: var.map_afd_doms_routes = { and also added this new resource block code:
On TFC plan, I am getting this crash in 3.27.0 provider:
The errors reported after that in TFC are:
When I create the AzFD route, I do not associate to any custom domains at that time, but I now say link to default = false. snippet of route resource block:
Any ideas? Is it because I've been trying other ways to solve this? Shall I tear the AzFD down completely and re-plan? Any thoughts? Thanks! |
An update - tearing AzFD down and re-planning did indeed work nicely - however the provider 3.27.0 is not working as expected. So, I now associate the routes to custom domains and also now using the new resource FYI - I have also tried to only define the AzFD routes and link to default domains and NOT associate with any custom domains but then later use new resource Ideally we'd like to (our use case) create the AzFD profile, origins, origin groups, routes (linked only to default domain if we must but prefer not appreciate the Azure portal doesn't allow this - routes must be associated to at least 1 domain), then create custom domains as and when and part of that process would also need to associate to existing routes as we define. Ideally we'd like to be able to also disable link_to_default_domain as and when too. We'd like to then also be able to remove a custom domain should we need to of course without error or needing to do 2 Terraform plans and applies in stages - which is the only workaround we have right now). |
Update - the deletion worked but it seems ONLY if when I create the routes I do also set link_to_default_domain = true in the route configuration as well as associate to all custom domains at that time, and also use the new resource This is so close - my only ask (please!) is why must we have a route associated to default domain for a custom domain to be deleted later successfully in one pass? |
Opened a new issue as requested! #18844 |
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. |
Is there an existing issue for this?
Community Note
Terraform Version
1.1.9
AzureRM Provider Version
3.25.0
Affected Resource(s)/Data Source(s)
azurerm_cdn_frontdoor_route_disable_link_to_default_domain
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
It's not 100% obvious to me what this TF resource "azurerm_cdn_frontdoor_route_disable_link_to_default_domain" does but based on the fact that while we were waiting for TF to support all the newer CDN Front Door resources, we were using native TF and mostly the Azure API (AzAPI provider). In that we were creating the AzFD profile, endpoint, routes, custom domains and then patching the route (using azapi_update_resource) to only then turn off link to default domain but also add in links to new custom domains. This worked well.
Based on that I was thinking/assuming that "azurerm_cdn_frontdoor_route_disable_link_to_default_domain" does the same thing? This is certainly what I was expecting...
So, we create the AzFD endpoint, routes (linked to default AzFD endpoint), custom domains and then try and use this new resource "azurerm_cdn_frontdoor_route_disable_link_to_default_domain" to do two things:
For_each route:
Actual Behaviour
However, it seems Azure objects and says you can't switch off link to default domain with no custom domains defined on the route. I'd agree but isn't this resource doing this both for us? Is it simply doing the two things in an invalid order? Should it be associating the custom domain to the route first and then (if successful), disabling link to default domain?
It seems to be doing it in this (invalid?)P order:
For_each route:
Steps to Reproduce
You will need some additional variables defined:
A string for the env prefix:
var.prefix = "sbx" for example, or "dev".
A set(string) of AzFD routes/regions to create as we want a single AzFD with multiple routes to AKS clusters in different regions
var.afd_regions = ["centralus", "westeurope"]
A set(string) of AzFD custom domains to create:
var.afd_domain_names = ["domain1", "domain2"]
A map(set(string)) of AzFD patterns to match for each route:
var.map_afd_routes_patterns = {
"centralus" = ["/example-cus/"]
"westeurope" = ["/example-we/"]
}
And a corresponding map of sets which maps required regions to AzFD routes per custom domains
var.map_afd_routes_doms = {
"centralus" = ["domain1", "domain2"]
"westeurope" = ["domain1"]
}
Create a PLS per region, PEs, istio load balancers and then then AzFD as per configuration.
Then TF plan (successful) and then apply.
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: