# cdk-ecr-deployment
[](https://github.com/cdklabs/cdk-ecr-deployment/actions/workflows/release.yml)
[](https://www.npmjs.com/package/cdk-ecr-deployment)
[](https://pypi.org/project/cdk-ecr-deployment)
[](https://www.npmjs.com/package/cdk-ecr-deployment)
[](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/6b/87/97c267d7f41c0c36f81efb715b687a0c1bc811fcbed96f6075ecfc4a262e/cdk_ecr_deployment-3.1.8.tar.gz",
"platform": null,
"description": "# cdk-ecr-deployment\n\n[](https://github.com/cdklabs/cdk-ecr-deployment/actions/workflows/release.yml)\n[](https://www.npmjs.com/package/cdk-ecr-deployment)\n[](https://pypi.org/project/cdk-ecr-deployment)\n[](https://www.npmjs.com/package/cdk-ecr-deployment)\n[](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.8",
"project_urls": {
"Homepage": "https://github.com/cdklabs/cdk-ecr-deployment",
"Source": "https://github.com/cdklabs/cdk-ecr-deployment"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "056f8ce864e182fceb2f8bdf8e46a36587544e81da1398f6730f050ac0f9b322",
"md5": "258a0b74f4dba0f7dfa8a6ca05210eb4",
"sha256": "a987946f9aab8451361e14986f4b7a21fe9497fd7dc892ffc695f0c4999ddeed"
},
"downloads": -1,
"filename": "cdk_ecr_deployment-3.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "258a0b74f4dba0f7dfa8a6ca05210eb4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 1441541,
"upload_time": "2025-01-28T18:23:15",
"upload_time_iso_8601": "2025-01-28T18:23:15.978314Z",
"url": "https://files.pythonhosted.org/packages/05/6f/8ce864e182fceb2f8bdf8e46a36587544e81da1398f6730f050ac0f9b322/cdk_ecr_deployment-3.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6b8797c267d7f41c0c36f81efb715b687a0c1bc811fcbed96f6075ecfc4a262e",
"md5": "f9cff30900360e02d139e25d26db03d3",
"sha256": "98760a0056d2ece17a9de1effa60a773d1365513211f587c6b347c3b62eaf094"
},
"downloads": -1,
"filename": "cdk_ecr_deployment-3.1.8.tar.gz",
"has_sig": false,
"md5_digest": "f9cff30900360e02d139e25d26db03d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 1442955,
"upload_time": "2025-01-28T18:23:17",
"upload_time_iso_8601": "2025-01-28T18:23:17.883110Z",
"url": "https://files.pythonhosted.org/packages/6b/87/97c267d7f41c0c36f81efb715b687a0c1bc811fcbed96f6075ecfc4a262e/cdk_ecr_deployment-3.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-28 18:23:17",
"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"
}