-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-ec2: SubnetFilter byIds does not work as expected when using vpc.selectSubnets() on non-private/mixed subnet types. #30826
Comments
The changes from #24625 seems to be there and not reverted.
|
@khushail I will check if the changes from the commit fixing the issue. And if yes, I will resubmit the PR. |
@khushail I used all possible types of subnets but CDK still did not find the subnets. The code exits with error on last else if as there are no public subnets.
|
@sbidy , @ajupatil , I tried to filter the ids and here is my code which gave me the subnet id using selectSubnet(), I have public subnets in my VPC which were printed - Code - const vpc = ec2.Vpc.fromLookup(this, 'Vpc',{
vpcId : "vpc-09b4a3571058b37a6"
});
const subnets = vpc.selectSubnets({
subnetFilters: [ ec2.SubnetFilter.byIds(['subnet-0427cfeac57da7453'])]
})
new cdk.CfnOutput(this, 'SubnetIds', { value: subnets.subnetIds.join(',') })
} Snapshot for output filtered - Please let me know if this does not work for you. Thanks! |
I am also seeing this on cdk v2 1.154.1.
If I replace the above with a private subnet ID it returns correctly. |
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 typeCurrent 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"]) });
willreturn []
if the subnet ids I filter for (here the["subnet-0000000000"]
) istype = public
.If I do a
const subnets = vpc.selectSubnets({ subnetFilters: [ec2.SubnetFilter.byIds(["subnet-0000000000"])], subnetType: ec2.SubnetType.PUBLIC });
it will find the subnet andreturn["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
The text was updated successfully, but these errors were encountered: