Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azuread_group: fix bug preventing creation retry when caller owner causes duplicate value error #1593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/services/groups/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,14 +674,14 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in
if response.WasBadRequest(resp.HttpResponse) && regexp.MustCompile(groupDuplicateValueError).MatchString(err.Error()) {
// Retry the group creation, without the calling principal as owner
ownersWithoutCallingPrincipal := make([]string, 0)
for _, o := range *properties.Owners_ODataBind {
for _, o := range pointer.From(properties.Owners_ODataBind) {
if o != callerODataId {
ownersWithoutCallingPrincipal = append(ownersWithoutCallingPrincipal, o)
}
}

// No point in retrying if the caller wasn't specified as an owner
if len(ownersWithoutCallingPrincipal) == len(pointer.From(properties.Owners)) {
if len(ownersWithoutCallingPrincipal) == len(pointer.From(properties.Owners_ODataBind)) {
log.Printf("[DEBUG] Not retrying group creation for %q as owner was not specified", displayName)
return tf.ErrorDiagF(err, "Creating group %q", displayName)
}
Expand Down
Loading