Skip to content
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: Filter subnets by CIDR Range #27421

Closed
1 of 2 tasks
AlemanCS opened this issue Oct 5, 2023 · 2 comments · Fixed by #27425
Closed
1 of 2 tasks

aws-ec2: Filter subnets by CIDR Range #27421

AlemanCS opened this issue Oct 5, 2023 · 2 comments · Fixed by #27425
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@AlemanCS
Copy link
Contributor

AlemanCS commented Oct 5, 2023

Describe the feature

I would like the ability to filter a SubnetSelection based on a CIDR range in a VPC. While SubnetFilter does allow to filter by CIDR mask and IP address, a VPC can have multiple CIDR Ranges associated with it and the CIDR masks can be the same while the range can be different.

Use Case

I would like this feature because some of the VPCs I have worked with have 2 or more CIDR Ranges associated and the current subnet filter options don't really work unless I filter by Id.

Simple Example:

VPC A can have CIDR ranges: 10.2.0.0/16 and 100.64.0.0/16

Its subnets can be as follows:

Subnet A: 10.2.0.0/18
Subnet B: 10.2.64.0/18
Subnet C: 100.64.0.0/18
Subnet D: 100.64.64.0/18

I want to only use the subnets under the 10.2.0.0/16 CIDR range.

Proposed Solution

I think the feature would look something like this

const subnetsByCidrRanges: SubnetSelection = {
      subnetFilters: [SubnetFilter.byCidrRanges([10.2.0.0/16])]
    }

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.93.0

Environment details (OS name and version, etc.)

Mac OS

@AlemanCS AlemanCS added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 5, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Oct 5, 2023
@peterwoodworth peterwoodworth added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Oct 5, 2023
@peterwoodworth
Copy link
Contributor

Thanks for the request, this makes sense and I can see how it would be useful 🙂

Be sure to check out our contributing guide, we will likely rely on contributor support for this feature

@peterwoodworth peterwoodworth added effort/small Small work item – less than a day of effort and removed effort/medium Medium work item – several days of effort labels Oct 5, 2023
@mergify mergify bot closed this as completed in #27425 Oct 11, 2023
mergify bot pushed a commit that referenced this issue Oct 11, 2023
This PR adds a new SubnetFilter ,`CidrRangesSubnetFilter`, which filter subnets if they are included in a given list of CIDR ranges. This becomes helpful if a VPC has multiple CIDR ranges and you want to select subnets for only a specific CIDR range or multiple.

Note: It is a bit difficult to write unit tests as CDK doesn't have the ability to add a secondary CIDR to a VPC.

Closes #27421 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants