Skip to content

Commit

Permalink
including #18600 fixes #18598 #18613 and #18656
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
WodansSon and tombuildsstuff authored Oct 14, 2022
1 parent 6219316 commit 281c710
Show file tree
Hide file tree
Showing 34 changed files with 1,742 additions and 1,314 deletions.
58 changes: 29 additions & 29 deletions examples/cdn/frontdoor/frontdoor-cmk-byoc-custom-domain/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,48 @@ resource "azurerm_cdn_frontdoor_security_policy" "example" {
}
}

resource "azurerm_cdn_frontdoor_route" "example" {
name = "${var.prefix}-route"
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.example.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.example.id]
enabled = true

https_redirect_enabled = true
forwarding_protocol = "HttpsOnly"
patterns_to_match = ["/*"]
supported_protocols = ["Http", "Https"]
cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.example.id]

cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id]
link_to_default_domain = false

cache {
compression_enabled = true
content_types_to_compress = ["text/html", "text/javascript", "text/xml"]
query_strings = ["account", "settings", "foo", "bar"]
query_string_caching_behavior = "IgnoreSpecifiedQueryStrings"
}
}

resource "azurerm_cdn_frontdoor_custom_domain" "contoso" {
name = "${var.prefix}-custom-domain"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
dns_zone_id = azurerm_dns_zone.example.id
host_name = join(".", ["contoso", azurerm_dns_zone.example.name])

associate_with_cdn_frontdoor_route_id = azurerm_cdn_frontdoor_route.example.id

tls {
certificate_type = "CustomerCertificate"
minimum_tls_version = "TLS12"
cdn_frontdoor_secret_id = azurerm_cdn_frontdoor_secret.example.id
}
}

resource "azurerm_cdn_frontdoor_custom_domain_association" "contoso" {
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.contoso.id
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
}

resource "azurerm_dns_txt_record" "contoso" {
name = join(".", ["_dnsauth", "contoso"])
zone_name = azurerm_dns_zone.example.name
Expand All @@ -314,33 +341,6 @@ resource "azurerm_dns_txt_record" "contoso" {
}
}

resource "azurerm_cdn_frontdoor_route" "example" {
name = "${var.prefix}-route"
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.example.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.example.id]
enabled = true

https_redirect_enabled = true
forwarding_protocol = "HttpsOnly"

patterns_to_match = ["/*"]
supported_protocols = ["Http", "Https"]
cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.example.id]

cache {
compression_enabled = true
content_types_to_compress = ["text/html", "text/javascript", "text/xml"]
query_strings = ["account", "settings", "foo", "bar"]
query_string_caching_behavior = "IgnoreSpecifiedQueryStrings"
}
}

resource "azurerm_cdn_frontdoor_route_disable_link_to_default_domain" "example" {
cdn_frontdoor_route_id = azurerm_cdn_frontdoor_route.example.id
cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id]
}

resource "azurerm_dns_cname_record" "contoso" {
depends_on = [azurerm_cdn_frontdoor_route.example, azurerm_cdn_frontdoor_security_policy.example]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ resource "azurerm_cdn_frontdoor_route" "example" {
supported_protocols = ["Http", "Https"]
cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.example.id]

cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id, azurerm_cdn_frontdoor_custom_domain.fabrikam.id]
link_to_default_domain = false

cache {
compression_enabled = true
content_types_to_compress = ["text/html", "text/javascript", "text/xml"]
Expand All @@ -231,19 +234,12 @@ resource "azurerm_cdn_frontdoor_route" "example" {
}
}

resource "azurerm_cdn_frontdoor_route_disable_link_to_default_domain" "example" {
cdn_frontdoor_route_id = azurerm_cdn_frontdoor_route.example.id
cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id, azurerm_cdn_frontdoor_custom_domain.fabrikam.id]
}

resource "azurerm_cdn_frontdoor_custom_domain" "contoso" {
name = "${var.prefix}-contoso-custom-domain"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
dns_zone_id = azurerm_dns_zone.example.id
host_name = join(".", ["contoso", azurerm_dns_zone.example.name])

associate_with_cdn_frontdoor_route_id = azurerm_cdn_frontdoor_route.example.id

tls {
certificate_type = "ManagedCertificate"
minimum_tls_version = "TLS12"
Expand All @@ -256,14 +252,22 @@ resource "azurerm_cdn_frontdoor_custom_domain" "fabrikam" {
dns_zone_id = azurerm_dns_zone.example.id
host_name = join(".", ["fabrikam", azurerm_dns_zone.example.name])

associate_with_cdn_frontdoor_route_id = azurerm_cdn_frontdoor_route.example.id

tls {
certificate_type = "ManagedCertificate"
minimum_tls_version = "TLS12"
}
}

resource "azurerm_cdn_frontdoor_custom_domain_association" "contoso" {
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.contoso.id
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
}

resource "azurerm_cdn_frontdoor_custom_domain_association" "fabrikam" {
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.fabrikam.id
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
}

resource "azurerm_dns_txt_record" "contoso" {
name = join(".", ["_dnsauth", "contoso"])
zone_name = azurerm_dns_zone.example.name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cdn

import (
"context"
"fmt"

"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
)

func importCdnFrontDoorCustomDomainAssociation() pluginsdk.ImporterFunc {
return func(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) (data []*pluginsdk.ResourceData, err error) {
id, err := parse.FrontDoorCustomDomainAssociationID(d.Id())
if err != nil {
return []*pluginsdk.ResourceData{}, err
}

client := meta.(*clients.Client).Cdn.FrontDoorCustomDomainsClient
resp, err := client.Get(ctx, id.ResourceGroup, id.ProfileName, id.AssociationName)
if err != nil {
return []*pluginsdk.ResourceData{}, fmt.Errorf("retrieving %s: %+v", id, err)
}

if resp.AFDDomainProperties == nil {
return []*pluginsdk.ResourceData{}, fmt.Errorf("retrieving %s: `AFDDomainProperties` was nil", id)
}

return []*pluginsdk.ResourceData{d}, nil
}
}
Loading

0 comments on commit 281c710

Please sign in to comment.