Lesson 4: Atlas Database User Management / Learn

Code Summary: Atlas Database User Management

The following code demonstrates how to do the following by using the Atlas CLI:

  • Add a database user with a built-in role
  • Add an IP address to the access list
  • Update a user’s role
  • Delete a user from an organization
  • Remove an IP address from the access list

Add a Database User with a Built-In Role

To add a user with a built-in role to an organization, use the atlas dbusers create <ROLE> command with the following options:

  • --username for the username
  • --password for the user’s password
  • --deleteAfter to specify how long to keep the user
  • --projectId to specify the ID of the project
  • atlas dbusers create atlasAdmin --username dba --password dba-pass --deleteAfter 2023-05-11  --projectId <projectId>
    
    

Add an IP Address to the Access List

To add an IP address to the access list, use the atlas accessList create <ip> command with the following options:

  • --type specifies the type of address
  • --projectId specifies the ID of the project
  • atlas accessList create <ip> --type ipAddress --projectId <projectId>

Update a User’s Role

To update a user’s role, use the atlas dbusers update <USERNAME> command with the following options:

  • --role to specify the new role of the user
  • --projectId to specify the ID of the project
  • atlas dbusers update dba --role readWriteAnyDatabase --projectId <projectId>

Delete a User

To delete a user from an organization, use the atlas dbusers delete <USERNAME> command with the --projectId option.

atlas dbusers delete dba --projectId <projectId>

Remove IP Address from the Access List

To remove an IP address from the access list, use the atlas accessList delete <ip> command with the --projectId option.

atlas accessList delete <ip> --projectId <projectId>