Skip to content

Commit

Permalink
fix(eks): fix helm deploy login for public ECR repositories (#24104)
Browse files Browse the repository at this point in the history
fix helm deploy login for public ECR repositories

I have tested this issue fixed in `us-east-1` and `us-west-2` integ testing for
```
yarn integ-runner integ.eks-helm-asset.js --force --parallel-regions us-east-1
yarn integ-runner integ.eks-helm-asset.js --force --parallel-regions us-west-2
```

Closes #23977.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
zorrofox committed Feb 23, 2023
1 parent 236ecde commit 71ec6b6
Show file tree
Hide file tree
Showing 427 changed files with 7,390 additions and 6,373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_oci_cmd(repository, version):
region = os.environ.get('AWS_REGION', 'us-east-1')

cmnd = [
f"aws ecr-public get-login-password --region {region} | " \
f"aws ecr-public get-login-password --region us-east-1 | " \
f"helm registry login --username AWS --password-stdin {public_registry['registry']}; helm pull {repository} --version {version} --untar"
]
else:
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/kubectl-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export class KubectlProvider extends NestedStack implements IKubectlProvider {
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ContainerRegistryReadOnly'),
);

// For OCI helm chart public ECR authorization.
this.handlerRole.addManagedPolicy(
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonElasticContainerRegistryPublicReadOnly'),
);

// allow this handler to assume the kubectl role
cluster.kubectlRole.grant(this.handlerRole, 'sts:AssumeRole');

Expand Down
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-eks/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,13 @@ describe('cluster', () => {
':iam::aws:policy/AmazonEC2ContainerRegistryReadOnly',
]],
},
{
'Fn::Join': ['', [
'arn:',
{ Ref: 'AWS::Partition' },
':iam::aws:policy/AmazonElasticContainerRegistryPublicReadOnly',
]],
},
],
});
});
Expand Down Expand Up @@ -2297,6 +2304,13 @@ describe('cluster', () => {
':iam::aws:policy/AmazonEC2ContainerRegistryReadOnly',
]],
},
{
'Fn::Join': ['', [
'arn:',
{ Ref: 'AWS::Partition' },
':iam::aws:policy/AmazonElasticContainerRegistryPublicReadOnly',
]],
},
],
});
});
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ function analyzeUpdate(oldProps: Partial<aws.EKS.CreateClusterRequest>, newProps
return {
replaceName: newProps.name !== oldProps.name,
replaceVpc:
JSON.stringify(newVpcProps.subnetIds) !== JSON.stringify(oldVpcProps.subnetIds) ||
JSON.stringify(newVpcProps.securityGroupIds) !== JSON.stringify(oldVpcProps.securityGroupIds),
JSON.stringify(newVpcProps.subnetIds?.sort()) !== JSON.stringify(oldVpcProps.subnetIds?.sort()) ||
JSON.stringify(newVpcProps.securityGroupIds?.sort()) !== JSON.stringify(oldVpcProps.securityGroupIds?.sort()),
updateAccess:
newVpcProps.endpointPrivateAccess !== oldVpcProps.endpointPrivateAccess ||
newVpcProps.endpointPublicAccess !== oldVpcProps.endpointPublicAccess ||
Expand Down

This file was deleted.

Loading

0 comments on commit 71ec6b6

Please sign in to comment.