From 6f595e379b24db3e9bdcbfe92974e0c34cb82ad1 Mon Sep 17 00:00:00 2001 From: SamuZad Date: Thu, 24 Aug 2023 13:48:19 +0100 Subject: [PATCH] prioritize email change, so it doesn't conflict with other api operations such as suspension or archival when done at the same time --- internal/provider/resource_user.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/provider/resource_user.go b/internal/provider/resource_user.go index 304d5dd8..560f39a4 100644 --- a/internal/provider/resource_user.go +++ b/internal/provider/resource_user.go @@ -1241,6 +1241,16 @@ func resourceUserUpdate(ctx context.Context, d *schema.ResourceData, meta interf // Strings if d.HasChange("primary_email") { + if d.IsNewResource() == false { + emailupdate := directory.User{ + PrimaryEmail: primaryEmail, + } + _, err := usersService.Update(d.Id(), &emailupdate).Do() + if err != nil { + return diag.FromErr(err) + } + } + userObj.PrimaryEmail = primaryEmail }