From f9963963d82f38f6c5bfe6b25b44cd4b84e5bd7c Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Mon, 6 Sep 2021 10:24:27 +0100 Subject: [PATCH] Bugfix: only specify the calling principal ID once when creating a group --- internal/services/groups/group_resource.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/services/groups/group_resource.go b/internal/services/groups/group_resource.go index e1906dad0e..d32350fdee 100644 --- a/internal/services/groups/group_resource.go +++ b/internal/services/groups/group_resource.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "net/http" + "strings" "time" "github.com/hashicorp/go-uuid" @@ -439,7 +440,7 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter if err != nil { return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id) } - if *ownerObject.ID == callerId { + if strings.EqualFold(*ownerObject.ID, callerId) { if ownerObject.ODataId == nil { return tf.ErrorDiagF(errors.New("ODataId was nil"), "Could not retrieve owner principal object %q", id) } @@ -459,7 +460,7 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter if err != nil { return tf.ErrorDiagF(err, "Could not retrieve owner principal object %q", id) } - if *ownerObject.ODataType == t { + if *ownerObject.ODataType == t && !strings.EqualFold(*ownerObject.ID, callerId) { if ownerCount < 20 { ownersFirst20 = append(ownersFirst20, *ownerObject) } else {