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

Ability to reserve a cidr_block #7

Open
braunsonm opened this issue Nov 22, 2021 · 4 comments
Open

Ability to reserve a cidr_block #7

braunsonm opened this issue Nov 22, 2021 · 4 comments

Comments

@braunsonm
Copy link

I would like the ability to provide a cidr_block attribute to denote that network as already reserved. For instance:

base_cidr_block = "10.0.0.0/8"
network = [
  {
    name = "reserved",
    new_bits = 8,
    cidr_block = "10.1.0.0/16"
  },
  {
    name = "new",
    new_bits = 8
  }
]

The new block should not try to use the reserved cidr_block

@apparentlymart
Copy link
Contributor

Hi @braunsonm,

Perhaps I misunderstand what you are asking, but I think what you asked for here is already supported if you set the name of the first element to null. As described in the README, that will make it still consume the described address space but the resulting prefix won't be included in the result map.

@braunsonm
Copy link
Author

braunsonm commented Apr 14, 2022

Sorry for the confusion, that does answer my question but what I'm looking for is for a way to be able to actually specify the cidr_block with a name. There are cases where I want to use a network (indexing the array by key) but I already know what the cidr has to be.

network = [
  {
    name = "reserved",
    new_bits = 8,
    cidr_block = "10.2.0.0/16"
  }
]

If name is set, then cidr_block seems to get ignored. What I'm asking is if the cidr_block is user provided, then it should respect that. The output from the above will not use 10.2.0.0/16

@braunsonm
Copy link
Author

Are you sure what you described works?

network = [
  {
    name = null,
    new_bits = 7,
    cidr_block = "10.0.0.0/15"
  },
  {
    name = null,
    new_bits = 8,
    cidr_block = "10.42.0.0/16"
  },
  {
    name = "test,
    new_bits = 8
  },
]

test is output with a cidr block of 10.3.0.0/16 when the first available is 10.2.0.0/16 because the second null on 10.42.0.0/16 is getting ignored and placed in 10.2.0.0/16.

@apparentlymart
Copy link
Contributor

Hi @braunsonm,

Indeed, this module does not allow you to specify CIDR blocks as the caller. This module's intended purpose is to calculate new CIDR blocks based on a specification.

What you are asking for seems to be outside the scope of this module, so I don't expect we would add such a capability here. You could fork this module and change it to work in the way you need in principle, although I think the specific functionality you'd need here (to tightly pack blocks while "working around" reserved areas) is perhaps beyond the capabilities of the Terraform functionality this module uses and so it might also require a custom Terraform provider to encapsulate the address calculation logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants