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_express_route_port_authorization: add a lock when create/update/delete authorization of express route port #21959

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"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/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
Expand Down Expand Up @@ -85,6 +86,11 @@ func resourceExpressRoutePortAuthorizationCreate(d *pluginsdk.ResourceData, meta
ExpressRoutePortAuthorizationPropertiesFormat: &network.ExpressRoutePortAuthorizationPropertiesFormat{},
}

// can run only one create/update/delete operation of expressRoutePort at the same time
portID := parse.NewExpressRoutePortID(id.SubscriptionId, id.ResourceGroup, id.ExpressRoutePortName)
locks.ByID(portID.ID())
defer locks.UnlockByID(portID.ID())

future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.ExpressRoutePortName, id.AuthorizationName, properties)
if err != nil {
return fmt.Errorf("Creating/Updating %s: %+v", id, err)
Expand Down Expand Up @@ -140,6 +146,10 @@ func resourceExpressRoutePortAuthorizationDelete(d *pluginsdk.ResourceData, meta
return err
}

portID := parse.NewExpressRoutePortID(id.SubscriptionId, id.ResourceGroup, id.ExpressRoutePortName)
locks.ByID(portID.ID())
defer locks.UnlockByID(portID.ID())

future, err := client.Delete(ctx, id.ResourceGroup, id.ExpressRoutePortName, id.AuthorizationName)
if err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
Expand Down