@pgarbe/cdk-ecr-sync
TypeScript icon, indicating that this package has built-in type declarations

0.5.38 • Public • Published

CDK ECR Sync

An CDK Construct to synchronizes Docker images from Docker Hub to ECR.

Why should you use it?

  1. Avoid DockerHub throttling
  2. Better availability (ECR: 99.9%, DockerHub: "as is")
  3. Possible less data transfer costs (ECS pulls from ECR in same region are free)

See also my blog post: https://garbe.io/blog/2020/04/22/cdk-ecr-sync/

How to use it

In your CDK application, run npm install @pgarbe/cdk-ecr-sync and add the following construct:

const ecrSync = new EcrSync(this, 'ecrSync', {
  repoPrefix: 'dockerhub-mirror', // optional prefix
  dockerImages: [
    {
      imageName: 'datadog/agent',
      excludeTags: [  // Use RegEx expressions to exclude specific tags
        'latest',
        '^1.0'
      ],
    }
  ],
  lifcecyleRule: {...} // Optional lifecycle rule for ECR repos
});

// Allow all accounts in your organization to pull
ecrSync.grantPull(new iam.OrganizationalPrincipal('o-123456'));

See also examples folder.

Trigger the sync manually

Look up for a lambda called *ecrSync*%*, add an empty test event, and execute it. The lambda will check which images needs to be synced and trigger a CodePipeline.

Readme

Keywords

Package Sidebar

Install

npm i @pgarbe/cdk-ecr-sync

Weekly Downloads

363

Version

0.5.38

License

Apache-2.0

Unpacked Size

100 MB

Total Files

2894

Last publish

Collaborators

  • pgarbe