-
Notifications
You must be signed in to change notification settings - Fork 4k
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() #24427
Comments
Yes I can reproduce this bug. const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
const subnets = vpc.selectSubnets({
// select a public subnet by IDs
// subnetFilters: [ ec2.SubnetFilter.byIds(['subnet-050929f8c6efb7657'])]
// select a private subnet by IDs
subnetFilters: [ ec2.SubnetFilter.byIds(['subnet-0d0069776469b2e0d'])]
})
new cdk.CfnOutput(this, 'SubnetIds', { value: subnets.subnetIds.join(',') }) And I think we probably should fix here: aws-cdk/packages/@aws-cdk/aws-ec2/lib/vpc.ts Line 576 in 0b822b3
|
Hello, i think subnet type selection is also happening in another function; and when tried with filtering byID it resulted with empty array with other vpc setups too. aws-cdk/packages/@aws-cdk/aws-ec2/lib/vpc.ts Line 653 in b935f2b
by reproducing the case, i can not create outputs because subnets.subnetIds is empty array.
from my understanding, is it doing filtering right, but when the subnetIDs are tokenised, it resulted with empty because there was no matches. example subnetIds: [ '${Token[TOKEN.622]}', '${Token[TOKEN.638]}' ].
Then tried this code block, it can be resolved as string.
As this is my first conversation, can you please review my findings, @pahud . thank you. |
|
Describe the bug
When creating a subnet selection with only the SubnetFilter.byIds, the selection if 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.
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
Try a subnet selection with a SubnetFilter.byIds on a vpc without subnet of type PRIVATE_WITH_EGRESS.
Possible Solution
Current code
I propose creating a new function selectAllSubnetObjects applying a patch on the selectSubnetObjects function:
Additional Information/Context
No response
CDK CLI Version
2.60.0 (build 2d40d77)
Framework Version
No response
Node.js Version
v16.17.0
OS
Windows 11
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: