Skip to main content

CDK construct to deploy docker image to Amazon ECR

Project description


Release npm version PyPI npm PyPI - Downloads

CDK construct to synchronize single docker image between docker registries.

⚠️ Version 1.* is no longer supported, as CDK v1 has reached the end-of-life stage. Please use only ^2.0.0.


  • Copy image from ECR/external registry to (another) ECR/external registry
  • Copy an archive tarball image from s3 to ECR/external registry

Environment variables

Enable flags: true, 1. e.g. export CI=1

  • CI indicate if it's CI environment. This flag will enable building lambda from scratch.
  • NO_PREBUILT_LAMBDA disable using prebuilt lambda.
  • FORCE_PREBUILT_LAMBDA force using prebuilt lambda.

⚠️ If you want to force using prebuilt lambda in CI environment to reduce build time. Try export FORCE_PREBUILT_LAMBDA=1.

⚠️ The above flags are only available in cdk-ecr-deployment 2.x.


from aws_cdk.aws_ecr_assets import DockerImageAsset

image = DockerImageAsset(self, "CDKDockerImage",
    directory=path.join(__dirname, "docker")

# Copy from cdk docker image asset to another ECR.
ecrdeploy.ECRDeployment(self, "DeployDockerImage1",

# Copy from docker registry to ECR.
ecrdeploy.ECRDeployment(self, "DeployDockerImage2",

# Copy from private docker registry to ECR.
# The format of secret in aws secrets manager must be plain text! e.g. <username>:<password>
ecrdeploy.ECRDeployment(self, "DeployDockerImage3",
    src=ecrdeploy.DockerImageName("javacs3/nginx:latest", "username:password"),
    # src: new ecrdeploy.DockerImageName('javacs3/nginx:latest', 'aws-secrets-manager-secret-name'),
    # src: new ecrdeploy.DockerImageName('javacs3/nginx:latest', 'arn:aws:secretsmanager:us-west-2:000000000000:secret:id'),

Sample: test/example.ecr-deployment.ts

# Run the following command to try the sample.
NO_PREBUILT_LAMBDA=1 npx cdk deploy -a "npx ts-node -P --prefer-ts-exts test/example.ecr-deployment.ts"


Tech Details & Contribution

The core of this project relies on containers/image which is used by Skopeo. Please take a look at those projects before contribution.

To support a new docker image source(like docker tarball in s3), you need to implement image transport interface. You could take a look at docker-archive transport for a good start.

To test the lambda folder, make test.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-ecr-deployment-2.5.30.tar.gz (1.8 MB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page