in src/constructs/ec2/vpc.ts [67:85]
static subnetsFromParameterFixedNumber(scope: GuStack, props?: GuSubnetProps, numSubnets: number = 3): ISubnet[] {
const type = props?.type ?? SubnetType.PRIVATE;
const parameterDefault =
type === SubnetType.PRIVATE
? NAMED_SSM_PARAMETER_PATHS.PrimaryVpcPrivateSubnets
: NAMED_SSM_PARAMETER_PATHS.PrimaryVpcPublicSubnets;
const subnets = new GuSubnetListParameter(scope, `${maybeApp(props)}${type}Subnets`, {
description: `A list of ${type.toLowerCase()} subnets`,
default: parameterDefault.path,
fromSSM: true,
});
const subnetIds: string[] = [];
for (let i = 0; i < numSubnets; i++) {
subnetIds.push(Fn.select(i, subnets.valueAsList));
}
return subnetIds.map((subnetId) => Subnet.fromSubnetId(scope, `subnet-${subnetId}`, subnetId));
}