Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@pgarbe/cdk-ecr-sync

pgarbe2.1kApache-2.00.5.39TypeScript support: included

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

cdk, ecr

readme

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.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.5.10 (2021-03-09)

Bug Fixes

0.5.9 (2021-03-09)

Features

  • explicitly use nodejs12 runtime (0e82d55)

0.5.8 (2021-02-06)

0.5.7 (2020-12-10)

0.5.6 (2020-11-20)

0.5.5 (2020-11-18)

Bug Fixes

  • Repo prefix has not been used in sync (ef04119)

0.5.4 (2020-11-18)

Features

  • ability to prefix ECR repositories (30e38d6), closes #414

Bug Fixes

  • Ignore tags where no matching manifest exists for linux/amd64 (a41716d)

0.5.3 (2020-10-09)

0.5.2 (2020-10-09)

Bug Fixes

  • only exclude filters were not applied (a102bba)

0.5.1 (2020-10-07)

0.5.0 (2020-10-07)

Features

  • Support multiple include and exclude tags (db684c7)

0.4.2 (2020-10-02)

Bug Fixes

  • log image tag and digest properly (d5d1d36)
  • write tags to trigger file (de10af4)

0.4.1 (2020-10-02)

Bug Fixes

  • Pagination with ECR and digest comparison (af452ae), closes #331

0.4.0 (2020-10-01)

Features

  • Better support for official images from Docker (c2f1af0), closes #321
  • Useful option to reduce number of tags (e2ced6b), closes #73

0.3.2 (2020-09-06)

0.3.1 (2020-09-06)

Bug Fixes

  • wrong dependency in example (e3bcf71)