-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(ecr-assets): add custom ECR repository and image tagging sup… #35251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oyiz-michael
wants to merge
40
commits into
aws:main
Choose a base branch
from
oyiz-michael:feature/ecr-custom-repository-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
4628449
feat(aws-ecr-assets): add custom ECR repository and image tagging sup…
oyiz-michael de66de8
feat(aws-ecr-assets): add integration tests for custom repository sup…
oyiz-michael 57021cd
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 02c27a4
Update packages/aws-cdk-lib/aws-ecr-assets/lib/image-asset.ts
oyiz-michael c207cea
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 07333ae
Update packages/aws-cdk-lib/aws-ecr-assets/README.md
oyiz-michael 0e230fc
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 85815ee
fix: lint issues in ECR custom repository implementation
oyiz-michael c7cb941
fix: remove integration test causing circular dependency
oyiz-michael 3d8eabb
fix: resolve circular dependency by deactivating problematic integrat…
oyiz-michael 8db24bd
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael ebc30ca
Merge branch 'aws:main' into feature/ecr-custom-repository-support
oyiz-michael bb0107d
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael b6fbd32
fix(aws-ecr-assets): add missing test fixtures for custom repository …
oyiz-michael 3acf387
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 010e840
feat: rebuild ECR custom repository test suite with comprehensive Clo…
oyiz-michael 8bc1d74
feat: reactivate pnpm dependencies integration test
oyiz-michael 01ebb8a
fix: add missing IntegTest declaration for ECR custom repository inte…
oyiz-michael 239a9f0
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 8ecaf7b
fix trailing space
oyiz-michael 7dd7680
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael b32951d
fix: remove corrupted integ.custom-repository snapshot
oyiz-michael 5640e23
feat: regenerate integ.custom-repository snapshot with correct refere…
oyiz-michael 3326be3
fix: add token check before imageUri replacement
oyiz-michael c1ad2ef
fix: use Annotations.addError instead of throwing error for token check
oyiz-michael b2cd85b
fix: regenerate integ.custom-repository snapshot with actual AWS depl…
oyiz-michael eaff018
fix: return early after token validation error
oyiz-michael 4a1cba6
test: update integ.custom-repository snapshot with correct custom tag…
oyiz-michael 99122a3
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael bad5072
fix: handle unresolved tokens in custom tag implementation
oyiz-michael 5eb0555
feat(core): support per-asset custom image tags in synthesizer
oyiz-michael 41a1060
fix: remove trailing spaces in asset-manifest-builder
oyiz-michael 15d497a
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 6f2f5a5
test: update integration test snapshot for custom ECR tags
oyiz-michael 2fe8039
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 8f10cba
fix(ecr-assets): restore hash calculation for custom repository prope…
oyiz-michael e5caed1
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 5450875
Merge branch 'main' into feature/ecr-custom-repository-support
oyiz-michael 353c26f
docs(aws-ecr-assets): clarify usage of externally managed ECR reposit…
4c1f6ce
test(aws-ecr-assets): update integration test snapshots for README ch…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
packages/aws-cdk-lib/aws-ecr-assets/test/custom-repository.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| import * as path from 'path'; | ||
| import * as ecr from '../../aws-ecr'; | ||
| import { App, Stack } from '../../core'; | ||
| import { DockerImageAsset } from '../lib'; | ||
|
|
||
| describe('DockerImageAsset Custom Repository Support', () => { | ||
| let app: App; | ||
| let stack: Stack; | ||
| let repository: ecr.Repository; | ||
|
|
||
| beforeEach(() => { | ||
| app = new App(); | ||
| stack = new Stack(app, 'TestStack'); | ||
| repository = new ecr.Repository(stack, 'CustomRepo', { | ||
| repositoryName: 'my-custom-repo', | ||
| }); | ||
| }); | ||
|
|
||
| test('should support custom ECR repository', () => { | ||
| // GIVEN | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| ecrRepository: repository, | ||
| }); | ||
|
|
||
| // THEN | ||
| expect(asset.repository).toBe(repository); | ||
| expect(asset.imageUri).toContain('my-custom-repo'); | ||
| expect(asset.imageTag).toBe(asset.assetHash); | ||
| }); | ||
|
|
||
| test('should support custom image tag with custom repository', () => { | ||
| // GIVEN | ||
| const customTag = 'v1.2.3'; | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| ecrRepository: repository, | ||
| imageTag: customTag, | ||
| }); | ||
|
|
||
| // THEN | ||
| expect(asset.repository).toBe(repository); | ||
| expect(asset.imageUri).toContain(`my-custom-repo:${customTag}`); | ||
| expect(asset.imageTag).toBe(customTag); | ||
| }); | ||
|
|
||
| test('should support custom image tag prefix with custom repository', () => { | ||
| // GIVEN | ||
| const tagPrefix = 'feature-'; | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| ecrRepository: repository, | ||
| imageTagPrefix: tagPrefix, | ||
| }); | ||
|
|
||
| // THEN | ||
| expect(asset.repository).toBe(repository); | ||
| expect(asset.imageUri).toContain(`my-custom-repo:${tagPrefix}${asset.assetHash}`); | ||
| expect(asset.imageTag).toBe(`${tagPrefix}${asset.assetHash}`); | ||
| }); | ||
|
|
||
| test('should support custom tag prefix with default repository', () => { | ||
| // GIVEN | ||
| const tagPrefix = 'branch-main-'; | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| imageTagPrefix: tagPrefix, | ||
| }); | ||
|
|
||
| // THEN | ||
| expect(asset.imageTag).toBe(`${tagPrefix}${asset.assetHash}`); | ||
| expect(asset.imageUri).toContain(`:${tagPrefix}${asset.assetHash}`); | ||
| }); | ||
|
|
||
| test('should support custom tag with default repository', () => { | ||
| // GIVEN | ||
| const customTag = 'release-candidate'; | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| imageTag: customTag, | ||
| }); | ||
|
|
||
| // THEN | ||
| expect(asset.imageTag).toBe(customTag); | ||
| expect(asset.imageUri).toContain(`:${customTag}`); | ||
| }); | ||
|
|
||
| test('should include custom repository in asset hash', () => { | ||
| // GIVEN | ||
| const asset1 = new DockerImageAsset(stack, 'Asset1', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| }); | ||
|
|
||
| const asset2 = new DockerImageAsset(stack, 'Asset2', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| ecrRepository: repository, | ||
| }); | ||
|
|
||
| // THEN - assets should have different hashes due to different repositories | ||
| expect(asset1.assetHash).not.toBe(asset2.assetHash); | ||
| }); | ||
|
|
||
| test('should include custom tag in asset hash', () => { | ||
| // GIVEN | ||
| const asset1 = new DockerImageAsset(stack, 'Asset1', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| imageTag: 'tag1', | ||
| }); | ||
|
|
||
| const asset2 = new DockerImageAsset(stack, 'Asset2', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| imageTag: 'tag2', | ||
| }); | ||
|
|
||
| // THEN - assets should have different hashes due to different tags | ||
| expect(asset1.assetHash).not.toBe(asset2.assetHash); | ||
| }); | ||
|
|
||
| test('should include custom tag prefix in asset hash', () => { | ||
| // GIVEN | ||
| const asset1 = new DockerImageAsset(stack, 'Asset1', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| imageTagPrefix: 'prefix1-', | ||
| }); | ||
|
|
||
| const asset2 = new DockerImageAsset(stack, 'Asset2', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| imageTagPrefix: 'prefix2-', | ||
| }); | ||
|
|
||
| // THEN - assets should have different hashes due to different tag prefixes | ||
| expect(asset1.assetHash).not.toBe(asset2.assetHash); | ||
| }); | ||
|
|
||
| test('imageTag takes precedence over imageTagPrefix', () => { | ||
| // GIVEN | ||
| const customTag = 'explicit-tag'; | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| ecrRepository: repository, | ||
| imageTag: customTag, | ||
| imageTagPrefix: 'should-be-ignored-', | ||
| }); | ||
|
|
||
| // THEN | ||
| expect(asset.imageTag).toBe(customTag); | ||
| expect(asset.imageUri).toContain(`:${customTag}`); | ||
| }); | ||
|
|
||
| test('should maintain backward compatibility', () => { | ||
| // GIVEN | ||
| const asset = new DockerImageAsset(stack, 'MyAsset', { | ||
| directory: path.join(__dirname, 'fixtures/custom-dockerfile'), | ||
| }); | ||
|
|
||
| // THEN - should work exactly like before | ||
| expect(asset.repository).toBeDefined(); | ||
| expect(asset.imageUri).toBeDefined(); | ||
| expect(asset.imageTag).toBe(asset.assetHash); | ||
| }); | ||
| }); |
13 changes: 13 additions & 0 deletions
13
packages/aws-cdk-lib/aws-ecr-assets/test/fixtures/custom-dockerfile/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| FROM public.ecr.aws/lambda/nodejs:18 | ||
|
|
||
| # Copy package files | ||
| COPY package*.json ./ | ||
|
|
||
| # Install dependencies | ||
| RUN npm ci --only=production | ||
|
|
||
| # Copy application code | ||
| COPY app.js ./ | ||
|
|
||
| # Simple test application | ||
| CMD ["app.handler"] |
7 changes: 7 additions & 0 deletions
7
packages/aws-cdk-lib/aws-ecr-assets/test/fixtures/custom-dockerfile/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "test-app", | ||
| "version": "1.0.0", | ||
| "description": "Test application for Docker Image Asset custom repository support", | ||
| "main": "app.js", | ||
| "dependencies": {} | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.