@pgarbe/cdk-ecr-sync
v0.5.39
Published
An CDK Construct to synchronizes Docker images from Docker Hub to ECR.
Downloads
2,149
Readme
CDK ECR Sync
An CDK Construct to synchronizes Docker images from Docker Hub to ECR.
Why should you use it?
- Avoid DockerHub throttling
- Better availability (ECR: 99.9%, DockerHub: "as is")
- 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.