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

[New Resource:] azurerm_cdn_frontdoor_custom_domain_association - rework associations with azurerm_cdn_frontdoor_route #18600

Merged
merged 61 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
46e2144
Initial check-in...
WodansSon Sep 30, 2022
fcb98e0
Churn while I work out the logic...
WodansSon Oct 1, 2022
bfb6235
So close...
WodansSon Oct 3, 2022
d17d5cc
Fix lint error...
WodansSon Oct 3, 2022
f8d3b0d
Fix case sensitivity and move toward association
WodansSon Oct 5, 2022
aa144c7
Merge branch 'main' into b_frontdoor_custom_domains
WodansSon Oct 5, 2022
9aaf01e
Merge branch 'main' of https://github.com/hashicorp/terraform-provide…
WodansSon Oct 6, 2022
6ad1250
Almost there... total redesign...
WodansSon Oct 6, 2022
3736a07
Done... now write test cases...
WodansSon Oct 7, 2022
a435800
Last of the case insensitive fix...
WodansSon Oct 7, 2022
f6bb268
Add nil checks to helper functions
WodansSon Oct 7, 2022
2ccf477
Fix race condition with route resource
WodansSon Oct 7, 2022
fc960fe
Add note to docs for route race condition
WodansSon Oct 8, 2022
1342d3c
Add third route to example
WodansSon Oct 8, 2022
4e6ee62
Fix lint error
WodansSon Oct 8, 2022
6113701
terrafmt
WodansSon Oct 8, 2022
f57c8a4
Fix up some loose ends and test cases
WodansSon Oct 9, 2022
e2bc53c
Fix comment spacing
WodansSon Oct 9, 2022
a64c107
Terrafmt test
WodansSon Oct 9, 2022
e46d4c7
Remove import check for association
WodansSon Oct 10, 2022
bed92ba
last minute changes
WodansSon Oct 10, 2022
9042993
Remove associate_with_cdn_frontdoor_route_id
WodansSon Oct 11, 2022
c3341da
remove validation from read func
WodansSon Oct 11, 2022
e128c68
refactor disable link resource
WodansSon Oct 12, 2022
2dc3833
Update nil error message
WodansSon Oct 12, 2022
87ef090
fix typo in var name
WodansSon Oct 12, 2022
fd01df8
Update website/docs/r/cdn_frontdoor_route_disable_link_to_default_dom…
WodansSon Oct 12, 2022
367c149
Update website/docs/r/cdn_frontdoor_route.html.markdown
WodansSon Oct 12, 2022
df9d442
Update website/docs/r/cdn_frontdoor_custom_domain_association.html.ma…
WodansSon Oct 12, 2022
84a11f9
Update website/docs/r/cdn_frontdoor_custom_domain_association.html.ma…
WodansSon Oct 12, 2022
ab0845e
Update internal/services/cdn/cdn_frontdoor_custom_domain_association_…
WodansSon Oct 13, 2022
a0d7881
Update internal/services/cdn/cdn_frontdoor_custom_domain_association_…
WodansSon Oct 13, 2022
88e1d0b
Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go
WodansSon Oct 13, 2022
2d8a224
Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go
WodansSon Oct 13, 2022
b9c1245
Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go
WodansSon Oct 13, 2022
d0a0cfe
Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go
WodansSon Oct 13, 2022
b48f8f6
Update internal/services/cdn/cdn_frontdoor_custom_domain_resource.go
WodansSon Oct 13, 2022
ec1f6aa
Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go
WodansSon Oct 13, 2022
1665107
Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go
WodansSon Oct 13, 2022
d387a0e
Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go
WodansSon Oct 13, 2022
f789e03
Update internal/services/cdn/cdn_frontdoor_endpoint_resource.go
WodansSon Oct 13, 2022
dcae3cf
Update internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go
WodansSon Oct 13, 2022
0ac6010
Update internal/services/cdn/cdn_frontdoor_firewall_policy_resource.go
WodansSon Oct 13, 2022
8a0779a
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
acb73d0
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
7b8b1bf
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
04caf16
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
954f74c
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
89cdf25
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
6f0bad3
Update internal/services/cdn/cdn_frontdoor_helpers.go
WodansSon Oct 13, 2022
3f87506
Update internal/services/cdn/cdn_frontdoor_origin_group_resource.go
WodansSon Oct 13, 2022
bf212b3
Update internal/services/cdn/cdn_frontdoor_origin_group_resource.go
WodansSon Oct 13, 2022
7c26b1c
Update internal/services/cdn/cdn_frontdoor_origin_group_resource.go
WodansSon Oct 13, 2022
c213b05
Update website/docs/r/cdn_frontdoor_custom_domain_association.html.ma…
WodansSon Oct 13, 2022
e18037e
remove all Insensitively from resource
WodansSon Oct 13, 2022
dc44953
Update website/docs/r/cdn_frontdoor_custom_domain_association.html.ma…
WodansSon Oct 13, 2022
1a281aa
Address PR comments
WodansSon Oct 13, 2022
6163ae6
Merge branch 'b_frontdoor_custom_domains' of https://github.com/hashi…
WodansSon Oct 13, 2022
ba54943
Fix frontmatter issue with doc
WodansSon Oct 13, 2022
fa1939f
Remove extra space from H1
WodansSon Oct 13, 2022
0572a38
remove friendly parse function
WodansSon Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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