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

lang/funcs: cidrsubnets function #22858

Merged
merged 1 commit into from
Sep 20, 2019
Merged

lang/funcs: cidrsubnets function #22858

merged 1 commit into from
Sep 20, 2019

Conversation

apparentlymart
Copy link
Contributor

This is a companion to cidrsubnet that allows bulk-allocation of multiple subnet addresses at once, with automatic numbering.

Unlike cidrsubnet, cidrsubnets allows each of the allocations to have a different prefix length, and will pack the networks consecutively into the given address space. cidrsubnets can potentially create more complicated addressing schemes than cidrsubnet alone can. It's not possible to achieve variable prefix lengths with cidrsubnet (singular) in the Terraform language because it has no reduce-equivalent operator to allow iteratively computing the next address from the previous address.


This is a function-oriented version of the core algorithm in terraform-provider-cidr. In light of the language improvements in Terraform 0.12, we've been leaning towards using compute-only modules to abstract over calculations rather than using custom Terraform providers, because modules are easier to maintain, release, and distribute.

However, the cidr provider has at is core an iteration-based algorithm that the Terraform language can't represent. By providing that algorithm as a built-in function (with a similar interface to our existing cidrsubnet) then it becomes technically possible to use it as the foundation of various IP address scheme calculation modules.

After merging this it would be possible to write a Terraform module with an equivalent interface to the cidr_network data source, but it can also be used as a building block for more specialized address planning modules, such as my own more-opinionated terraformnet/addr-plan/cidr module that currently has some rather awkward restrictions due to being built on the existing cidrsubnet function.

This is a companion to cidrsubnet that allows bulk-allocation of multiple
subnet addresses at once, with automatic numbering.

Unlike cidrsubnet, cidrsubnets allows each of the allocations to have a
different prefix length, and will pack the networks consecutively into the
given address space. cidrsubnets can potentially create more complicated
addressing schemes than cidrsubnet alone can, because it's able to take
into account the full set of requested prefix lengths rather than just
one at a time.
@apparentlymart apparentlymart requested a review from a team September 20, 2019 02:19
@apparentlymart apparentlymart self-assigned this Sep 20, 2019
@ghost ghost added the sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK label Sep 20, 2019
@apparentlymart apparentlymart merged commit f84ab99 into master Sep 20, 2019
@apparentlymart apparentlymart deleted the f-func-cidrsubnets branch September 20, 2019 22:58
kmoe added a commit to hashicorp/terraform-plugin-sdk that referenced this pull request Sep 27, 2019
@ghost
Copy link

ghost commented Oct 21, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Oct 21, 2019
@appilon appilon removed the sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK label Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants