aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

(ecr-deployment): Native solution for pushing container images to named ECR repositories #31467

Open athewsey opened 2 months ago

athewsey commented 2 months ago

Describe the feature

A fully-supported, CDK-native way to stage container image assets to named ECR repositories, similar to how s3-deployment supports staging assets to S3.

Use Case

This has been a known gap for some time, and the aws-ecr-assets README still references issue #12597 which was actually accepted by the CDK team but then closed (incorrectly I would argue) without a solution getting rolled in to aws-cdk itself.

There are a range of reasons to want to stage container images defined in CDK stacks to named repositories rather than just the CDK-managed one: Both for philosophical environment tidiness; use-cases where developers need to access the images by name; and for setting up secure IAM permissions (since repository ARNs are name-dependent).

The non-native solutions under CDKLabs have struggled with persistent bugs and lack of maintenance (e.g. cdk-ecr-deployment#478, cdk-ecr-deployment#651, cdk-ecr-deployment#380, cdk-docker-image-deployment#433, etc)

Proposed Solution

A construct or sub-module (aws-ecr-deployment maybe?), maintained within this aws-cdk repository itself, for loading container image assets to named ECR repositories.

Other Information

I would be totally fine if the solution here is to re-open the original issue that's still mentioned on the README and close this one as a duplicate - but right now the docs are directing users to +1 an issue that's already been closed.

Acknowledgements

CDK version used

2.140.0

Environment details (OS name and version, etc.)

macOS

tmokmss commented 2 months ago

jfyi there is another non-native solution: ContainerImageBuild.

You can push a container image to any ECR repository with arbitrary image tag:

import { ContainerImageBuild } from 'deploy-time-build';

const image = new ContainerImageBuild(this, 'BuildImage', {
    directory: 'example-image',
    repository: repository,
    tag: 'foo',
});

with additonal configurations such as zstd compression or deploy-time build args injection.

pahud commented 2 months ago

Thank you. We recommend https://github.com/cdklabs/cdk-ecr-deployment at this moment.

Your feedback is very important. I'll bring it to the team's attention.

mrgrain commented 1 month ago

We would like to support this as part of the regular asset publishing. However this will likely require some major changes how assets are handled. We are committed to delivering this eventually. The help has prioritize, please keep commenting and +1 this issue, and let your contacts at AWS know (if available). The current prioritization plan can be seen here: https://github.com/aws/aws-cdk/blob/main/ROADMAP.md