Skip to content

Commit

Permalink
Fixed error while deleting cdn_frontdoor_origin_path property (#22209)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan authored Jun 21, 2023
1 parent 56d1e71 commit ca4d502
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions internal/services/cdn/azuresdkhacks/cdn_frontdoor_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ func (rupp RouteUpdatePropertiesParameters) MarshalJSON() ([]byte, error) {
if rupp.OriginGroup != nil {
objectMap["originGroup"] = rupp.OriginGroup
}
if rupp.OriginPath != nil {
objectMap["originPath"] = rupp.OriginPath
}

// OriginPath must be set to nil to be removed
objectMap["originPath"] = rupp.OriginPath

if rupp.RuleSets != nil {
objectMap["ruleSets"] = rupp.RuleSets
}
Expand Down
5 changes: 4 additions & 1 deletion internal/services/cdn/cdn_frontdoor_route_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@ func resourceCdnFrontDoorRouteUpdate(d *pluginsdk.ResourceData, meta interface{}
}

if d.HasChange("cdn_frontdoor_origin_path") {
updateProps.OriginPath = utils.String(d.Get("cdn_frontdoor_origin_path").(string))
originPath := d.Get("cdn_frontdoor_origin_path").(string)
if originPath != "" {
updateProps.OriginPath = utils.String(originPath)
}
}

if d.HasChange("patterns_to_match") {
Expand Down
1 change: 1 addition & 0 deletions internal/services/cdn/cdn_frontdoor_route_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ resource "azurerm_cdn_frontdoor_route" "test" {
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.test.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.test.id]
cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.test.id]
cdn_frontdoor_origin_path = "/example"
enabled = true
forwarding_protocol = "HttpsOnly"
Expand Down

0 comments on commit ca4d502

Please sign in to comment.