@@ -61,6 +61,11 @@ func resourceGoogleProjectIamPolicyCreate(d *schema.ResourceData, meta interface
61
61
if err != nil {
62
62
return err
63
63
}
64
+
65
+ mutexKey := getProjectIamPolicyMutexKey (pid )
66
+ mutexKV .Lock (mutexKey )
67
+ defer mutexKV .Unlock (mutexKey )
68
+
64
69
// Get the policy in the template
65
70
p , err := getResourceIamPolicy (d )
66
71
if err != nil {
@@ -153,6 +158,10 @@ func resourceGoogleProjectIamPolicyUpdate(d *schema.ResourceData, meta interface
153
158
return err
154
159
}
155
160
161
+ mutexKey := getProjectIamPolicyMutexKey (pid )
162
+ mutexKV .Lock (mutexKey )
163
+ defer mutexKV .Unlock (mutexKey )
164
+
156
165
// Get the policy in the template
157
166
p , err := getResourceIamPolicy (d )
158
167
if err != nil {
@@ -220,6 +229,10 @@ func resourceGoogleProjectIamPolicyDelete(d *schema.ResourceData, meta interface
220
229
return err
221
230
}
222
231
232
+ mutexKey := getProjectIamPolicyMutexKey (pid )
233
+ mutexKV .Lock (mutexKey )
234
+ defer mutexKV .Unlock (mutexKey )
235
+
223
236
// Get the existing IAM policy from the API
224
237
ep , err := getProjectIamPolicy (pid , config )
225
238
if err != nil {
@@ -400,3 +413,7 @@ func (b sortableBindings) Swap(i, j int) {
400
413
func (b sortableBindings ) Less (i , j int ) bool {
401
414
return b [i ].Role < b [j ].Role
402
415
}
416
+
417
+ func getProjectIamPolicyMutexKey (pid string ) string {
418
+ return fmt .Sprintf ("iam-project-%s" , pid )
419
+ }
0 commit comments