function askForSubnets() {
    if (this.abort) return null;
    const done = this.async();

    const subnetList = _.map(this.awsFacts.availableSubnets, sn => {
        const friendlyName = _getFriendlyNameFromTag(sn);
        const formattedFriendlyName = friendlyName ? `name: '${friendlyName}', ` : '';
        return {
            name: `${sn.SubnetId} (${formattedFriendlyName}Availability Zone: ${sn.AvailabilityZone}, Public IP On Launch: ${
                sn.MapPublicIpOnLaunch ? 'yes' : 'no'
            })`,
            value: sn.SubnetId,
            short: sn.SubnetId
        };
    });

    const defaultSubnetValue = storedSubnetValue =>
        storedSubnetValue || [_.get(this.awsFacts.availableSubnets, '[0].SubnetId'), _.get(this.awsFacts.availableSubnets, '[1].SubnetId')];
    const validateSubnet = input =>
        _.isEmpty(input) || (_.isArray(input) && input.length < 2) ? 'You must select two or more subnets' : true;

    const prompts = [
        {
            type: 'checkbox',
            name: 'elbSubnets',
            message: `Which subnets should we deploy the ${chalk.yellow('Network Load Balancer (ELB)')} to?`,
            choices: subnetList,
            default: defaultSubnetValue(this.aws.vpc.elbSubnets),
            validate: validateSubnet
        },
        {
            type: 'checkbox',
            name: 'appSubnets',
            message: `Which subnets should we deploy the ${chalk.yellow('Application & Database')} to?`,
            choices: subnetList,
            default: defaultSubnetValue(this.aws.vpc.appSubnets),
            validate: validateSubnet
        }
    ];

    return this.prompt(prompts).then(props => {
        const publicIpOnLaunchArray = appSubnets =>
            _.chain(this.awsFacts.availableSubnets)
                .filter(availableSubnet => _.includes(appSubnets, availableSubnet.SubnetId))
                .map('MapPublicIpOnLaunch')
                .uniq()
                .value();

        const uniqueIPLaunch = publicIpOnLaunchArray(props.appSubnets);
        const shouldAppHavePublicIP = _.head(uniqueIPLaunch);
        if (uniqueIPLaunch.length !== 1) {
            this.log.ok(
                `⚠️ Mix of Application Subnets containing contradictory 'MapPublic Ip On Launch' values. Defaulting to '${
                    shouldAppHavePublicIP ? 'yes' : 'no'
                }'`
            );
        }

        this.aws.vpc.elbSubnets = props.elbSubnets;
        this.aws.vpc.appSubnets = props.appSubnets;
        this.aws.vpc.appSubnetsLaunchWithPublicIP = shouldAppHavePublicIP;
        done();
    });
}
function askForSubnets() {
    if (this.abort) return null;
    const done = this.async();

    const subnetList = _.map(this.awsFacts.availableSubnets, sn => {
        const friendlyName = _getFriendlyNameFromTag(sn);
        const formattedFriendlyName = friendlyName ? `name: '${friendlyName}', ` : '';
        return {
            name: `${sn.SubnetId} (${formattedFriendlyName}Availability Zone: ${sn.AvailabilityZone}, Public IP On Launch: ${
                sn.MapPublicIpOnLaunch ? 'yes' : 'no'
            })`,
            value: sn.SubnetId,
            short: sn.SubnetId
        };
    });

    const defaultSubnetValue = storedSubnetValue =>
        storedSubnetValue || [_.get(this.awsFacts.availableSubnets, '[0].SubnetId'), _.get(this.awsFacts.availableSubnets, '[1].SubnetId')];
    const validateSubnet = input =>
        _.isEmpty(input) || (_.isArray(input) && input.length < 2) ? 'You must select two or more subnets' : true;

    const prompts = [
        {
            type: 'checkbox',
            name: 'elbSubnets',
            message: `Which subnets should we deploy the ${chalk.yellow('Network Load Balancer (ELB)')} to?`,
            choices: subnetList,
            default: defaultSubnetValue(this.aws.vpc.elbSubnets),
            validate: validateSubnet
        },
        {
            type: 'checkbox',
            name: 'appSubnets',
            message: `Which subnets should we deploy the ${chalk.yellow('Application & Database')} to?`,
            choices: subnetList,
            default: defaultSubnetValue(this.aws.vpc.appSubnets),
            validate: validateSubnet
        }
    ];

    return this.prompt(prompts).then(props => {
        const publicIpOnLaunchArray = appSubnets =>
            _.chain(this.awsFacts.availableSubnets)
                .filter(availableSubnet => _.includes(appSubnets, availableSubnet.SubnetId))
                .map('MapPublicIpOnLaunch')
                .uniq()
                .value();

        const uniqueIPLaunch = publicIpOnLaunchArray(props.appSubnets);
        const shouldAppHavePublicIP = _.head(uniqueIPLaunch);
        if (uniqueIPLaunch.length !== 1) {
            this.log.ok(
                `⚠️ Mix of Application Subnets containing contradictory 'MapPublic Ip On Launch' values. Defaulting to '${
                    shouldAppHavePublicIP ? 'yes' : 'no'
                }'`
            );
        }

        this.aws.vpc.elbSubnets = props.elbSubnets;
        this.aws.vpc.appSubnets = props.appSubnets;
        this.aws.vpc.appSubnetsLaunchWithPublicIP = shouldAppHavePublicIP;
        done();
    });
}
function askForSubnets ( ) { if ( this . abort ) return null ; const done = this . async ( ) ; const subnetList = _ . map ( this . awsFacts . availableSubnets , sn => { const friendlyName = _getFriendlyNameFromTag ( sn ) ; const formattedFriendlyName = friendlyName ? ` ${ friendlyName } ` : '' ; return { name : ` ${ sn . SubnetId } ${ formattedFriendlyName } ${ sn . AvailabilityZone } ${ sn . MapPublicIpOnLaunch ? 'yes' : 'no' } ` , value : sn . SubnetId , short : sn . SubnetId } ; } ) ; const defaultSubnetValue = storedSubnetValue => storedSubnetValue || [ _ . get ( this . awsFacts . availableSubnets , '[0].SubnetId' ) , _ . get ( this . awsFacts . availableSubnets , '[1].SubnetId' ) ] ; const validateSubnet = input => _ . isEmpty ( input ) || ( _ . isArray ( input ) && input . length < 2 ) ? 'You must select two or more subnets' : true ; const prompts = [ { type : 'checkbox' , name : 'elbSubnets' , message : ` ${ chalk . yellow ( 'Network Load Balancer (ELB)' ) } ` , choices : subnetList , default : defaultSubnetValue ( this . aws . vpc . elbSubnets ) , validate : validateSubnet } , { type : 'checkbox' , name : 'appSubnets' , message : ` ${ chalk . yellow ( 'Application & Database' ) } ` , choices : subnetList , default : defaultSubnetValue ( this . aws . vpc . appSubnets ) , validate : validateSubnet } ] ; return this . prompt ( prompts ) . then ( props => { const publicIpOnLaunchArray = appSubnets => _ . chain ( this . awsFacts . availableSubnets ) . filter ( availableSubnet => _ . includes ( appSubnets , availableSubnet . SubnetId ) ) . map ( 'MapPublicIpOnLaunch' ) . uniq ( ) . value ( ) ; const uniqueIPLaunch = publicIpOnLaunchArray ( props . appSubnets ) ; const shouldAppHavePublicIP = _ . head ( uniqueIPLaunch ) ; if ( uniqueIPLaunch . length !== 1 ) { this . log . ok ( ` shouldAppHavePublicIP ? 'yes' : 'no' } ` ) ; } this . aws . vpc . elbSubnets = props . elbSubnets ; this . aws . vpc . appSubnets = props . appSubnets ; this . aws . vpc . appSubnetsLaunchWithPublicIP = shouldAppHavePublicIP ; done ( ) ; } ) ; }
Ask user to select availability information (availability, zones)/
Ask user to select availability information ( availability zones ) /
Ask For Subnets