Lesson 3: Atlas User Management / Learn

Code Summary: Atlas User Management

The following code demonstrates how to manage users by using the Atlas CLI.

Retrieve the Organization ID

To retrieve the organization ID, use the atlas organizations list command with the --name option, which specifies the name of the organization that we want the ID for.

atlas organizations list --name atlas-security

Adding a User to an Organization

To add a user, use the atlas organizations invitations invite <email> command with the following options:

  • --orgId ID for the organizations
  • --role for the role assigned to the user
  • atlas organizations invitations invite john.mackay9001@gmail.com --orgId <Organization-ID> --role ORG_READ_ONLY
    

Retrieve the Project ID

To retrieve the project ID, use the atlas projects list command with the --orgId option to specify the ID of the organization.

atlas projects list --orgId <Organization-ID>

Add a User to a Project

To add a user to a project by using the Atlas CLI, use the atlas projects invitations invite <email> command with the following options:

  • --projectId for the ID of the project to add the user to
  • --role for the user’s project role
  • atlas projects invitations invite john.mackay9001@gmail.com --projectId <projectId> --role GROUP_DATA_ACCESS_READ_WRITE
    
    

List Users

To list the users of a project, use the atlas projects users list command with the --projectId option, which specifies the project ID.

atlas projects users list --projectId <projectId>

Remove a User from a Project

To remove a user from a project, first list all users to find the user ID.

atlas projects users list --projectId <projectId> --output json

Then, use the atlas projects users delete command with the --projectId option to specify the ID of the project that we are removing the user from.

atlas projects users delete <ID> --projectId <projectId>