Skip to content

Commit 386fca3

Browse files
fix(eks): update private ecr repo url regex (#31394)
### Issue # (if applicable) ### Reason for this change The regex for private ECR repos currently excludes some supported URLs in AWS regions. Updating the regex to be more inclusive of all AWS regions. ### Description of changes Modified private ECR repo URL to be domain agnostic. ### Description of how you validated changes All existing tests pass: - `npx cdk -a test/aws-eks/test/integ.eks-helm-asset.js deploy --all` - `yarn test aws-eks` - `yarn integ --directory test/aws-eks/test` Manually updated lambda function highside to verify change works in isolated regions as well. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 84701d6 commit 386fca3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/kubectl-handler/helm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def helm_handler(event, context):
101101

102102
def get_oci_cmd(repository, version):
103103
# Generates OCI command based on pattern. Public ECR vs Private ECR are treated differently.
104-
private_ecr_pattern = 'oci://(?P<registry>\d+\.dkr\.ecr\.(?P<region>[a-z0-9\-]+)\.amazonaws\.com(\.cn)?)*'
104+
private_ecr_pattern = 'oci://(?P<registry>\d+\.dkr\.ecr\.(?P<region>[a-z0-9\-]+)\.(?P<domain>[a-z0-9\.-]+))*'
105105
public_ecr_pattern = 'oci://(?P<registry>public\.ecr\.aws)*'
106106

107107
private_registry = re.match(private_ecr_pattern, repository).groupdict()

packages/aws-cdk-lib/aws-eks/test/helm-chart.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,15 @@ describe('helm chart', () => {
272272
// THEN
273273
Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { SkipCrds: true });
274274
});
275+
test('should use private ecr repo when specified', () => {
276+
// GIVEN
277+
const { stack, cluster } = testFixtureCluster();
278+
279+
// WHEN
280+
new eks.HelmChart(stack, 'MyPrivateChart', { cluster, chart: 'chart', repository: 'oci://012345678.dkr.ecr.us-east-1.amazonaws.com/private-repo' });
281+
282+
// THEN
283+
Template.fromStack(stack).hasResourceProperties(eks.HelmChart.RESOURCE_TYPE, { Repository: 'oci://012345678.dkr.ecr.us-east-1.amazonaws.com/private-repo' });
284+
});
275285
});
276286
});

0 commit comments

Comments
 (0)