From f945592aa735163a6357272a87f3596a0cc66032 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Wed, 16 Apr 2025 01:21:49 -0600 Subject: [PATCH 1/6] Initial Check-in... --- .../cdn/cdn_frontdoor_route_resource.go | 3 +- .../cdn/cdn_frontdoor_route_resource_test.go | 63 +++++++++++++++++++ .../docs/r/cdn_frontdoor_route.html.markdown | 24 ++++--- .../docs/r/cdn_frontdoor_rule.html.markdown | 34 +++++----- 4 files changed, 97 insertions(+), 27 deletions(-) diff --git a/internal/services/cdn/cdn_frontdoor_route_resource.go b/internal/services/cdn/cdn_frontdoor_route_resource.go index 18cfab538697..f1be9138193e 100644 --- a/internal/services/cdn/cdn_frontdoor_route_resource.go +++ b/internal/services/cdn/cdn_frontdoor_route_resource.go @@ -62,9 +62,10 @@ func resourceCdnFrontDoorRoute() *pluginsdk.Resource { // NOTE: These are not sent to the API, they are only here so Terraform // can provision/destroy the resources in the correct order. + // Made this field optional to address comments in Issue #29063 "cdn_frontdoor_origin_ids": { Type: pluginsdk.TypeList, - Required: true, + Optional: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, diff --git a/internal/services/cdn/cdn_frontdoor_route_resource_test.go b/internal/services/cdn/cdn_frontdoor_route_resource_test.go index 4cc187159ea9..a1bd7c2def73 100644 --- a/internal/services/cdn/cdn_frontdoor_route_resource_test.go +++ b/internal/services/cdn/cdn_frontdoor_route_resource_test.go @@ -36,6 +36,34 @@ func TestAccCdnFrontDoorRoute_basic(t *testing.T) { }) } +func TestAccCdnFrontDoorRoute_basicDependsOn(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cdn_frontdoor_route", "test") + r := CdnFrontDoorRouteResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basicDependsOn(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("cdn_frontdoor_origin_group_id"), + }) +} + +func TestAccCdnFrontDoorRoute_basicDependsOnAndField(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cdn_frontdoor_route", "test") + r := CdnFrontDoorRouteResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basicDependsOnAndField(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("cdn_frontdoor_origin_group_id", "cdn_frontdoor_origin_ids"), + }) +} + func TestAccCdnFrontDoorRoute_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cdn_frontdoor_route", "test") r := CdnFrontDoorRouteResource{} @@ -197,6 +225,41 @@ resource "azurerm_cdn_frontdoor_route" "test" { `, template, data.RandomInteger) } +func (r CdnFrontDoorRouteResource) basicDependsOn(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_cdn_frontdoor_route" "test" { + name = "accTestRoute-%d" + cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.test.id + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.test.id + patterns_to_match = ["/*"] + supported_protocols = ["Http", "Https"] + + depends_on = [azurerm_cdn_frontdoor_origin.test] +} +`, template, data.RandomInteger) +} + +func (r CdnFrontDoorRouteResource) basicDependsOnAndField(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_cdn_frontdoor_route" "test" { + name = "accTestRoute-%d" + cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.test.id + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.test.id + cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.test.id] + patterns_to_match = ["/*"] + supported_protocols = ["Http", "Https"] + + depends_on = [azurerm_cdn_frontdoor_origin.test] +} +`, template, data.RandomInteger) +} + func (r CdnFrontDoorRouteResource) requiresImport(data acceptance.TestData) string { config := r.basic(data) return fmt.Sprintf(` diff --git a/website/docs/r/cdn_frontdoor_route.html.markdown b/website/docs/r/cdn_frontdoor_route.html.markdown index 88b706940cec..e0f64fe24ca6 100644 --- a/website/docs/r/cdn_frontdoor_route.html.markdown +++ b/website/docs/r/cdn_frontdoor_route.html.markdown @@ -10,6 +10,8 @@ description: |- Manages a Front Door (standard/premium) Route. +!>**Note:** The `azurerm_cdn_frontdoor_route` resource must **explicitly** reference its associated `azurerm_cdn_frontdoor_origin` resource(s). This can be achieved either by using a `depends_on` meta-argument that points to the `azurerm_cdn_frontdoor_origin` resource(s), or by specifying the `azurerm_cdn_frontdoor_origin` IDs via the `cdn_frontdoor_origin_ids` field. + ## Example Usage ```hcl @@ -134,19 +136,23 @@ The following arguments are supported: * `cdn_frontdoor_origin_group_id` - (Required) The resource ID of the Front Door Origin Group where this Front Door Route should be created. -* `cdn_frontdoor_origin_ids` - (Required) One or more Front Door Origin resource IDs that this Front Door Route will link to. - -* `forwarding_protocol` - (Optional) The Protocol that will be use when forwarding traffic to backends. Possible values are `HttpOnly`, `HttpsOnly` or `MatchRequest`. Defaults to `MatchRequest`. - * `patterns_to_match` - (Required) The route patterns of the rule. * `supported_protocols` - (Required) One or more Protocols supported by this Front Door Route. Possible values are `Http` or `Https`. -~> **NOTE:** If `https_redirect_enabled` is set to `true` the `supported_protocols` field must contain both `Http` and `Https` values. +~> **Note:** If `https_redirect_enabled` is set to `true` the `supported_protocols` field must contain both `Http` and `Https` values. + +* `cdn_frontdoor_origin_ids` - (Optional) One or more Front Door Origin resource IDs for this Front Door Route. + +~> **Note:** The `cdn_frontdoor_origin_ids` field is not sent to the Azure API, it exists solely to ensure Terraform can manage the correct `provisioning` and `destruction` order of related resources. When importing an existing `azurerm_cdn_frontdoor_route` resource, you will need to manually add the `cdn_frontdoor_origin_ids` field to your configuration after the resource has been successfully imported. + +~> **Note:** If the `cdn_frontdoor_origin_ids` field is not defined in the configuration, you **must** use a `depends_on` meta-argument that references the corresponding `azurerm_cdn_frontdoor_origin` resource(s) for the route. When importing an existing `azurerm_cdn_frontdoor_route` resource from Azure, you will need to manually add the `depends_on` meta-argument to your configuration after the resource has been successfully imported. + +* `forwarding_protocol` - (Optional) The Protocol that will be use when forwarding traffic to backends. Possible values are `HttpOnly`, `HttpsOnly` or `MatchRequest`. Defaults to `MatchRequest`. * `cache` - (Optional) A `cache` block as defined below. -~> **NOTE:** To disable caching, do not provide the `cache` block in the configuration file. +~> **Note:** To disable caching, do not provide the `cache` block in the configuration file. * `cdn_frontdoor_custom_domain_ids` - (Optional) The IDs of the Front Door Custom Domains which are associated with this Front Door Route. @@ -158,7 +164,7 @@ The following arguments are supported: * `https_redirect_enabled` - (Optional) Automatically redirect HTTP traffic to HTTPS traffic? Possible values are `true` or `false`. Defaults to `true`. -~> **NOTE:** The `https_redirect_enabled` rule is the first rule that will be executed. +~> **Note:** The `https_redirect_enabled` rule is the first rule that will be executed. * `link_to_default_domain` - (Optional) Should this Front Door Route be linked to the default endpoint? Possible values include `true` or `false`. Defaults to `true`. @@ -168,13 +174,13 @@ A `cache` block supports the following: * `query_string_caching_behavior` - (Optional) Defines how the Front Door Route will cache requests that include query strings. Possible values include `IgnoreQueryString`, `IgnoreSpecifiedQueryStrings`, `IncludeSpecifiedQueryStrings` or `UseQueryString`. Defaults to `IgnoreQueryString`. -~> **NOTE:** The value of the `query_string_caching_behavior` determines if the `query_strings` field will be used as an include list or an ignore list. +~> **Note:** The value of the `query_string_caching_behavior` determines if the `query_strings` field will be used as an include list or an ignore list. * `query_strings` - (Optional) Query strings to include or ignore. * `compression_enabled` - (Optional) Is content compression enabled? Possible values are `true` or `false`. Defaults to `false`. -~> **NOTE:** Content won't be compressed when the requested content is smaller than `1 KB` or larger than `8 MB`(inclusive). +~> **Note:** Content won't be compressed when the requested content is smaller than `1 KB` or larger than `8 MB`(inclusive). * `content_types_to_compress` - (Optional) A list of one or more `Content types` (formerly known as `MIME types`) to compress. Possible values include `application/eot`, `application/font`, `application/font-sfnt`, `application/javascript`, `application/json`, `application/opentype`, `application/otf`, `application/pkcs7-mime`, `application/truetype`, `application/ttf`, `application/vnd.ms-fontobject`, `application/xhtml+xml`, `application/xml`, `application/xml+rss`, `application/x-font-opentype`, `application/x-font-truetype`, `application/x-font-ttf`, `application/x-httpd-cgi`, `application/x-mpegurl`, `application/x-opentype`, `application/x-otf`, `application/x-perl`, `application/x-ttf`, `application/x-javascript`, `font/eot`, `font/ttf`, `font/otf`, `font/opentype`, `image/svg+xml`, `text/css`, `text/csv`, `text/html`, `text/javascript`, `text/js`, `text/plain`, `text/richtext`, `text/tab-separated-values`, `text/xml`, `text/x-script`, `text/x-component` or `text/x-java-source`. diff --git a/website/docs/r/cdn_frontdoor_rule.html.markdown b/website/docs/r/cdn_frontdoor_rule.html.markdown index 8f690c2ded14..8a88ae3c6883 100644 --- a/website/docs/r/cdn_frontdoor_rule.html.markdown +++ b/website/docs/r/cdn_frontdoor_rule.html.markdown @@ -10,7 +10,7 @@ description: |- Manages a Front Door (standard/premium) Rule. -!>**IMPORTANT:** The Rules resource **must** include a `depends_on` meta-argument which references the `azurerm_cdn_frontdoor_origin` and the `azurerm_cdn_frontdoor_origin_group`. +!>**Note:** The Rules resource **must** include a `depends_on` meta-argument which references the `azurerm_cdn_frontdoor_origin` and the `azurerm_cdn_frontdoor_origin_group`. ## Example Usage @@ -152,7 +152,7 @@ The following arguments are supported: * `order` - (Required) The order in which the rules will be applied for the Front Door Endpoint. The order value should be sequential and begin at `1`(e.g. `1`, `2`, `3`...). A Front Door Rule with a lesser order value will be applied before a rule with a greater order value. -->**NOTE:** If the Front Door Rule has an order value of `0` they do not require any conditions and the actions will always be applied. +->**Note:** If the Front Door Rule has an order value of `0` they do not require any conditions and the actions will always be applied. * `actions` - (Required) An `actions` block as defined below. @@ -164,7 +164,7 @@ The following arguments are supported: An `actions` block supports the following: -->**NOTE:** You may include up to 5 separate actions in the `actions` block. +->**Note:** You may include up to 5 separate actions in the `actions` block. Some actions support `Action Server Variables` which provide access to structured information about the request. For more information about `Action Server Variables` see the `Action Server Variables` as defined below. @@ -198,7 +198,7 @@ An `url_redirect_action` block supports the following: A `route_configuration_override_action` block supports the following: -->**NOTE:** In the v3.x of the provider the `cache_duration`, `cache_behavior` and `query_string_caching_behavior` will have default values. You can use Terraform's [ignore_changes](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#ignore_changes) functionality to ignore these default values. In v4.0 of the provider the `cache_duration`, `cache_behavior` and `query_string_caching_behavior` will **NOT** have default values and will need to be explicitly set in the configuration file. +->**Note:** In the v3.x of the provider the `cache_duration`, `cache_behavior` and `query_string_caching_behavior` will have default values. You can use Terraform's [ignore_changes](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#ignore_changes) functionality to ignore these default values. In v4.0 of the provider the `cache_duration`, `cache_behavior` and `query_string_caching_behavior` will **NOT** have default values and will need to be explicitly set in the configuration file. * `cache_duration` - (Optional) When Cache behavior is set to `Override` or `SetIfMissing`, this field specifies the cache duration to use. The maximum duration is 366 days specified in the `d.HH:MM:SS` format(e.g. `365.23:59:59`). If the desired maximum cache duration is less than 1 day then the maximum cache duration should be specified in the `HH:MM:SS` format(e.g. `23:59:59`). @@ -206,17 +206,17 @@ A `route_configuration_override_action` block supports the following: * `forwarding_protocol` - (Optional) The forwarding protocol the request will be redirected as. This overrides the configuration specified in the route to be associated with. Possible values include `MatchRequest`, `HttpOnly` or `HttpsOnly`. -->**NOTE:** If the `cdn_frontdoor_origin_group_id` is not defined you cannot set the `forwarding_protocol`. +->**Note:** If the `cdn_frontdoor_origin_group_id` is not defined you cannot set the `forwarding_protocol`. * `query_string_caching_behavior` - (Optional) `IncludeSpecifiedQueryStrings` query strings specified in the `query_string_parameters` field get included when the cache key gets generated. `UseQueryString` cache every unique URL, each unique URL will have its own cache key. `IgnoreSpecifiedQueryStrings` query strings specified in the `query_string_parameters` field get excluded when the cache key gets generated. `IgnoreQueryString` query strings aren't considered when the cache key gets generated. Possible values include `IgnoreQueryString`, `UseQueryString`, `IgnoreSpecifiedQueryStrings` or `IncludeSpecifiedQueryStrings`. * `query_string_parameters` - (Optional) A list of query string parameter names. -->**NOTE:** `query_string_parameters` is a required field when the `query_string_caching_behavior` is set to `IncludeSpecifiedQueryStrings` or `IgnoreSpecifiedQueryStrings`. +->**Note:** `query_string_parameters` is a required field when the `query_string_caching_behavior` is set to `IncludeSpecifiedQueryStrings` or `IgnoreSpecifiedQueryStrings`. * `compression_enabled` - (Optional) Should the Front Door dynamically compress the content? Possible values include `true` or `false`. -->**NOTE:** Content won't be compressed on AzureFrontDoor when requested content is smaller than `1 byte` or larger than `1 MB`. +->**Note:** Content won't be compressed on AzureFrontDoor when requested content is smaller than `1 byte` or larger than `1 MB`. * `cache_behavior` - (Optional) `HonorOrigin` the Front Door will always honor origin response header directive. If the origin directive is missing, Front Door will cache contents anywhere from `1` to `3` days. `OverrideAlways` the TTL value returned from your Front Door Origin is overwritten with the value specified in the action. This behavior will only be applied if the response is cacheable. `OverrideIfOriginMissing` if no TTL value gets returned from your Front Door Origin, the rule sets the TTL to the value specified in the action. This behavior will only be applied if the response is cacheable. `Disabled` the Front Door will not cache the response contents, irrespective of Front Door Origin response directives. Possible values include `HonorOrigin`, `OverrideAlways`, `OverrideIfOriginMissing` or `Disabled`. @@ -236,13 +236,13 @@ A `request_header_action` block supports the following: * `header_action` - (Required) The action to be taken on the specified `header_name`. Possible values include `Append`, `Overwrite` or `Delete`. --> **NOTE:** `Append` causes the specified header to be added to the request with the specified value. If the header is already present, the value is appended to the existing header value using string concatenation. No delimiters are added. `Overwrite` causes specified header to be added to the request with the specified value. If the header is already present, the specified value overwrites the existing value. `Delete` causes the header to be deleted from the request. +-> **Note:** `Append` causes the specified header to be added to the request with the specified value. If the header is already present, the value is appended to the existing header value using string concatenation. No delimiters are added. `Overwrite` causes specified header to be added to the request with the specified value. If the header is already present, the specified value overwrites the existing value. `Delete` causes the header to be deleted from the request. * `header_name` - (Required) The name of the header to modify. * `value` - (Optional) The value to append or overwrite. -->**NOTE:** `value` is required if the `header_action` is set to `Append` or `Overwrite`. +->**Note:** `value` is required if the `header_action` is set to `Append` or `Overwrite`. --- @@ -250,19 +250,19 @@ A `response_header_action` block supports the following: * `header_action` - (Required) The action to be taken on the specified `header_name`. Possible values include `Append`, `Overwrite` or `Delete`. --> **NOTE:** `Append` causes the specified header to be added to the request with the specified value. If the header is already present, the value is appended to the existing header value using string concatenation. No delimiters are added. `Overwrite` causes specified header to be added to the request with the specified value. If the header is already present, the specified value overwrites the existing value. `Delete` causes the header to be deleted from the request. +-> **Note:** `Append` causes the specified header to be added to the request with the specified value. If the header is already present, the value is appended to the existing header value using string concatenation. No delimiters are added. `Overwrite` causes specified header to be added to the request with the specified value. If the header is already present, the specified value overwrites the existing value. `Delete` causes the header to be deleted from the request. * `header_name` - (Required) The name of the header to modify. * `value` - (Optional) The value to append or overwrite. -->**NOTE:** `value` is required if the `header_action` is set to `Append` or `Overwrite`. +->**Note:** `value` is required if the `header_action` is set to `Append` or `Overwrite`. --- A `conditions` block supports the following: -->**NOTE:** You may include up to 10 separate conditions in the `conditions` block. +->**Note:** You may include up to 10 separate conditions in the `conditions` block. * `remote_address_condition` - (Optional) A `remote_address_condition` block as defined below. @@ -362,13 +362,13 @@ A `socket_address_condition` block supports the following: * `operator` - (Optional) The type of match. The Possible values are `IpMatch` or `Any`. Defaults to `IPMatch`. -->**NOTE:** If the value of the `operator` field is set to `IpMatch` then the `match_values` field is also required. +->**Note:** If the value of the `operator` field is set to `IpMatch` then the `match_values` field is also required. * `negate_condition` - (Optional) If `true` operator becomes the opposite of its value. Possible values `true` or `false`. Defaults to `false`. Details can be found in the `Condition Operator List` below. * `match_values` - (Optional) Specify one or more IP address ranges. If multiple IP address ranges are specified, they're evaluated using `OR` logic. -->**NOTE:** See the `Specifying IP Address Ranges` section below on how to correctly define the `match_values` field. +->**Note:** See the `Specifying IP Address Ranges` section below on how to correctly define the `match_values` field. --- @@ -382,7 +382,7 @@ A `remote_address_condition` block supports the following: * `match_values` - (Optional) For the IP Match or IP Not Match operators: specify one or more IP address ranges. If multiple IP address ranges are specified, they're evaluated using `OR` logic. For the Geo Match or Geo Not Match operators: specify one or more locations using their country code. -->**NOTE:** See the `Specifying IP Address Ranges` section below on how to correctly define the `match_values` field. +->**Note:** See the `Specifying IP Address Ranges` section below on how to correctly define the `match_values` field. --- @@ -462,7 +462,7 @@ A `request_body_condition` block supports the following: ->The `request_body_condition` identifies requests based on specific text that appears in the body of the request. -->**NOTE:** If a request body exceeds `64 KB` in size, only the first `64 KB` will be considered for the request body match condition. +->**Note:** If a request body exceeds `64 KB` in size, only the first `64 KB` will be considered for the request body match condition. * `operator` - (Required) A Conditional operator. Possible values include `Any`, `Equal`, `Contains`, `BeginsWith`, `EndsWith`, `LessThan`, `LessThanOrEqual`, `GreaterThan`, `GreaterThanOrEqual` or `RegEx`. Details can be found in the `Condition Operator List` below. @@ -522,7 +522,7 @@ An `url_filename_condition` block supports the following: * `match_values` - (Optional) A list of one or more string or integer values(e.g. "1") representing the value of the request file name to match. If multiple values are specified, they're evaluated using `OR` logic. --> **NOTE:** The `match_values` field is only optional if the `operator` is set to `Any`. +-> **Note:** The `match_values` field is only optional if the `operator` is set to `Any`. * `negate_condition` - (Optional) If `true` operator becomes the opposite of its value. Possible values `true` or `false`. Defaults to `false`. Details can be found in the `Condition Operator List` below. From c6a2dc9ebb982ded85963f2d1f6d919760e7c071 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Thu, 21 Aug 2025 23:56:04 -0600 Subject: [PATCH 2/6] Address PR comments... --- .../services/cdn/cdn_frontdoor_route_resource.go | 14 +++++++------- website/docs/r/cdn_frontdoor_route.html.markdown | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/services/cdn/cdn_frontdoor_route_resource.go b/internal/services/cdn/cdn_frontdoor_route_resource.go index f1be9138193e..deb7075373ae 100644 --- a/internal/services/cdn/cdn_frontdoor_route_resource.go +++ b/internal/services/cdn/cdn_frontdoor_route_resource.go @@ -8,6 +8,7 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" @@ -66,7 +67,6 @@ func resourceCdnFrontDoorRoute() *pluginsdk.Resource { "cdn_frontdoor_origin_ids": { Type: pluginsdk.TypeList, Optional: true, - Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validate.FrontDoorOriginID, @@ -291,7 +291,7 @@ func resourceCdnFrontDoorRouteCreate(d *pluginsdk.ResourceData, meta interface{} } if originPath := d.Get("cdn_frontdoor_origin_path").(string); originPath != "" { - props.RouteProperties.OriginPath = utils.String(originPath) + props.RouteProperties.OriginPath = pointer.To(originPath) } future, err := client.Create(ctx, id.ResourceGroup, id.ProfileName, id.AfdEndpointName, id.RouteName, props) @@ -347,7 +347,7 @@ func resourceCdnFrontDoorRouteRead(d *pluginsdk.ResourceData, meta interface{}) // NOTE: These are not sent to the API, they are only here so Terraform // can provision/destroy the resources in the correct order. if originIds := d.Get("cdn_frontdoor_origin_ids").([]interface{}); len(originIds) > 0 { - d.Set("cdn_frontdoor_origin_ids", utils.ExpandStringSlice(originIds)) + d.Set("cdn_frontdoor_origin_ids", originIds) } d.Set("name", id.RouteName) @@ -496,7 +496,7 @@ func resourceCdnFrontDoorRouteUpdate(d *pluginsdk.ResourceData, meta interface{} originPath := d.Get("cdn_frontdoor_origin_path").(string) if originPath != "" { - updateProps.OriginPath = utils.String(originPath) + updateProps.OriginPath = pointer.To(originPath) } } @@ -533,7 +533,7 @@ func resourceCdnFrontDoorRouteUpdate(d *pluginsdk.ResourceData, meta interface{} // NOTE: These are not sent to the API, they are only here so Terraform // can provision/destroy the resources in the correct order. if originIds := d.Get("cdn_frontdoor_origin_ids").([]interface{}); len(originIds) > 0 { - d.Set("cdn_frontdoor_origin_ids", utils.ExpandStringSlice(originIds)) + d.Set("cdn_frontdoor_origin_ids", originIds) } return resourceCdnFrontDoorRouteRead(d, meta) @@ -583,7 +583,7 @@ func expandRuleSetReferenceArray(input []interface{}) *[]cdn.ResourceReference { for _, item := range input { results = append(results, cdn.ResourceReference{ - ID: utils.String(item.(string)), + ID: pointer.To(item.(string)), }) } @@ -605,7 +605,7 @@ func expandCdnFrontdoorRouteCacheConfiguration(input []interface{}) *cdn.AfdRout cacheConfiguration := &cdn.AfdRouteCacheConfiguration{ CompressionSettings: &cdn.CompressionSettings{ - IsCompressionEnabled: utils.Bool(compressionEnabled), + IsCompressionEnabled: pointer.To(compressionEnabled), }, QueryParameters: expandStringSliceToCsvFormat(v["query_strings"].([]interface{})), QueryStringCachingBehavior: queryStringCachingBehaviorValue, diff --git a/website/docs/r/cdn_frontdoor_route.html.markdown b/website/docs/r/cdn_frontdoor_route.html.markdown index e0f64fe24ca6..30773b27e587 100644 --- a/website/docs/r/cdn_frontdoor_route.html.markdown +++ b/website/docs/r/cdn_frontdoor_route.html.markdown @@ -10,7 +10,7 @@ description: |- Manages a Front Door (standard/premium) Route. -!>**Note:** The `azurerm_cdn_frontdoor_route` resource must **explicitly** reference its associated `azurerm_cdn_frontdoor_origin` resource(s). This can be achieved either by using a `depends_on` meta-argument that points to the `azurerm_cdn_frontdoor_origin` resource(s), or by specifying the `azurerm_cdn_frontdoor_origin` IDs via the `cdn_frontdoor_origin_ids` field. +!> **Note:** The `azurerm_cdn_frontdoor_route` resource must **explicitly** reference its associated `azurerm_cdn_frontdoor_origin` resource(s). This can be achieved either by using a `depends_on` meta-argument that points to the `azurerm_cdn_frontdoor_origin` resource(s), or by specifying the `azurerm_cdn_frontdoor_origin` IDs via the `cdn_frontdoor_origin_ids` field. ## Example Usage From ee787efdd5c2f376244fb879151ba1c59e482c15 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Tue, 2 Sep 2025 21:40:36 -0600 Subject: [PATCH 3/6] docs: update note formatting and clarify usage of cdn_frontdoor_origin_ids in azurerm_cdn_frontdoor_route documentation --- website/docs/r/cdn_frontdoor_route.html.markdown | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/website/docs/r/cdn_frontdoor_route.html.markdown b/website/docs/r/cdn_frontdoor_route.html.markdown index 30773b27e587..60920348219f 100644 --- a/website/docs/r/cdn_frontdoor_route.html.markdown +++ b/website/docs/r/cdn_frontdoor_route.html.markdown @@ -10,7 +10,7 @@ description: |- Manages a Front Door (standard/premium) Route. -!> **Note:** The `azurerm_cdn_frontdoor_route` resource must **explicitly** reference its associated `azurerm_cdn_frontdoor_origin` resource(s). This can be achieved either by using a `depends_on` meta-argument that points to the `azurerm_cdn_frontdoor_origin` resource(s), or by specifying the `azurerm_cdn_frontdoor_origin` IDs via the `cdn_frontdoor_origin_ids` field. +~> **Note:** The `azurerm_cdn_frontdoor_route` resource must **explicitly** reference its associated `azurerm_cdn_frontdoor_origin` resource(s). This can be achieved either by using a `depends_on` meta-argument that points to the `azurerm_cdn_frontdoor_origin` resource(s), or by specifying the `azurerm_cdn_frontdoor_origin` IDs via the `cdn_frontdoor_origin_ids` field. ## Example Usage @@ -144,9 +144,7 @@ The following arguments are supported: * `cdn_frontdoor_origin_ids` - (Optional) One or more Front Door Origin resource IDs for this Front Door Route. -~> **Note:** The `cdn_frontdoor_origin_ids` field is not sent to the Azure API, it exists solely to ensure Terraform can manage the correct `provisioning` and `destruction` order of related resources. When importing an existing `azurerm_cdn_frontdoor_route` resource, you will need to manually add the `cdn_frontdoor_origin_ids` field to your configuration after the resource has been successfully imported. - -~> **Note:** If the `cdn_frontdoor_origin_ids` field is not defined in the configuration, you **must** use a `depends_on` meta-argument that references the corresponding `azurerm_cdn_frontdoor_origin` resource(s) for the route. When importing an existing `azurerm_cdn_frontdoor_route` resource from Azure, you will need to manually add the `depends_on` meta-argument to your configuration after the resource has been successfully imported. +~> **Note:** The `cdn_frontdoor_origin_ids` field is not transmitted to the Azure API; it is used exclusively by Terraform to determine correct resource provisioning and destruction order. If this field is omitted, a `depends_on` meta-argument referencing the corresponding `azurerm_cdn_frontdoor_origin` resource(s) is required. When importing an existing `azurerm_cdn_frontdoor_route resource`, you must manually add either the `cdn_frontdoor_origin_ids` field or the `depends_on` meta-argument to the configuration post-import. * `forwarding_protocol` - (Optional) The Protocol that will be use when forwarding traffic to backends. Possible values are `HttpOnly`, `HttpsOnly` or `MatchRequest`. Defaults to `MatchRequest`. From ada7a2eee833cd9e0971aeb8e1ed23c616c2f3b8 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Thu, 12 Mar 2026 00:15:15 -0600 Subject: [PATCH 4/6] Fix conflict... --- internal/services/cdn/cdn_frontdoor_route_resource.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/services/cdn/cdn_frontdoor_route_resource.go b/internal/services/cdn/cdn_frontdoor_route_resource.go index 1eae8aef5973..6787fed24e9f 100644 --- a/internal/services/cdn/cdn_frontdoor_route_resource.go +++ b/internal/services/cdn/cdn_frontdoor_route_resource.go @@ -291,11 +291,7 @@ func resourceCdnFrontDoorRouteCreate(d *pluginsdk.ResourceData, meta interface{} } if originPath := d.Get("cdn_frontdoor_origin_path").(string); originPath != "" { -<<<<<<< HEAD props.RouteProperties.OriginPath = pointer.To(originPath) -======= - props.OriginPath = pointer.To(originPath) ->>>>>>> 2dd770f5b60c92e78643f20e61ff9ae22db5d496 } future, err := client.Create(ctx, id.ResourceGroup, id.ProfileName, id.AfdEndpointName, id.RouteName, props) From 4fddb6e8cc3407a88cbbd418a3c553d9f30b90a9 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Thu, 12 Mar 2026 00:28:05 -0600 Subject: [PATCH 5/6] Fix lint error... --- internal/services/cdn/cdn_frontdoor_route_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/cdn/cdn_frontdoor_route_resource.go b/internal/services/cdn/cdn_frontdoor_route_resource.go index 6787fed24e9f..d62d934c0831 100644 --- a/internal/services/cdn/cdn_frontdoor_route_resource.go +++ b/internal/services/cdn/cdn_frontdoor_route_resource.go @@ -291,7 +291,7 @@ func resourceCdnFrontDoorRouteCreate(d *pluginsdk.ResourceData, meta interface{} } if originPath := d.Get("cdn_frontdoor_origin_path").(string); originPath != "" { - props.RouteProperties.OriginPath = pointer.To(originPath) + props.OriginPath = pointer.To(originPath) } future, err := client.Create(ctx, id.ResourceGroup, id.ProfileName, id.AfdEndpointName, id.RouteName, props) From 6ad761a2f6f523c98462e445306cbc1f5fc43836 Mon Sep 17 00:00:00 2001 From: Jeffrey Cline <20408400+WodansSon@users.noreply.github.com> Date: Thu, 12 Mar 2026 02:16:29 -0600 Subject: [PATCH 6/6] Add updateDependsOn method for cdn_frontdoor_route tests --- .../cdn/cdn_frontdoor_route_resource_test.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/internal/services/cdn/cdn_frontdoor_route_resource_test.go b/internal/services/cdn/cdn_frontdoor_route_resource_test.go index 91ec1aece790..6b4f04ff6f45 100644 --- a/internal/services/cdn/cdn_frontdoor_route_resource_test.go +++ b/internal/services/cdn/cdn_frontdoor_route_resource_test.go @@ -111,6 +111,13 @@ func TestAccCdnFrontDoorRoute_update(t *testing.T) { ), }, data.ImportStep("cdn_frontdoor_origin_group_id", "cdn_frontdoor_origin_ids"), + { + Config: r.updateDependsOn(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("cdn_frontdoor_origin_group_id"), }) } @@ -351,3 +358,30 @@ resource "azurerm_cdn_frontdoor_route" "test" { } `, template, data.RandomInteger) } + +func (r CdnFrontDoorRouteResource) updateDependsOn(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_cdn_frontdoor_route" "test" { + name = "accTestRoute-%d" + cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.test.id + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.test.id + + enabled = true + forwarding_protocol = "HttpOnly" + https_redirect_enabled = false + patterns_to_match = ["/*"] + cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.test.id] + supported_protocols = ["Https"] + + cache { + query_strings = ["bar"] + query_string_caching_behavior = "IncludeSpecifiedQueryStrings" + } + + depends_on = [azurerm_cdn_frontdoor_origin.test] +} +`, template, data.RandomInteger) +}