@tekorka/cloudorkabe
v1.1.6
Published
CLI tool for managing AWS Cognito users
Downloads
8
Readme
Cognito Manager CLI
A comprehensive command-line tool for managing AWS Cognito users and groups.
Features
- List users in groups with filtering options
- Add users to groups (batch and single mode)
- Remove users from groups (batch and single mode)
- Edit user attributes
- Reset/change user passwords
- Batch cleanup of users based on allowed lists
- Multi-pool support with configuration
Installation
# Clone the repository
git clone https://github.com/yourusername/cognito-manager.git
# Install dependencies
cd cognito-manager
npm install
# Link the CLI globally (optional)
npm linkAWS SDK Migration Notice
Important: This project currently uses AWS SDK v2, which is in maintenance mode. Migration to AWS SDK v3 is planned.
The AWS SDK for JavaScript v2 is now in maintenance mode. It will continue to receive critical bug fixes and security patches but no new features. We recommend migrating to AWS SDK v3 for future development.
See scripts/batch-remove-users.js for examples of both AWS SDK v2 and v3 implementations.
Configuration
Create a config file at ~/.cognito-manager.json:
{
"userPoolId": "us-west-2_example",
"defaultGroup": "Users"
}Or create a pools.json file in your project root:
{
"default": "us-west-2_example",
"pools": [
{
"name": "Production",
"id": "us-west-2_example",
"region": "us-west-2"
},
{
"name": "Staging",
"id": "us-east-1_example",
"region": "us-east-1"
}
]
}Usage
Using the CLI
# Get help
cognito-manager --help
# List users in a group
cognito-manager list --group Users
# Add a user to a group
cognito-manager add --username [email protected] --group Users
# Remove a user from a group
cognito-manager remove --username [email protected] --group Users
# Batch remove users not in an allowed list
cognito-manager batch-remove --file allowed-emails.txt --group Users
# Cleanup users (alias for batch-remove)
cognito-manager cleanup --file allowed-emails.txt --group Users
# Edit user attributes
cognito-manager edit --username [email protected] --attribute "name=John Doe"
# Reset a user's password
cognito-manager password --username [email protected] --reset
# Switch between pools
cognito-manager pool --selectUsing the Scripts
For batch operations, you can use the provided scripts:
# Batch remove users not in an allowed list (standalone script)
npm run batch-remove allowed-emails.txt
# Batch remove using the CLI
npm run batch-remove-cli allowed-emails.txtMigrating from working-with-users.js
If you were previously using the working-with-users.js script, you can now use the batch-remove command:
# Old way
node working-with-users.js allowed-emails.txt
# New way (standalone script)
node scripts/batch-remove-users.js allowed-emails.txt
# New way (CLI)
cognito-manager batch-remove --file allowed-emails.txt --group BETALicense
MIT
