You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call (#9727) (#16927)
* Add error handling for ALREADY_EXISTS in IAM CreateServiceAccount call
* Use a separate unit test for create_ignore_already_exists
[upstream:612663010b4da3022cade6f2a07f4d6beb2b6d51]
Signed-off-by: Modular Magician <[email protected]>
iam: introducde an optional resource argument to Google Cloud IAM Service Account. If `ignore_create_already_exists` is set to true, resource creation would succeed if response error is 409 ALREADY_EXISTS.
Description: `The Identity of the service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.`,
86
87
},
88
+
"create_ignore_already_exists": {
89
+
Type: schema.TypeBool,
90
+
Optional: true,
91
+
Computed: false,
92
+
Description: `If set to true, skip service account creation if a service account with the same email already exists.`,
93
+
},
87
94
},
88
95
UseJSONNumber: true,
89
96
}
@@ -116,7 +123,15 @@ func resourceGoogleServiceAccountCreate(d *schema.ResourceData, meta interface{}
116
123
117
124
sa, err=config.NewIamClient(userAgent).Projects.ServiceAccounts.Create("projects/"+project, r).Do()
118
125
iferr!=nil {
119
-
returnfmt.Errorf("Error creating service account: %s", err)
0 commit comments