import { Construct } from 'constructs'; import { DefaultSubnet, DefaultVpc } from '../generated/providers/aws/vpc'; import { getId } from '../utils'; export type NetworkConfig = { region: string; }; export default class Network extends Construct { readonly id: string; readonly subnetIds: string[]; constructor(scope: Construct, id: string, config: NetworkConfig) { super(scope, id); const vpcId = getId(id, 'vpc'); const vpc = new DefaultVpc(this, vpcId); const subnetId = getId(id, 'subnet'); const subnetA = new DefaultSubnet(this, getId(subnetId, 'a'), { availabilityZone: `${config.region}a`, }); const subnetB = new DefaultSubnet(this, getId(subnetId, 'b'), { availabilityZone: `${config.region}b`, }); const subnetC = new DefaultSubnet(this, getId(subnetId, 'c'), { availabilityZone: `${config.region}c`, }); this.id = vpc.id; this.subnetIds = [subnetA.id, subnetB.id, subnetC.id]; } }