# cdk-ecr-deployment
[![Release](https://github.com/cdklabs/cdk-ecr-deployment/actions/workflows/release.yml/badge.svg)](https://github.com/cdklabs/cdk-ecr-deployment/actions/workflows/release.yml)
[![npm version](https://img.shields.io/npm/v/cdk-ecr-deployment)](https://www.npmjs.com/package/cdk-ecr-deployment)
[![PyPI](https://img.shields.io/pypi/v/cdk-ecr-deployment)](https://pypi.org/project/cdk-ecr-deployment)
[![npm](https://img.shields.io/npm/dw/cdk-ecr-deployment?label=npm%20downloads)](https://www.npmjs.com/package/cdk-ecr-deployment)
[![PyPI - Downloads](https://img.shields.io/pypi/dw/cdk-ecr-deployment?label=pypi%20downloads)](https://pypi.org/project/cdk-ecr-deployment)
CDK construct to synchronize single docker image between docker registries.
**Only use v3 of this package**
⚠️ Version 2.* is no longer supported, as the Go.1.x runtime is no longer supported in AWS Lambda.\
⚠️ Version 1.* is no longer supported, as CDK v1 has reached the end-of-life
stage.
## Features
* 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`.
## Examples
```python
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",
src=ecrdeploy.DockerImageName(image.image_uri),
dest=ecrdeploy.DockerImageName(f"{cdk.Aws.ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/my-nginx:latest")
)
# Copy from docker registry to ECR.
ecrdeploy.ECRDeployment(self, "DeployDockerImage2",
src=ecrdeploy.DockerImageName("nginx:latest"),
dest=ecrdeploy.DockerImageName(f"{cdk.Aws.ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/my-nginx2:latest")
)
# 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'),
dest=ecrdeploy.DockerImageName(f"{cdk.Aws.ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/my-nginx3:latest")
).add_to_principal_policy(iam.PolicyStatement(
effect=iam.Effect.ALLOW,
actions=["secretsmanager:GetSecretValue"
],
resources=["*"]
))
```
## Sample: [test/example.ecr-deployment.ts](./test/example.ecr-deployment.ts)
```shell
# Run the following command to try the sample.
NO_PREBUILT_LAMBDA=1 npx cdk deploy -a "npx ts-node -P tsconfig.dev.json --prefer-ts-exts test/example.ecr-deployment.ts"
```
## [API](./API.md)
## Tech Details & Contribution
The core of this project relies on [containers/image](https://github.com/containers/image) which is used by [Skopeo](https://github.com/containers/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](https://github.com/containers/image/blob/master/types/types.go). You could take a look at [docker-archive](https://github.com/containers/image/blob/ccb87a8d0f45cf28846e307eb0ec2b9d38a458c2/docker/archive/transport.go) transport for a good start.
To test the `lambda` folder, `make test`.
Raw data
{
"_id": null,
"home_page": "https://github.com/cdklabs/cdk-ecr-deployment",
"name": "cdk-ecr-deployment",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Amazon Web Services<aws-cdk-dev@amazon.com>",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/b9/d3/4dc48db68948ead3dc8bcc43f58080f83763511c52e97dfc638a40ad45c1/cdk_ecr_deployment-3.1.3.tar.gz",
"platform": null,
"description": "# cdk-ecr-deployment\n\n[![Release](https://github.com/cdklabs/cdk-ecr-deployment/actions/workflows/release.yml/badge.svg)](https://github.com/cdklabs/cdk-ecr-deployment/actions/workflows/release.yml)\n[![npm version](https://img.shields.io/npm/v/cdk-ecr-deployment)](https://www.npmjs.com/package/cdk-ecr-deployment)\n[![PyPI](https://img.shields.io/pypi/v/cdk-ecr-deployment)](https://pypi.org/project/cdk-ecr-deployment)\n[![npm](https://img.shields.io/npm/dw/cdk-ecr-deployment?label=npm%20downloads)](https://www.npmjs.com/package/cdk-ecr-deployment)\n[![PyPI - Downloads](https://img.shields.io/pypi/dw/cdk-ecr-deployment?label=pypi%20downloads)](https://pypi.org/project/cdk-ecr-deployment)\n\nCDK construct to synchronize single docker image between docker registries.\n\n**Only use v3 of this package**\n\n\u26a0\ufe0f Version 2.* is no longer supported, as the Go.1.x runtime is no longer supported in AWS Lambda.\\\n\u26a0\ufe0f Version 1.* is no longer supported, as CDK v1 has reached the end-of-life\nstage.\n\n## Features\n\n* Copy image from ECR/external registry to (another) ECR/external registry\n* Copy an archive tarball image from s3 to ECR/external registry\n\n## Environment variables\n\nEnable flags: `true`, `1`. e.g. `export CI=1`\n\n* `CI` indicate if it's CI environment. This flag will enable building lambda from scratch.\n* `NO_PREBUILT_LAMBDA` disable using prebuilt lambda.\n* `FORCE_PREBUILT_LAMBDA` force using prebuilt lambda.\n\n\u26a0\ufe0f If you want to force using prebuilt lambda in CI environment to reduce build time. Try `export FORCE_PREBUILT_LAMBDA=1`.\n\n## Examples\n\n```python\nfrom aws_cdk.aws_ecr_assets import DockerImageAsset\n\n\nimage = DockerImageAsset(self, \"CDKDockerImage\",\n directory=path.join(__dirname, \"docker\")\n)\n\n# Copy from cdk docker image asset to another ECR.\necrdeploy.ECRDeployment(self, \"DeployDockerImage1\",\n src=ecrdeploy.DockerImageName(image.image_uri),\n dest=ecrdeploy.DockerImageName(f\"{cdk.Aws.ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/my-nginx:latest\")\n)\n\n# Copy from docker registry to ECR.\necrdeploy.ECRDeployment(self, \"DeployDockerImage2\",\n src=ecrdeploy.DockerImageName(\"nginx:latest\"),\n dest=ecrdeploy.DockerImageName(f\"{cdk.Aws.ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/my-nginx2:latest\")\n)\n\n# Copy from private docker registry to ECR.\n# The format of secret in aws secrets manager must be plain text! e.g. <username>:<password>\necrdeploy.ECRDeployment(self, \"DeployDockerImage3\",\n src=ecrdeploy.DockerImageName(\"javacs3/nginx:latest\", \"username:password\"),\n # src: new ecrdeploy.DockerImageName('javacs3/nginx:latest', 'aws-secrets-manager-secret-name'),\n # src: new ecrdeploy.DockerImageName('javacs3/nginx:latest', 'arn:aws:secretsmanager:us-west-2:000000000000:secret:id'),\n dest=ecrdeploy.DockerImageName(f\"{cdk.Aws.ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/my-nginx3:latest\")\n).add_to_principal_policy(iam.PolicyStatement(\n effect=iam.Effect.ALLOW,\n actions=[\"secretsmanager:GetSecretValue\"\n ],\n resources=[\"*\"]\n))\n```\n\n## Sample: [test/example.ecr-deployment.ts](./test/example.ecr-deployment.ts)\n\n```shell\n# Run the following command to try the sample.\nNO_PREBUILT_LAMBDA=1 npx cdk deploy -a \"npx ts-node -P tsconfig.dev.json --prefer-ts-exts test/example.ecr-deployment.ts\"\n```\n\n## [API](./API.md)\n\n## Tech Details & Contribution\n\nThe core of this project relies on [containers/image](https://github.com/containers/image) which is used by [Skopeo](https://github.com/containers/skopeo).\nPlease take a look at those projects before contribution.\n\nTo support a new docker image source(like docker tarball in s3), you need to implement [image transport interface](https://github.com/containers/image/blob/master/types/types.go). You could take a look at [docker-archive](https://github.com/containers/image/blob/ccb87a8d0f45cf28846e307eb0ec2b9d38a458c2/docker/archive/transport.go) transport for a good start.\n\nTo test the `lambda` folder, `make test`.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "CDK construct to deploy docker image to Amazon ECR",
"version": "3.1.3",
"project_urls": {
"Homepage": "https://github.com/cdklabs/cdk-ecr-deployment",
"Source": "https://github.com/cdklabs/cdk-ecr-deployment"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d57260989f14651b164c057fa95df85a733d35363cd88c9c714016156633c437",
"md5": "71f1192171c39cc634c4e60482464c99",
"sha256": "1ca74a7fc31976503c6051988eda7fd5b9d293bb341956918121da348cb55969"
},
"downloads": -1,
"filename": "cdk_ecr_deployment-3.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "71f1192171c39cc634c4e60482464c99",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 1448973,
"upload_time": "2025-01-01T18:22:08",
"upload_time_iso_8601": "2025-01-01T18:22:08.450756Z",
"url": "https://files.pythonhosted.org/packages/d5/72/60989f14651b164c057fa95df85a733d35363cd88c9c714016156633c437/cdk_ecr_deployment-3.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b9d34dc48db68948ead3dc8bcc43f58080f83763511c52e97dfc638a40ad45c1",
"md5": "33c7df8b2762d0e9ec65bb7e1bdb9a98",
"sha256": "37829c9c2c43f2f32766d3c4695d3b9a8c24a33c9108f2c5bd2111b779224a8e"
},
"downloads": -1,
"filename": "cdk_ecr_deployment-3.1.3.tar.gz",
"has_sig": false,
"md5_digest": "33c7df8b2762d0e9ec65bb7e1bdb9a98",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 1450457,
"upload_time": "2025-01-01T18:22:11",
"upload_time_iso_8601": "2025-01-01T18:22:11.698561Z",
"url": "https://files.pythonhosted.org/packages/b9/d3/4dc48db68948ead3dc8bcc43f58080f83763511c52e97dfc638a40ad45c1/cdk_ecr_deployment-3.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-01 18:22:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cdklabs",
"github_project": "cdk-ecr-deployment",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cdk-ecr-deployment"
}