Commit 1b6e962
authored
fix(eks): kubectlProvider should use the AmazonEC2ContainerRegistryPullOnly managed policy (#35248)
### Issue
Closes #35244
### Problem Statement
The current KubectlProvider implementation uses the AmazonEC2ContainerRegistryReadOnly managed policy for ECR access, which has two key limitations:
1. Too broad: Includes unnecessary permissions like ecr:ListImages that kubectl doesn't require
2. Too narrow: Missing the ecr:BatchImportUpstreamImage action required for ECR pull-through cache functionality
This prevents users from leveraging ECR pull-through caches when installing Helm charts from ECR repositories via the CDK.
### Solution
Replace `AmazonEC2ContainerRegistryReadOnly` with `AmazonEC2ContainerRegistryPullOnly` in the KubectlProvider's IAM role. The `AmazonEC2ContainerRegistryPullOnly` policy:
• Provides the exact permissions needed for container image pulling
• Includes support for ecr:BatchImportUpstreamImage enabling pull-through cache functionality
• Follows the principle of least privilege by removing unnecessary permissions
### Changes Made
• Updated kubectl-provider.ts to use AmazonEC2ContainerRegistryPullOnly instead of AmazonEC2ContainerRegistryReadOnly
• Regenerated integration test snapshots to reflect the policy change across all affected EKS test cases
### Impact
• **Enables ECR pull-through cache support** for Helm chart installations via kubectl
• **Improves security posture** by applying principle of least privilege
• **Maintains backward compatibility** - all existing functionality continues to work
• **No breaking changes** - this is a drop-in replacement with enhanced capabilities
### Testing
• All existing integration tests pass with updated snapshots
• The change affects multiple EKS integration test scenarios including ALB controller, custom addons, and various node group
configurations
• Verified that the new policy provides all necessary permissions for kubectl operations
### References
• [AmazonEC2ContainerRegistryPullOnly Policy Documentation](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEC2ContainerRegistryPullOnly.html)
• [AmazonEC2ContainerRegistryReadOnly Policy Documentation](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonEC2ContainerRegistryReadOnly.html)
---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license1 parent d79fd85 commit 1b6e962
File tree
142 files changed
+758
-1935
lines changed- packages
- @aws-cdk-testing/framework-integ/test
- aws-eks/test
- integ.alb-controller-authapi.js.snapshot
- integ.alb-controller.js.snapshot
- integ.custom-addons.js.snapshot
- integ.eks-addon.js.snapshot
- integ.eks-al2023-nodegroup.js.snapshot
- integ.eks-bottlerocket-ng.js.snapshot
- integ.eks-cluster-handlers-vpc.js.snapshot
- integ.eks-cluster-imported.js.snapshot
- integ.eks-cluster-ipv6.js.snapshot
- integ.eks-cluster-private-endpoint.js.snapshot
- integ.eks-cluster-tags.js.snapshot
- integ.eks-cluster.js.snapshot
- integ.eks-helm-asset.js.snapshot
- integ.eks-hybrid-nodes.js.snapshot
- integ.eks-inference-nodegroup.js.snapshot
- integ.eks-inference.js.snapshot
- integ.eks-pod-identities.js.snapshot
- integ.eks-service-account-sdk-call.js.snapshot
- integ.eks-standard-access-entry.js.snapshot
- integ.eks-subnet-updates.js.snapshot
- integ.eks-windows-ng.js.snapshot
- integ.fargate-cluster.js.snapshot
- integ.helm-chart-logging.js.snapshot
- integ.nodegroup-repair-config.js.snapshot
- asset.1bf478116a59c3d8e069e12fe42948c11b5d5233fca90d2f2b3ec9fcd695025b.bundle
- aws-stepfunctions-tasks/test
- eks/integ.call.js.snapshot
- asset.d671460286b61f85906debbcec5341ea4edad148fbc432b0663593611866728e
- apply
- get
- helm
- patch
- emrcontainers
- integ.job-submission-workflow.js.snapshot
- asset.d671460286b61f85906debbcec5341ea4edad148fbc432b0663593611866728e
- apply
- get
- helm
- patch
- integ.start-job-run.js.snapshot
- asset.d671460286b61f85906debbcec5341ea4edad148fbc432b0663593611866728e
- apply
- get
- helm
- patch
- aws-cdk-lib/aws-eks
- lib
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
142 files changed
+758
-1935
lines changedLines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| |||
Lines changed: 6 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| |||
Lines changed: 6 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| |||
0 commit comments