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

Change "Prefix Too Large" Behavior? #4

Closed
cooperwalbrun opened this issue Feb 18, 2022 · 4 comments · Fixed by #7
Closed

Change "Prefix Too Large" Behavior? #4

cooperwalbrun opened this issue Feb 18, 2022 · 4 comments · Fixed by #7
Assignees
Labels
enhancement New feature or request

Comments

@cooperwalbrun
Copy link
Owner

cooperwalbrun commented Feb 18, 2022

I will need to gather some input from others on this. The idea is that instead of erroring out when an "invalid" prefix is specified, e.g.:

$ aws-cidr-finder --profile myprofile --prefix 18
Desired prefix (18) is incompatible with the available CIDR blocks!
Encountered a CIDR whose prefix is 19, which is higher than 18. Offending CIDR: 172.31.96.0/19
Run the command again without the --prefix argument to see the full list.

...the results list could just be scrubbed of any CIDRs that do not satisfy the criteria. For example, if the aws-cidr-finder command would return 172.0.0.0/20, 172.0.16.0/18, 172.45.0.0/32 and we specify --prefix 18, the only result would be 172.0.16.0/18 because that is the only returned CIDR that is large enough to have the desired prefix.

@cooperwalbrun cooperwalbrun self-assigned this Feb 18, 2022
@cooperwalbrun cooperwalbrun added the enhancement New feature or request label Feb 18, 2022
@cooperwalbrun
Copy link
Owner Author

An alternative to changing the behavior of --prefix is adding an additional flag which will allow the behavior described above. What I have in mind is --filter, e.g.:

aws-cidr-finder --profile myprofile --prefix 18 --filter

@DacoDev
Copy link

DacoDev commented May 3, 2022

An alternative to changing the behavior of --prefix is adding an additional flag which will allow the behavior described above. What I have in mind is --filter, e.g.:

aws-cidr-finder --profile myprofile --prefix 18 --filter

Adding filter seems like a good solution, but also I don't know if someone looking for a subnet with a certain CIDR would care if it runs into a block it checked that was of an incompatible size, only if there were no available blocks for their specified prefix.

Of course, this is from my perspective and use-case where I'm breaking up a VPC to create a subnet with Terraform at launch time. I found this issue because I got the error you listed; the first available block sequentially in my VPC is a /28, but I'm looking for /25s.

Whatever you decide, thanks for making and working on this!

@cooperwalbrun
Copy link
Owner Author

cooperwalbrun commented May 8, 2022

Thanks for the input @DacoDev. I will make this change.

Edit: the change described in the root post of this issue is now available in aws-cidr-finder v0.1.2.

@cooperwalbrun cooperwalbrun changed the title Change "Mask Too Large" Behavior? Change "Prefix Too Large" Behavior? May 8, 2022
@DacoDev
Copy link

DacoDev commented May 9, 2022

Thank you @cooperwalbrun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants