node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »



Code Climate JavaScript Style Guide Coverage Status Build

An AWS Lambda Function to clean ecr repos automatically.


  • node.js ( AWS Lambda working version is 4.3.2 )


Clone this repository and install dependencies:

$ git clone
cd aws-lambda-ecr-cleaner
$ npm install


AWS Lambda accepts zip archived package. To create it, run npm run package task simply.

$ npm run package --packageDirectory=./dist

It will create at project root. You can upload it.


Hardcode the configuration on config.json

Use AWS Environment Variables

Name Type Description Default
DRY_RUN Bool Run without delete true
API_DELAY Integer Delay between calls 500
REPO_AGE_THRESHOLD Integer Image age threshold 90
REPO_FIRST_N_THRESHOLD Integer How many images from each group to keep 3
AWS_ACCOUNT_ID Integer The account id number
REGION String ECR and ECS region. us-east-1
REPO_TO_CLEAN String / Array String One repo name or an array of repos name to clean
ENVS Array String Group by these strings and one for each unique tag


MIT License @ Shy Alter