astonishing-oil-84546
09/11/2025, 10:49 PMawsx.ec2.Vpc
(Crosswalk) library. I'm creating a /17
VPC, and a handful of subnets under it. I'm getting this error though:
error: awsx:ec2:Vpc resource 'shared-non-prod' has a problem: Subnets are too large for VPC. VPC has 8192 addresses, but subnets require 10240 addresses.
A /17
should have 32768
addresses- not 8192
- any idea how it's doing its calculations?astonishing-oil-84546
09/11/2025, 10:50 PMastonishing-oil-84546
09/11/2025, 11:05 PMavailability_zone_cidr_mask
to match the mask of the VPC, it seems to do what I need it to.astonishing-oil-84546
09/11/2025, 11:40 PMastonishing-oil-84546
09/12/2025, 1:01 AM/17
VPC:
private_subnet_cidr_blocks:
- 10.212.0.0/19
- 10.212.32.0/19
- 10.212.64.0/19
public_subnet_cidr_blocks:
- 10.212.96.0/21
- 10.212.104.0/21
- 10.212.112.0/21
I have this in my `.VpcArgs()`:
subnet_strategy=awsx.ec2.SubnetAllocationStrategy.EXACT,
subnet_specs=[
awsx.ec2.SubnetSpecArgs(
type=awsx.ec2.SubnetType.PRIVATE,
name="subnet-high",
cidr_blocks=args['private_subnet_cidr_blocks'],
tags={
'sec:domain': "High"
}
),
awsx.ec2.SubnetSpecArgs(
# Setting aside for future use. May be removed if not needed.
type=awsx.ec2.SubnetType.PUBLIC,
name="subnet-mediation",
cidr_blocks=args['public_subnet_cidr_blocks'],
tags={
'sec:domain': "Mediation"
}
)
]
But it's creating a bunch of /20
subnets anyway.. Is there any way to get it to listen to what I'm asking for?little-cartoon-10569
09/12/2025, 3:13 AMlittle-cartoon-10569
09/12/2025, 3:14 AMstocky-restaurant-98004
09/12/2025, 8:32 PMastonishing-oil-84546
09/14/2025, 10:24 PMastonishing-oil-84546
09/14/2025, 10:28 PMcidrMask
or size
would have been really nice, but not at the expense of throwing away 1/4 of my address space. I actually needed to add 3 /24s since I needed to match the AZ layout.astonishing-oil-84546
09/14/2025, 10:40 PMThis may not be a bug, per se, but it is a UX issue. When trying to use automatic subnet allocations across 3 AZs, you're basically forced to throw away 1/4 of your address space.
Example:
1. Create a VPC with a /17 CIDR block (32,768 addresses)
2. Create 3 /19 private subnets
3. Create 3 /21 public subnets
This should fit evenly in a /17 with a bit of leftover space (basically a final /21). When attempting to do this, you receive an error:
error: awsxec2Vpc resource 'shared-non-prod' has a problem: Subnets are too large for VPC. VPC has 8192 addresses, but subnets require 10240 addresses.
I think this is happening because network blocks don't divide easily by 3, so it's rounding up to 4 and dividing the address space that way (32,768/4 = 8192).
In AWS a 3-AZ network configuration is very common as this is the default minimum number of availability zones per region.
It'd be nice to use automatic subnet allocation, but not at the expense of throwing away 1/4 of the address space.
Pulumi about
output:
CLI
Version 3.191.0
Go Version go1.25.0
Go Compiler gc
Plugins
KIND NAME VERSION
resource aws 7.7.0
resource awsx 3.0.0
resource docker 4.8.2
resource docker-build 0.0.13
language python 3.191.0
Host
OS darwin
Version 13.7.6
Arch arm64
This project is written in python: executable='/Users/Source/aws-platform-management-vpc/.venv/bin/python' version='3.13.3'
Dependencies:
NAME VERSION
<corp>-vpc 0.1.0
little-cartoon-10569
09/14/2025, 11:03 PMstocky-restaurant-98004
09/15/2025, 1:21 PMstocky-restaurant-98004
09/15/2025, 1:25 PMacoustic-father-565
09/15/2025, 9:15 PMastonishing-oil-84546
09/16/2025, 9:19 PM@astonishing-oil-84546 I assume that's a restriction that comes from your employer? This is a new one to me, but I'm guessing that it's so you don't reveal which vendors your company works with?Yeah, regrettably 😞
astonishing-oil-84546
09/16/2025, 9:20 PM