aws / aws/aws-cdk

(aws-eks): Allow to only tag selected subnets for load balancer usage

Open
#20,010 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-eks @aws-cdk/aws-eks-v2-alpha feature-request feature/service-integration needs-discussion p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

In the `Cluster` construct [subnets are tagged](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-eks/lib/cluster.ts#L1811) so that the AWS load balancer controller can discover them automatically. However, this mechanism automatically tags all private and public subnets.

It should be possible to limit the tagging to the subnets that have been selected through the `SubnetSelection` of the `Cluster`.

### Use Case

We are using certain private subnets only to provide IPs to our EKS clusters' pods. Load balancers should never be placed in those subnets because we don't route into them. With the current tagging mechanism, we need to explicitly specify the subnet IDs for all load balancers in the annotations because all private subnets are tagged.

### Proposed Solution

* Keep the default that all subnets are tagged so that the existing behavior is not broken.
* Add a property of a to be implemented `SubnetTaggingProps` interface to the `ClusterProps` interface -> could look something like this:
```
export interface SubnetTaggingProps {
onlyUseSelectedSubnets: boolean;
tagPrivateSubnets: boolean;
tagPublicSubnets: boolean;
}
```
* Adapt the tagging function in the `Cluster` construct so that it correctly handles the props.

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.20.0

### Environment details (OS name and version, etc.)

Any

Contributor guide

Open the contributing guide

Research direction

Start in packages/@aws-cdk/aws-eks/lib/cluster.ts at the linked Cluster tagging logic, then trace how ClusterProps and SubnetSelection determine the available subnets. Done means adding the proposed controls while preserving the default of tagging all private and public subnets, and limiting tags to selected subnets when requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, kubernetes, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.