Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ashnazg/precipitator

xander18MIT0.0.3

a higher level wrapper for cloud provisioning APIs

readme


title: "@ashnazg/precipitator"

Usage

var ec2   = require('@ashnazg/precipitator/create-ec2.js'); // ~/projects/ashnazg-npm/precipitator/create-ec2.js
var setup = require('@ashnazg/precipitator/ssh-setup.js');  // ~/projects/ashnazg-npm/precipitator/ssh-setup.js

async function exampleLibUsage() {
    ec2.init('us-west-2'); // if you don't init() with your desired region, it'll default to us-west-2

    var disk_in_gigs = 8;
    var tags = {Name: 'server label Name'};
    var conf = ec2.createConfig(tags, {
        InstanceType: 't3a.nano',
        ImageId:  'ami-06e54d05255faf8f6',
        KeyName: 'xander@ashnazg.com',

    // SubnetId: 'subnet-6804e831', // if unspecified, AWS will pick from valid subnets
    // SecurityGroupIds: ['sg-35137850'], // if unspecified, AWS will use your sg named 'default'

    // these are the default and can be omitted:
    //    MinCount: 1,
    //    MaxCount: 1
    }, disk_in_gigs);

    try {
        var definition = await ec2.createEC2(conf); // note that Name is just a tag; I'm going to actually set up DNS/certs in a later call.
        var {url, ip} = definition;
        // url is a convenience link to the aws ec2 console with this server selected in the filters.
        // there's also regurgitations of {conf, opts} so that you can associate the results with the inputs you gave
        // {create_resp, describe_resp} are the full AWS responses for those api calls; {meta} is a shortcut to just the instance description itself.
    } catch (e) {
        u.die(e);
    }
    try {
        var sudo_user = 'ubuntu';
        var {package_manager} = await setup.waitForReadiness(definition, sudo_user, {tries: 10, retry_delay: 5, initial_delay: 0, verbosity: 0});
        // waitForReadiness returns the same definition except that it's added 'yum' or 'apt-get' as {package_manager}
    } catch (e) {
        console.error("could not reach new ec2:");
        u.die(e);
    }
}