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_cognitive_deployment - add locks to parent resource to prevent 409 error #22711

Merged
merged 2 commits into from
Jul 28, 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
Next Next commit
adding locks to prevent 409 Error when creating multiple deployments
liuwuliuyun committed Jul 27, 2023
commit fd83c0e19361d9ef073a5ede571f20c937e4a00c
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ package cognitive
import (
"context"
"fmt"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
@@ -220,6 +221,9 @@ func (r CognitiveDeploymentResource) Create() sdk.ResourceFunc {

client := metadata.Client.Cognitive.DeploymentsClient
accountId, err := cognitiveservicesaccounts.ParseAccountID(model.CognitiveAccountId)

locks.ByID(accountId.ID())

if err != nil {
return err
}
@@ -250,6 +254,8 @@ func (r CognitiveDeploymentResource) Create() sdk.ResourceFunc {
return fmt.Errorf("creating %s: %+v", id, err)
}

locks.UnlockByID(accountId.ID())

metadata.SetID(id)
return nil
},