Class responsible for allocating CIDRs at each level of the hierarchy.

The allocation follows a top-down approach:

  1. Start with a base CIDR block
  2. Divide it among accounts (or cloud-specific account configurations)
  3. For each account, divide its CIDR among regions
  4. For each region, divide its CIDR among availability zones
  5. For each AZ, divide its CIDR among subnet types

The allocation is deterministic, meaning the same input will always produce the same output, and ensures no CIDR overlaps occur.

Constructors

Methods

Constructors

Methods

  • Generates IP allocations for all accounts, regions, and subnets. This is the main entry point for the allocation process.

    Returns Allocation[]

    An array of allocation objects representing all subnet allocations

    Throws

    If the allocation cannot be completed due to insufficient space, overlapping CIDRs, or invalid inputs

    Example

    const allocator = new CidrAllocator(config);
    const allocations = allocator.generateAllocations();
    // allocations contains all subnet CIDRs for all accounts, regions, and AZs