diff --git a/redshift/resource_redshift_default_privileges.go b/redshift/resource_redshift_default_privileges.go index af19f24..66a4f98 100644 --- a/redshift/resource_redshift_default_privileges.go +++ b/redshift/resource_redshift_default_privileges.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "strings" + "sync" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -30,6 +31,8 @@ var defaultPrivilegesObjectTypesCodes = map[string]string{ "table": "r", } +var defaultPrivilegesMutex sync.Mutex + func redshiftDefaultPrivileges() *schema.Resource { return &schema.Resource{ Description: `Defines the default set of access privileges to be applied to objects that are created in the future by the specified user. By default, users can change only their own default access privileges. Only a superuser can specify default privileges for other users.`, @@ -112,6 +115,9 @@ func resourceRedshiftDefaultPrivilegesDelete(db *DBConnection, d *schema.Resourc } func resourceRedshiftDefaultPrivilegesCreate(db *DBConnection, d *schema.ResourceData) error { + defaultPrivilegesMutex.Lock() + defer defaultPrivilegesMutex.Unlock() + privilegesSet := d.Get(defaultPrivilegesPrivilegesAttr).(*schema.Set) objectType := d.Get(defaultPrivilegesObjectTypeAttr).(string)