Managing IAM User Groups (Part 2)
To Read Part 1, please click here
Attaching a Policy to an IAM User Group
If you want to attach a customer managed policy (a policy with custom permissions that you create), you must first create the policy.
To attach a policy to a user group (console)
- Sign-in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
- Select the User groups and the group's name in the navigation pane.
- Choose the Permissions tab.
- Now you can Add permissions and then Attach policy.
- The Current permissions policies list shows the attached current policies. You can easily choose the names of the policies you want to attach from the list of Other permissions policies.
- Choose Attach policies.
To attach a policy to a user group (AWS CLI or AWS API)
You can do either of the following:
- AWS CLI: aws iam attach-group-policy.
- AWS API: AttachGroupPolicy.
Renaming an IAM User Group
If you change a user group's name or path, then,-
- Any of the policies attached to the user group under the new name.
- The user group retains all its users under the new name.
- The unique ID for the user group remains the same.
To change the name of an IAM user group
You can perform any of the following:
- AWS Management Console- You can choose User Groups and then the group's name in the navigation pane.
- AWS CLI- aws iam update-group.
- AWS API- UpdateGroup.
Deleting an IAM User Group
If a user group is deleted in the AWS Management Console, the console automatically removes all the group members, detaches all the attached policies and deletes all the inline policies; whereas, for AWS CLI, Tools for Windows PowerShell, or AWS API, you have to remove the users in the group first in order to delete a user group.
Deleting an IAM User Group (Console)
It can be easily done via AWS Management Console.
To delete an IAM user group (console)
- Sign-in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
- Select the User groups in the navigation pane.
- Now, you have to select the user groups you want to delete from the list of the user groups.
- Choose Delete.
- Type the user group name (and then select Delete) in the confirmation box, if you want to remove a single user group. However, if multiple user groups are to be deleted, then, you have to type the number of the groups followed by the user groups and then Delete.
Deleting an IAM User Group (AWS CLI)
A user group can also be deleted via AWS CLI.
To delete an IAM user group (AWS CLI)
- Remove all the users from the user group via- aws iam get-group (for listing the users) and then aws iam remove-user-from-group (for removing a user).
- Delete all the inline policies embedded in the user group via- aws iam list-group-polices (for listing the user group's inline policies) and then aws iam delete-group-policy (to delete the inline policies).
- Now you have to detach all the managed policies attached to the user group via- aws iam list-attached-group-polices (for listing the user group's managed policies) and then aws iam detach-group-policy (to delete the managed policy).
- Finally, you can delete the user group via- aws iam delete-group.
Deleting an IAM User Group (AWS API)
A user group can also be deleted via AWS API.
To delete an IAM user group (AWS API)
- Remove all the users from the user group via- GetGroup (for listing the users) and then RemoveUserFromGroup (for removing a user).
- Delete all the inline policies embedded in the user group via- ListGroupPolicies (for listing the user group's inline policies) and then DeleteGroupPolicy (to delete the inline policies).
- Now you have to detach all the managed policies attached to the user group via- ListAttachedGroupPolices (for listing the user group's managed policies) and then DetachGroupPolicy (to delete the managed policy).
- Finally, you can delete the user group via- DeleteGroup.
To Read Part 1, please click here
Comments
Post a Comment