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

refactor: updating vpn_gateway to use hashicorp/go-azure-sdk #22906

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions internal/services/network/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type Client struct {
VnetPeeringsClient *network.VirtualNetworkPeeringsClient
VirtualWanClient *network.VirtualWansClient
VirtualHubClient *network.VirtualHubsClient
VpnGatewaysClient *network.VpnGatewaysClient
}

func NewClient(o *common.ClientOptions) (*Client, error) {
Expand Down Expand Up @@ -173,9 +172,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
VirtualHubClient := network.NewVirtualHubsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&VirtualHubClient.Client, o.ResourceManagerAuthorizer)

vpnGatewaysClient := network.NewVpnGatewaysClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&vpnGatewaysClient.Client, o.ResourceManagerAuthorizer)

ServiceAssociationLinkClient := network.NewServiceAssociationLinksClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&ServiceAssociationLinkClient.Client, o.ResourceManagerAuthorizer)

Expand Down Expand Up @@ -228,7 +224,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
VnetPeeringsClient: &VnetPeeringsClient,
VirtualWanClient: &VirtualWanClient,
VirtualHubClient: &VirtualHubClient,
VpnGatewaysClient: &vpnGatewaysClient,
PrivateDnsZoneGroupClient: &PrivateDnsZoneGroupClient,
PrivateLinkServiceClient: &PrivateLinkServiceClient,
ServiceAssociationLinkClient: &ServiceAssociationLinkClient,
Expand Down
72 changes: 0 additions & 72 deletions internal/services/network/parse/vpn_gateway.go

This file was deleted.

115 changes: 0 additions & 115 deletions internal/services/network/parse/vpn_gateway_test.go

This file was deleted.

1 change: 0 additions & 1 deletion internal/services/network/resourceids.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ package network
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualHub -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualHubIpConfiguration -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/ipConfiguration1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualWan -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/virtualWan1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VpnGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PointToSiteVpnGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/pointToSite1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VpnConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/vpnConnection1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VpnGatewayNatRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/natRule1
Expand Down
26 changes: 0 additions & 26 deletions internal/services/network/validate/vpn_gateway_id.go

This file was deleted.

79 changes: 0 additions & 79 deletions internal/services/network/validate/vpn_gateway_id_test.go

This file was deleted.

13 changes: 6 additions & 7 deletions internal/services/network/vpn_gateway_connection_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -54,7 +53,7 @@ func resourceVPNGatewayConnection() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.VpnGatewayID,
ValidateFunc: virtualwans.ValidateVpnGatewayID,
},

"remote_vpn_site_id": {
Expand Down Expand Up @@ -336,12 +335,12 @@ func resourceVpnGatewayConnectionResourceCreateUpdate(d *pluginsdk.ResourceData,
defer cancel()

name := d.Get("name").(string)
gatewayId, err := parse.VpnGatewayID(d.Get("vpn_gateway_id").(string))
gatewayId, err := virtualwans.ParseVpnGatewayID(d.Get("vpn_gateway_id").(string))
if err != nil {
return err
}

id := commonids.NewVPNConnectionID(gatewayId.SubscriptionId, gatewayId.ResourceGroup, gatewayId.Name, name)
id := commonids.NewVPNConnectionID(gatewayId.SubscriptionId, gatewayId.ResourceGroupName, gatewayId.VpnGatewayName, name)
if d.IsNewResource() {
resp, err := client.VpnConnectionsGet(ctx, id)
if err != nil {
Expand All @@ -355,8 +354,8 @@ func resourceVpnGatewayConnectionResourceCreateUpdate(d *pluginsdk.ResourceData,
}
}

locks.ByName(gatewayId.Name, VPNGatewayResourceName)
defer locks.UnlockByName(gatewayId.Name, VPNGatewayResourceName)
locks.ByName(gatewayId.VpnGatewayName, VPNGatewayResourceName)
defer locks.UnlockByName(gatewayId.VpnGatewayName, VPNGatewayResourceName)

payload := virtualwans.VpnConnection{
Properties: &virtualwans.VpnConnectionProperties{
Expand Down Expand Up @@ -403,7 +402,7 @@ func resourceVpnGatewayConnectionResourceRead(d *pluginsdk.ResourceData, meta in
}

d.Set("name", id.ConnectionName)
d.Set("vpn_gateway_id", parse.NewVpnGatewayID(id.SubscriptionId, id.ResourceGroupName, id.GatewayName).ID())
d.Set("vpn_gateway_id", virtualwans.NewVpnGatewayID(id.SubscriptionId, id.ResourceGroupName, id.GatewayName).ID())

if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
Expand Down