How to do it...

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:

  1. Create the following users: admin_user and regular_user.
  2. 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:

  1. Create a group called authenticated_users, following the command in the previous step.
  1. 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
  1. Add the user admin_user to the groups administrators and authenticated_usersfollowing the command in the previous step.
  2. 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:

  1. 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:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.163.175