We will look at how to create a group, how to add users to it, and finally, how to check a user for their groups:
- Create the following users: admin_user and regular_user.
- Create a group called administrators, as follows:
aws cognito-idp create-group
--group-name 'administrators'
--user-pool-id us-east-1_fYsb1Gyec
--description 'Administrator Group'
--profile admin
If this is successful, it should return the following response:
- Create a group called authenticated_users, following the command in the previous step.
- Add the user regular_user to the authenticated_users, as follows:
aws cognito-idp admin-add-user-to-group
--user-pool-id us-east-1_fYsb1Gyec
--username regular_user
--group-name authenticated_users
--profile admin
- Add the user admin_user to the groups administrators and authenticated_users, following the command in the previous step.
- Check for the groups that admin_user belongs to, as follows:
aws cognito-idp admin-list-groups-for-user
--username admin_user
--user-pool-id us-east-1_fYsb1Gyec
--profile admin
If this is successful, it should return the details of the two groups to which the user admin_user belongs, as follows:
- Check for the groups that regular_user belongs to, following the command in the previous step.
If this is successful, it should return the details of the one group to which the user regular_user belongs, as follows: