private void GlobalRoutes(VirtualNetwork[] vnets, Subnet[] snets, Firewall[] firewalls) { for (int currVnet = 0; currVnet < vnets.Length; currVnet++) { var route = new RouteTable($"route-{currVnet + 1}-ex", new RouteTableArgs { ResourceGroupName = vnets[currVnet].ResourceGroupName, Location = vnets[currVnet].Location, Routes = Enumerable .Range(0, locations.Count()) .Where(currFirewall => currFirewall != currVnet) .Select(currFirewall => FirewallRoute(firewalls[currFirewall], currVnet, currFirewall)) .Concat(new[] { InternetRoute(currVnet) }) .ToArray() }); var association = new SubnetRouteTableAssociation($"route-assoc-{currVnet + 1}-ex", new SubnetRouteTableAssociationArgs { RouteTableId = route.Id, SubnetId = snets[currVnet].Id }); } }
private Template GetSqlExpressDbTemplate() { var template = new Template("corp.getthebuybox.com", "vpcBasicDbInstanceTest", "StackBasicDbInstanceTest", "10.0.0.0/16"); var vpc = template.Vpcs.First(); vpc.EnableDnsHostnames = true; vpc.EnableDnsSupport = true; var subnet1 = new Subnet(vpc, "10.0.128.0/28", AvailabilityZone.UsEast1A, true); template.Resources.Add("subnetDb1", subnet1); RouteTable routeTable4Subnet1 = new RouteTable(vpc); template.Resources.Add("routeTable4Subnet1", routeTable4Subnet1); Route route4subnet1 = new Route(vpc.InternetGateway, "0.0.0.0/0", routeTable4Subnet1); template.Resources.Add("route4subnet1", route4subnet1); SubnetRouteTableAssociation subnetRouteTableAssociationSubnet1 = new SubnetRouteTableAssociation(subnet1, routeTable4Subnet1); template.Resources.Add(subnetRouteTableAssociationSubnet1.LogicalId, subnetRouteTableAssociationSubnet1); var subnet2 = new Subnet(template.Vpcs.First(), "10.0.64.0/28", AvailabilityZone.UsEast1E, true); template.Resources.Add("subnetDb2", subnet2); RouteTable routeTable4Subnet2 = new RouteTable(vpc); template.Resources.Add("routeTable4Subnet2", routeTable4Subnet2); Route route4subnet2 = new Route(vpc.InternetGateway, "0.0.0.0/0", routeTable4Subnet2); template.Resources.Add("route4subnet2", route4subnet2); SubnetRouteTableAssociation subnetRouteTableAssociationSubnet2 = new SubnetRouteTableAssociation(subnet2, routeTable4Subnet2); template.Resources.Add(subnetRouteTableAssociationSubnet2.LogicalId, subnetRouteTableAssociationSubnet2); var subnetGroup = new DbSubnetGroup("this is my subnet group description"); template.Resources.Add("dbSubnetGroup", subnetGroup); subnetGroup.AddSubnet(subnet1); subnetGroup.AddSubnet(subnet2); SecurityGroup securityGroup = new SecurityGroup("Allows access to SqlServer from everywhere", vpc); template.Resources.Add("securityGroupWorldWide", securityGroup); securityGroup.AddIngress(PredefinedCidr.TheWorld, Protocol.Tcp, Ports.MsSqlServer); var dbSecurityGroup = new DbSecurityGroup(vpc, "Why is a description required?"); template.Resources.Add("dbSecurityGroup", dbSecurityGroup); var dbSecurityGroupIngress = new DbSecurityGroupIngress(); dbSecurityGroupIngress.CIDRIP = "0.0.0.0/0"; dbSecurityGroup.AddDbSecurityGroupIngress(dbSecurityGroupIngress); DbInstance instance = new DbInstance(DbInstanceClassEnum.DbT2Micro, EngineType.SqlServerExpress, LicenseModelType.LicenseIncluded, Ebs.VolumeTypes.GeneralPurpose, 20, "MyMasterUsername", "YellowBeard123", subnetGroup, dbSecurityGroup); template.Resources.Add("instanceBasicDbInstanceTest", instance); instance.PubliclyAccessible = true.ToString().ToLowerInvariant(); return(template); }