aws / aws/aws-cdk

aws-ec2: SubnetFilter byIds does not work as expected when using vpc.selectSubnets() on non-private/mixed subnet types.

Open
#30,826 6 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

Related Issue #24427 - the issue seems not being fixed or was reverted.

When creating a subnet selection with only the `SubnetFilter.byIds()`, the selection is empty if the subnets are not of type PRIVATE_WITH_EGRESS.

### Expected Behavior

Being able to select subnet by IDs in a subnet selection when using `SubnetFilter.byIds` regardless of the subnet type

### Current Behavior

When creating a subnet selection with only the SubnetFilter.byIds, the selection if empty if the subnets are not of type PRIVATE_WITH_EGRESS.

### Reproduction Steps

The `const subnets = vpc.selectSubnets({ subnetFilters: [ec2.SubnetFilter.byIds(["subnet-0000000000"]) }); `will `return [] ` if the subnet ids I filter for (here the `["subnet-0000000000"]` ) is `type = public`.
If I do a `const subnets = vpc.selectSubnets({ subnetFilters: [ec2.SubnetFilter.byIds(["subnet-0000000000"])], subnetType: ec2.SubnetType.PUBLIC });` it will find the subnet and `return["subnet-0000000000"]`

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.144.0 (build 5fb15bc)

### Framework Version

_No response_

### Node.js Version

v22.2.0

### OS

Linux 5.15.153.1-microsoft-standard-WSL2

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the vpc.selectSubnets() path handling SubnetFilter.byIds, using the reproduction with a public subnet ID and no subnetType. Confirm the behavior against the PRIVATE_WITH_EGRESS and PUBLIC cases; done means byIds selects the requested subnet IDs regardless of subnet type, including mixed selections.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.