Skip to content

eks: KubectlProvider should use the AmazonEC2ContainerRegistryPullOnly managed policy #35244

@wagdav

Description

@wagdav

Describe the feature

The KubectlProvider has access to ECR so that it can fetch Helm charts stored in repositories:

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

Currently, the KubectlProvider uses the AmazonEC2ContainerRegistryReadOnly policy which works, but it's

  1. Too broad: for example kubectl doesn't use the "ecr:ListImages" action
  2. Too narrow: it doesn't include "ecr:BatchImportUpstreamImage" action, which is required to use a pull-through cache.

Reference:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-eksRelated to Amazon Elastic Kubernetes Serviceeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions