Skip to content

Commit

Permalink
azurerm_postgresql_flexible_server_configuration - add lock to avoi…
Browse files Browse the repository at this point in the history
…d confliction (#27355)
  • Loading branch information
neil-yechenwei authored Oct 11, 2024
1 parent bb21661 commit a130180
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

var postgresqlFlexibleServerConfigurationResourceName = "azurerm_postgresql_flexible_server_configuration"

func resourcePostgresqlFlexibleServerConfiguration() *pluginsdk.Resource {
return &pluginsdk.Resource{
Create: resourceFlexibleServerConfigurationUpdate,
Expand Down Expand Up @@ -79,6 +81,9 @@ func resourceFlexibleServerConfigurationUpdate(d *pluginsdk.ResourceData, meta i
locks.ByName(id.FlexibleServerName, postgresqlFlexibleServerResourceName)
defer locks.UnlockByName(id.FlexibleServerName, postgresqlFlexibleServerResourceName)

locks.ByName(id.ConfigurationName, postgresqlFlexibleServerConfigurationResourceName)
defer locks.UnlockByName(id.ConfigurationName, postgresqlFlexibleServerConfigurationResourceName)

props := configurations.Configuration{
Properties: &configurations.ConfigurationProperties{
Value: utils.String(d.Get("value").(string)),
Expand Down Expand Up @@ -162,6 +167,9 @@ func resourceFlexibleServerConfigurationDelete(d *pluginsdk.ResourceData, meta i
locks.ByName(id.FlexibleServerName, postgresqlFlexibleServerResourceName)
defer locks.UnlockByName(id.FlexibleServerName, postgresqlFlexibleServerResourceName)

locks.ByName(id.ConfigurationName, postgresqlFlexibleServerConfigurationResourceName)
defer locks.UnlockByName(id.ConfigurationName, postgresqlFlexibleServerConfigurationResourceName)

resp, err := client.Get(ctx, *id)
if err != nil {
return fmt.Errorf("retrieving %s: %+v", id, err)
Expand Down

0 comments on commit a130180

Please sign in to comment.