internal VpcCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props) { const bool createPaidResources = true; var vpcProperties = new VpcProps { Cidr = "10.10.0.0/16", EnableDnsHostnames = true, EnableDnsSupport = true, NatGateways = createPaidResources ? 1 : 0, SubnetConfiguration = new ISubnetConfiguration[] { new SubnetConfiguration { CidrMask = 26, Name = "public", SubnetType = SubnetType.PUBLIC, }, new SubnetConfiguration { CidrMask = 26, Name = "private", SubnetType = createPaidResources ? SubnetType.PRIVATE : SubnetType.ISOLATED, } } }; var vpc = new Vpc(this, "MyVpc", vpcProperties); }
public CustomVpc(Construct scope, string id, string cidr) : base(scope, id) { SubnetConfiguration privateSubnetConfig = new SubnetConfiguration { CidrMask = 26, SubnetType = SubnetType.PRIVATE, Name = "privateSubnet" }; SubnetConfiguration publicSubnetConfig = new SubnetConfiguration { CidrMask = 26, SubnetType = SubnetType.PUBLIC, Name = "publicSubnet" }; VpcProps props = new VpcProps { Cidr = cidr, DefaultInstanceTenancy = DefaultInstanceTenancy.DEFAULT, MaxAzs = 99, SubnetConfiguration = new ISubnetConfiguration[] { privateSubnetConfig, publicSubnetConfig }, NatGateways = 99, EnableDnsHostnames = true, EnableDnsSupport = true }; var vpc = new Vpc(this, id + $"{id}-vpc", props); this.Vpc = vpc; }
public VpcStack(Construct scope, IConfigSettings config, IStackProps props = null) : base(scope, $"{config?.Vpc?.StackName}", props) { var vpcProps = new VpcProps { Cidr = (config.Vpc.Cidr != null) ? config.Vpc.Cidr : "10.0.0.0/16", NatGateways = config.Vpc.NatGateways, }; // create the vpc Vpc = new Amazon.CDK.AWS.EC2.Vpc(this, config.Vpc.Name, vpcProps); // tag it Utilities.Tagging.Tag(Vpc, config, config.Vpc.Tags); Utilities.Tagging.Tag(Vpc, config, config.Tags); }