CDK construct library that helps you build a garbage collector to delete all untagged images in Amazon ECR public with AWS CDK.
Amazon ECR public does not have lifecycle policy to clean up all untagged images at this moment(see this issue). cdk-ecrpublic-gc
allows you to deploy a AWS Step Functions state machine with dynamic parallelism to invoke an arbitrary of Lambda functions to remove untagged images to release the storage.
By default, the state machine will be triggered every 4 hours and can be configured in the schedule
property in the TidyUp
construct.
import * as cdk from '@aws-cdk/core';
import { TidyUp } from 'cdk-ecrpublic-gc';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'ecr-public-gc');
new TidyUp(stack, 'TidyUp', {
repository: [
'vscode',
'gitpod-workspace',
'github-codespace',
],
schedule: events.Schedule.cron({ hour: '*/4', minute: '0' }),
});