Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Add a new `Unused` subnet type. This has no effect in the legacy subnet allocation method. 2. Add `subnetStrategy` field to VPC as enum of `Legacy`, `Auto`, `Exact`. - `Legacy` maintains current complex behaviour. - `Auto` lays out in specified order with gaps where required. Either all mask must be specified, or no masks specified - no mixing of auto-allocated and manual is allowed. - `Exact` requires the user to specify what every part of the range is used for - using the `Unused` subnet spec type for expected gaps between subnets. Anyone using the legacy subnet allocation method can definitely migrate to the exact layout method, they can also test migrating to the Auto layout, but it's not guaranteed to be compatible. In the next major version, we should change the default subnet strategy to `Auto`. Adds optional `size` and `cidrBlocks` fields to subnet spec as an alternative to `cidrMask` as a more intuitive way of specifying masks. The size must be a power of two (2, 4, 8, 16, 32, 64, 128, etc). The cidrBlocks property is an array of strings, which must match the number of AZs being used. If using `cidrBlocks`, then all subnet specs MUST specify `cidrBlocks`. If multiple of the cidrMask, cidrBlocks and size properties are specified, they must agree. Adds a new output called `subnetLayout` which describes the resolved subnet layout to make it a little more transparent to the user what's happening. This is also used to help users move from the legacy strategy to Auto or Exact. Example of warning for anyone using the implicit "Legacy" strategy: ``` awsx:ec2:Vpc (vpc): warning: The default subnetStrategy will change from "Legacy" to "Auto" in the next major version. Please specify the subnetStrategy explicitly. The current subnet layout can be specified via "Auto" as: [ { "type": "Private", "cidrMask": 21 }, { "type": "Unused", "cidrMask": 21 }, { "type": "Public", "cidrMask": 20 } ] ``` Fixes #1135 Fixes #951 Fixes #321 - we can now add subnets in custom positions to avoid conflicts or recreation ## Changes: * Add SubnetStrategy to VPC - Add "Unused" spec type. - Draft the `cidrBlock` variation for complete custom layouts. * Make plain * Rename existing subnet to legacy * Implement new subnet distributor - Copy existing tests. - Exclude known cases test as we specifically don't want this to be backward compatible - only legacy is backward compatible to v1.x. - Use netmask over ip-address as it's a simpler API and includes a `.next()` function. * Validate for gaps in exact mode * Fixup lint * Generate SDKs * Make default layout match legacy - Remove isolated subnet. - Simplify maths. * Implement fully custom subnet layouts * Add warning about users on the legacy strategy by default * Separate codepaths for auto and explicit layouts - Refine type of explicit layouts to avoid existence checks. - Extract subnet name function. - Rework normalisation to be more imperative and ensure type correctness. * Add custom documentation for VPC * Improve subnet strategy warning - Add explanation of condition. - Attach to correct resource * Make it easier to debug the provider * Fix review feedback Remove redundant undefined check. Replace `Math.log2(nextPow2(x))` with `newBits(x)`. Proven compatibility locally by the test: test("log2calc", () => { fc.assert( fc.property(fc.integer({ min: 0, max: 32 }), (i) => { expect(newBits(i)).toEqual(Math.log2(nextPow2(i))); }), ); }); * Add availabilityZoneCidrMask option Allow users to reserve more space for additional AZs to be added later. * Add `subnetLayout` output Reverse engineer layout from legacy calculation by looking at just the first AZ repetition. Add calculated "Auto" to the warning message for legacy users to transition to the new "Auto" setting. * Un-skip tests
- Loading branch information