Skip to content

Commit

Permalink
resource/alicloud_ram_group_membership: fix bug while deleting resour…
Browse files Browse the repository at this point in the history
…ce will remove all user under group.
  • Loading branch information
ChenHanZhang committed Jul 2, 2024
1 parent d717183 commit f002e1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alicloud/resource_alicloud_ram_group_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ func resourceAlicloudRamGroupMembershipRead(d *schema.ResourceData, meta interfa
return WrapError(err)
}
var users []string
localUsers := expandStringList(d.Get("user_names").(*schema.Set).List())
for _, v := range object.Users.User {
users = append(users, v.UserName)
if InArray(v.UserName, localUsers) {
users = append(users, v.UserName)
}
}
d.Set("group_name", d.Id())
if err := d.Set("user_names", users); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/ram_group_membership.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ The following arguments are supported:
* `group_name` - (Required, ForceNew) Name of the RAM group. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.
* `user_names` - (Required) Set of user name which will be added to group. Each name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen.

-> **NOTE:** Before version 1.225.0, when you deleted the resource, **all users under the current group were removed at the same time**;

-> **NOTE:** Since version 1.225.1, removing the current resource will only delete the users declared in the template. **Whi**.

## Attributes Reference

The following attributes are exported:
Expand Down

0 comments on commit f002e1e

Please sign in to comment.