Git Product home page Git Product logo

robin's Introduction

Robin

Note that ECR Lifecycle Policies may be a better fit for you use case.

cicd Dependencies

Batman's very capable side kick - deletes old ECR images.

Why Robin?

Images stored in ECR incur monthly data storage charges, this means paying to store old images that are no longer in use. Also, AWS ECR has a default limit of 1000 images. Therefore, it is desirable to ensure the ECR repositories are kept clean of unused images.

What we delete currently:

Per Lambda invocation:

  • 100 images that are older than 30 days and that do not have tags that contain 'master' or 'main'

If you need to delete more than 100 images, rather than complicating this script so that it can paginate through all pages of images, we suggest you simply run the lambda multiple times.

Usage

  1. Authenticate and get AWS credentials via your preferred CLI, you may need to export the environment variables directly

  2. Update the environment variables in serverless.yml to match your setup

  3. Update the repoNames array in handler.js to reflect the repositories you want to clean

  4. Lint the function

    $ npm run lint
    
  5. Run Prettier

    $ npm run prettier:check
    
  6. Test the function

    $ npm test
    
  7. Deploy the function

    # Describe REPO_NAMES at deploy time
    
    $ REPO_NAMES="test_repo,test_repo_1,test_repo_2" AWS_ACCOUNT_ID=1234567890 npm run deploy
    
  8. Tail cloudwatch logs

    $ npm run tail-logs
    

TODO

  • Only keep the last 10 master/main images (justification: we should be using the last images only, last 10 gives us something to rollback to if needed.)
  • Add some more documentation to this readme
  • Delete all untagged images
  • Make tagging convention configurable

robin's People

Contributors

angelling11 avatar hlmartin avatar kleeut avatar nicklaw5 avatar pennyzzzz avatar ramesius avatar sevaine avatar willfalconer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

robin's Issues

Invoke a lambda function per repository

Deleting images in one repository takes some time, so it might be better to trigger a lambda per repository name to avoid running into lambda Maximum execution duration per request limits (currently 300 seconds).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.