Non-Partisan Magicians

    aws-cf-monitor
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    aws-cf-monitor

    Build Status npm npm npm

    A wrapper around the AWS CloudFormation Node API that monitors the progress of CF commands while providing smart logging.

    The AWS API handles CloudFormation commands asynchronously, meaning you make a request to create a stack and you then write a bunch of boilerplate code to poll and wait for the creation to finish.

    This aims to replace that boilerplate code with some pretty winston logging so you can watch the events as they come.

    Usage

    import AWS from 'aws-sdk';
    import { LOG_NAME, Monitor } from 'aws-cf-monitor';
    import winston from 'winston';
     
    const input = {StackName: 'blah', TemplateBody: 'template goes here'};
    const cf = new AWS.CloudFormation();
     
    // simplest log configuration
    winston.loggers.add(LOG_NAME, {
        format: winston.format.simple(),
        transports: [new winston.transports.Console()]
    });
     
    cf.createStack(input).promise()
        .then(() => new Monitor().monitor(name, cf))
        .then((status) => {
          console.log(`Hooray, the stack is ${status}`);
          console.log('And I didn\'t have to write a bunch of boilerplate to wait for it!');
        });

    Delay Interval

    As the CFMonitor waits for your stack to complete, it will poll for the status. The interval in between polls can be controlled via the AWS_CF_MONITOR_DELAY environment variable. The default is 5000 milliseconds.

    Configure logger

    You can configure the logger by whichever means you prefer to configure a winston logger. The name of the logger is aws-cf-monitor, which is a constant saved in LOG_NAME.

    See the winston project for more information.

    Inspiration

    The way the [serverless framework](https://github.com/serverless/serverless) handles these CloudFormation requests is the inspiration. The framework handles polling well and prints some pretty color-coded logging as well, making it easy to follow the progress of the stack.

    The bulk of that original logic is in the monitorStack.js.

    Install

    npm i aws-cf-monitor

    DownloadsWeekly Downloads

    79

    Version

    2.1.0

    License

    ISC

    Unpacked Size

    15.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • colbywhite