-
Couldn't load subscription status.
- Fork 4.3k
Description
Describe the feature
The KubectlProvider has access to ECR so that it can fetch Helm charts stored in repositories:
aws-cdk/packages/aws-cdk-lib/aws-eks/lib/kubectl-provider.ts
Lines 169 to 172 in ec18b83
| // For OCI helm chart authorization. | |
| this.handlerRole.addManagedPolicy( | |
| iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ContainerRegistryReadOnly'), | |
| ); |
Currently, the KubectlProvider uses the AmazonEC2ContainerRegistryReadOnly policy which works, but it's
- Too broad: for example kubectl doesn't use the "ecr:ListImages" action
- Too narrow: it doesn't include "ecr:BatchImportUpstreamImage" action, which is required to use a pull-through cache.
Reference:
- https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEC2ContainerRegistryPullOnly.html
- https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEC2ContainerRegistryReadOnly.html
Use Case
I discovered this issue when I configured an ECR as a pull-through cache, that is to pull images from another registry (in my case another ECR).
For my EKS setup I granted all my nodes the AmazonEC2ContainerRegistryPullOnly role, but I couldn't install Helm charts from ECR, using the CDK, because kubectl couldn't use the caching ECR repository because its policy doesn't allow the ecr:BatchImportUpstreamImage action.
Proposed Solution
I suggest to replace the AmazonEC2ContainerRegistryReadyOnly managed policy with AmazonEC2ContainerRegistryPullOnly in the KubectlProvider's code.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
AWS CDK Library version (aws-cdk-lib)
2.204.0
AWS CDK CLI version
2.1020.2 (build cf35f57)
Environment details (OS name and version, etc.)
macOS