Skip to content

Commit

Permalink
azuread_group - owners is now additive on creation allowing exis… (#211)
Browse files Browse the repository at this point in the history
Fixed func resourceGroupCreate. From now you can pass your object_id to the owner list

(fixes #212)
  • Loading branch information
jnehlt authored Mar 11, 2020
1 parent 5331666 commit 842e9b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions azuread/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ func resourceGroupCreate(d *schema.ResourceData, meta interface{}) error {

// Add owners if specified
if v, ok := d.GetOk("owners"); ok {
members := tf.ExpandStringSlicePtr(v.(*schema.Set).List())
if err := graph.GroupAddOwners(client, ctx, *group.ObjectID, *members); err != nil {
existingOwners, err := graph.GroupAllOwners(client, ctx, *group.ObjectID)
if err != nil {
return err
}
members := *tf.ExpandStringSlicePtr(v.(*schema.Set).List())
ownersToAdd := slices.Difference(members, existingOwners)

if err := graph.GroupAddOwners(client, ctx, *group.ObjectID, ownersToAdd); err != nil {
return err
}
}
Expand Down

0 comments on commit 842e9b1

Please sign in to comment.