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

azurerm_cdn_endpoint - Standardize the resource ID to be case sensitive #8237

Merged
19 changes: 18 additions & 1 deletion azurerm/internal/services/cdn/cdn_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"log"
"time"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/migration"

"github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -201,10 +203,20 @@ func resourceArmCdnEndpoint() *schema.Resource {

"tags": tags.Schema(),
},

SchemaVersion: 1,
StateUpgraders: []schema.StateUpgrader{
{
Type: migration.CdnEndpointV0Schema().CoreConfigSchema().ImpliedType(),
Upgrade: migration.CdnEndpointV0ToV1,
Version: 0,
magodo marked this conversation as resolved.
Show resolved Hide resolved
},
},
}
}

func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error {
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
endpointsClient := meta.(*clients.Client).Cdn.EndpointsClient
profilesClient := meta.(*clients.Client).Cdn.ProfilesClient
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
Expand Down Expand Up @@ -303,7 +315,12 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error retrieving CDN Endpoint %q (Profile %q / Resource Group %q): %+v", name, profileName, resourceGroup, err)
}

d.SetId(*read.ID)
id, err := parse.CdnEndpointID(*read.ID)
if err != nil {
return err
}

d.SetId(id.ID(subscriptionId))
magodo marked this conversation as resolved.
Show resolved Hide resolved

return resourceArmCdnEndpointRead(d, meta)
}
Expand Down
10 changes: 9 additions & 1 deletion azurerm/internal/services/cdn/cdn_profile_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"time"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/parse"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
Expand Down Expand Up @@ -41,6 +43,7 @@ func dataSourceArmCdnProfile() *schema.Resource {
}

func dataSourceArmCdnProfileRead(d *schema.ResourceData, meta interface{}) error {
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
client := meta.(*clients.Client).Cdn.ProfilesClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand All @@ -56,7 +59,12 @@ func dataSourceArmCdnProfileRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error making Read request on Azure CDN Profile %q (Resource Group %q): %+v", name, resourceGroup, err)
}

d.SetId(*resp.ID)
id, err := parse.CdnProfileID(*resp.ID)
if err != nil {
return err
}

d.SetId(id.ID(subscriptionId))

d.Set("name", name)
d.Set("resource_group_name", resourceGroup)
Expand Down
19 changes: 18 additions & 1 deletion azurerm/internal/services/cdn/cdn_profile_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"log"
"time"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/migration"

"github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -66,10 +68,20 @@ func resourceArmCdnProfile() *schema.Resource {

"tags": tags.Schema(),
},

SchemaVersion: 1,
StateUpgraders: []schema.StateUpgrader{
{
Type: migration.CdnProfileV0Schema().CoreConfigSchema().ImpliedType(),
Upgrade: migration.CdnProfileV0ToV1,
Version: 0,
magodo marked this conversation as resolved.
Show resolved Hide resolved
},
},
}
}

func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error {
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
client := meta.(*clients.Client).Cdn.ProfilesClient
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -121,7 +133,12 @@ func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Cannot read CDN Profile %s (resource group %s) ID", name, resGroup)
}

d.SetId(*read.ID)
id, err := parse.CdnProfileID(*read.ID)
if err != nil {
return err
}

d.SetId(id.ID(subscriptionId))
magodo marked this conversation as resolved.
Show resolved Hide resolved

return resourceArmCdnProfileRead(d, meta)
}
Expand Down
Loading