AWS CDK - Create custom Subnets with custom CIDR blocks
 When you're building a VPC through AWS CDK, the Vpc construct will 
create the subnets automatically for you without allowing you to specify
 the subnet cidr blocks.
    const pizzaVPC = new CfnVPC(this, "CDKPizzaVPC", {
      cidrBlock: "10.1.0.0/16",
    });
If you don't want them, then use CfnVPC, this will allow you to manually create your subnets with any highlevel construct. i.e:
    const subnet1 = new PublicSubnet(this, "CDKSubnet1", {
      vpcId: pizzaVPC.ref,
      availabilityZone: "us-east-1a",
      cidrBlock: "10.1.0.0/24",
    });
    const subnet2 = new PublicSubnet(this, "CDKSubnet2", {
      vpcId: pizzaVPC.ref,
      availabilityZone: "us-east-1b",
      cidrBlock: "10.1.2.0/24",
    });  
Comments
Post a Comment