(eks-v2): moving API endpoints from PUBLIC_AND_PRIVATE to PRIVATE fails on PublicAccessCidrs
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When creating an EKS cluster using the aws-eks-v2 `Cluster` construct, we see issues when changing the API `endpointAccess` property from `PUBLIC_AND_PRIVATE` including a specific allowed CIDR (using the onlyFrom method) to connect from to `PRIVATE`.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
Going from `PUBLIC_PRIVATE` to `PRIVATE` ignores the `PublicAccessCidrs` value, since it is not relevant when having the endpoints private.
### Current Behavior
Impossible to apply the template unless working around it with the workaround:
```
if (cfn instanceof CfnCluster) {
cfn.addPropertyOverride('ResourcesVpcConfig.PublicAccessCidrs', []);
}
```
CI/CD after applying without the workaround:
```
Resource handler returned message: "The new template must include all the properties specified in the previous template,
property "PublicAccessCidrs" missing
```
### Reproduction Steps
1. Create a private cluster using the onlyFrom with a specific CIDR to be allowed.
```
new eks.Cluster(this, `cluster`, {
...
endpointAccess: PUBLIC_AND_PRIVATE.onlyFrom(
`1.2.3.4/32`,
);
...
});
```
2. Adapt this to set the endpoint private
```
new eks.Cluster(this, `cluster`, {
...
endpointAccess: PRIVATE,
...
});
```
Run against CI fails 🚫
3. Workaround this using below:
```
const cluster = new eks.Cluster(this, `cluster`, {
...
endpointAccess: PRIVATE,
...
});
const cfn = this.cluster.node.defaultChild;
if (cfn instanceof CfnCluster) {
cfn.addPropertyOverride('ResourcesVpcConfig.PublicAccessCidrs', []);
}
```
Run against CI succes ✅
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.250.0
### AWS CDK CLI version
2.1025.0
### Node.js Version
10.9.7
### OS
/
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start in the aws-eks-v2 Cluster construct and trace how endpointAccess and onlyFrom populate the CfnCluster ResourcesVpcConfig. Reproduce the transition from PUBLIC_AND_PRIVATE with a CIDR to PRIVATE, then verify the synthesized template and deployment no longer fail because of PublicAccessCidrs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100