Create a group
Create a group of IAM users, add users to it and attach the policies they share.
Every member of a group holds every policy attached to it, so you attach a policy once instead of to each user. A user in three groups holds the policies of all three. Replace developers with the group's name, and group-id, user-id and policy-id with ids.
Prerequisites
- Permission for
iam:CreateGroup,iam:AddUserToGroupandiam:AttachGroupPolicy. - To take a user out or detach a policy,
iam:RemoveUserFromGrouporiam:DetachGroupPolicy; to delete the group,iam:DeleteGroup. - In the console, also
iam:ListGroupsto see Groups, andiam:GetGroupon the group to open its page (without it the page is not found).
Create the group and fill it
- Open Identity, then choose Groups.
- Choose Create group. Enter the name developers and, optionally, a description.
- Choose Create group. The group's page opens.
- Choose Members, pick a user from the list, then choose Add. Repeat for each user.
- Choose Permissions, pick a policy from the list, then choose Attach. Repeat for each policy.
dcloud iam groups create --name developers
dcloud iam groups add-member group-id --iam-user-id user-id
dcloud iam groups attach-policy group-id --policy-id policy-idPOST /iam/api/groups
{ "name": "developers", "description": "Everyone who builds the app" }Then POST /iam/api/groups/{id}/members with {"iamUserId": …} and
POST /iam/api/groups/{id}/policies with {"policyId": …}.
resource "dcloud_iam_group" "developers" {
name = "developers"
}
resource "dcloud_iam_group_membership" "alice_developers" {
group_id = dcloud_iam_group.developers.id
user_id = dcloud_iam_user.alice.id
}
resource "dcloud_iam_group_policy_attachment" "developers_read" {
group_id = dcloud_iam_group.developers.id
policy_id = dcloud_iam_policy.s3_read.id
}Result
Users added to the group hold its policies from their next request on. Removing a user, or detaching a policy, takes the permissions away at once. A group holds IAM users only, not other groups.
To delete the group, open it and choose Danger zone, then Delete group, and type its name
(dcloud iam groups delete). Its members lose the permissions it carried.
If a change is refused
- 404
Group not found,IAM user not found, orGroup or policy not foundfor an id that is not in your organization. - 409
Quota exceeded: …when the organization has as many groups as its quota allows; see Quotas.