A command-line utility tool for managing and analyzing AWS Elastic Container Registry (ECR) repositories using Node.js and TypeScript.
This tool provides a convenient way to scan and manage AWS ECR repositories using your local AWS profile. It stores repository information in a local SQLite database for quick access and analysis.
- Scan AWS ECR repositories and store repository and image metadata in SQLite database
- List and view repository and image information from the local database
- Terminal-based visualization of repository and image data
- Uses local AWS profile for authentication (or specify with --profile option)
- Built with Node.js, TypeScript, and SQLite3
- Node.js
- TypeScript
- SQLite3
- AWS SDK for JavaScript
- Commander.js (for CLI interface)
- Chalk (for terminal styling)
- Node.js (v14 or higher)
- AWS CLI configured with appropriate credentials
- Make (for using Makefile commands)
- Clone the repository:
git clone https://github.com/yourusername/aws-ecr-utils.git
cd aws-ecr-utils- Install dependencies:
npm install- Build the project:
npm run buildThe tool provides the following commands through the Makefile:
make scan
```bash
make scan AWS_PROFILE=ama AWS_REGION=us-west-2This command will:
- Connect to AWS using your local profile (or specify with AWS_PROFILE=your_profile option)
- Connect to AWS using the specified region (or specify with AWS_REGION=your_region option)
- Delete the existing SQLite database
- Scan all accessible ECR repositories
- Retrieve and store repository and image metadata in the SQLite database
make lsThis command will:
- Read from the local SQLite database
- Display repository information in a formatted table
make statsThis command will:
- Read from the local SQLite database
- Calculate and display the top 20 repositories with the highest number of images
make analyseThis command will:
- Read from the local SQLite database
- Group image tags by repository and show similar tags
- Show key metrics and details for each repository
make suggest
```bash
make suggest AWS_PROFILE=ama AWS_REGION=us-west-2This command will:
- Connect to AWS using your local profile (or specify with AWS_PROFILE=your_profile option)
- Connect to AWS using the specified region (or specify with AWS_REGION=your_region option)
- Read from the local SQLite database
- Suggest images that have never been pulled, grouped by repository
- Prompt the user for confirmation before deleting the images
- Delete the images from ECR if the user confirms
aws-ecr-utils/
├── src/
│ ├── commands/ # CLI command implementations
│ ├── services/ # Business logic and AWS interactions
│ ├── database/ # SQLite database operations (stores repositories and images)
│ └── utils/ # Helper functions and utilities
├── ecr-repos.db # SQLite database file
├── tests/ # Test files
├── Makefile # Build and command definitions
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
- Install development dependencies:
npm install --save-dev- Run tests:
npm test- Start development mode:
npm run devMIT
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
