-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(ec2): improve subnet selection to support subnet group name and combined selection #35513
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
base: main
Are you sure you want to change the base?
feat(ec2): improve subnet selection to support subnet group name and combined selection #35513
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR.
packages/aws-cdk-lib/aws-ec2/test/integ.subnet-selection-combined.ts
let's move this integ test to packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test
and
$ cd framework-integ
$ yarn build --fix
$ yarn integ test/aws-ec2/test/integ.subnet-selection-combined.js --update-on-failed
to generate the new snapshot.
and you may want to
$ yarn integ --directory test/aws-ec2/test/ --update-on-failed
to make sure all existing aws-ec2 integ tests stay up-to-date and refreshed if necessary.
…shots - Move integ.subnet-selection-combined.ts from aws-cdk-lib to framework-integ - Update imports to use proper framework-integ pattern - Convert to use IntegTest construct as required by modern CDK testing - Generate integration test snapshots Addresses review feedback from PR aws#35513
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
…combined selection This change enhances the SubnetSelection functionality to address the issue where users cannot specify exact subnet groups by name when multiple public subnets exist with different purposes. Key improvements: - Add support for subnet_group_name in SubnetSelection - Enable combined subnet selection using both type and name - Maintain backward compatibility with existing subnet selection methods Fixes aws#35422 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…shots - Move integ.subnet-selection-combined.ts from aws-cdk-lib to framework-integ - Update imports to use proper framework-integ pattern - Convert to use IntegTest construct as required by modern CDK testing - Generate integration test snapshots Addresses review feedback from PR aws#35513
62b7275
to
260af5f
Compare
…r simpler alternatives - Add comprehensive JSDoc documentation to selectSubnetObjectsByTypeAndName method - Include guidance about when to use simpler alternatives (subnetGroupName alone, subnetType alone, or SubnetFilter.byIds) - Update README with note about considering simpler alternatives - Improve SubnetSelection interface documentation with usage guidance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per CI error:
aws-cdk-lib: /codebuild/output/src1050340690/src/actions-runner/_work/aws-cdk/aws-cdk/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts
aws-cdk-lib: 717:5 error Trailing spaces not allowed no-trailing-spaces
aws-cdk-lib: 722:5 error Trailing spaces not allowed no-trailing-spaces
aws-cdk-lib: ✖ 2 problems (2 errors, 0 warnings)
aws-cdk-lib: 2 errors and 0 warnings potentially fixable with the `--fix` option.
aws-cdk-lib: Error: /codebuild/output/src1050340690/src/actions-runner/_work/aws-cdk/aws-cdk/node_modules/eslint/bin/eslint.js . --ext=.ts --resolve-plugins-relative-to=/codebuild/output/src1050340690/src/actions-runner/_work/aws-cdk/aws-cdk/tools/@aws-cdk/cdk-build-tools/lib exited with error code 1
please run yarn lint --fix
in aws-cdk-lib
Addresses PR review comment about ESLint trailing spaces errors on lines 717 and 722.
Summary
This PR addresses issue #35422 by enhancing the
SubnetSelection
functionality to support more precise subnet selection when multiple public subnets with different purposes exist in a VPC.Problem
Currently, when using
SubnetSelection(subnet_type=SubnetType.PUBLIC)
, the CDK selects any public subnet without considering the specific subnet group name. This causes issues when users have multiple public subnet groups (e.g., "public" and "nat") and need to target a specific group.Solution
This PR introduces the following enhancements:
subnet_type
andsubnet_group_name
for more precise selectionChanges Made
Usage Examples
Testing
Breaking Changes
None. This change is fully backward compatible.
Fixes #35422