-
Notifications
You must be signed in to change notification settings - Fork 5k
azurerm_cdn_frontdoor_route - make cdn_frontdoor_origin_ids field optional
#29350
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
Changes from 4 commits
f945592
21a0c11
ee701b6
c6a2dc9
ee787ef
7d3e441
ada7a2e
4fddb6e
6ad761a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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" | ||||||||||||
|
|
@@ -62,10 +63,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{ | ||||||||||||
|
Comment on lines
+69
to
70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen both ways in the code, but it seems most of the time there's no new line before
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||||||||||||
| Type: pluginsdk.TypeString, | ||||||||||||
| ValidateFunc: validate.FrontDoorOriginID, | ||||||||||||
|
|
@@ -290,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) | ||||||||||||
|
|
@@ -346,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) | ||||||||||||
|
|
@@ -495,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) | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -532,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) | ||||||||||||
|
|
@@ -582,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)), | ||||||||||||
| }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -604,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, | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd like to save the "!>" notes for cases where costly or irreversible damage could occur. The "~>" is a good choice for advising users how to avoid minor errors.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||||||
|
|
||||||
| ## Example Usage | ||||||
|
|
||||||
| ```hcl | ||||||
|
|
@@ -134,16 +136,20 @@ 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. | ||||||
|
|
||||||
| * `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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could these two notes be condensed and combined?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||||||
|
|
||||||
| * `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. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you replace the
utils.String()etc withpointer.To()?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.