npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cfn-stack

v2.0.1

Published

CLI for launching CloudFormation stacks using local parameter files

Downloads

52

Readme

cfn-stack Build Status

CLI for launching CloudFormation stacks using local parameter files

cfn-stack is a simple CLI designed to join templates with YAML files that specify the stack name, template, and input parameters.

It is designed to work with stack files organized into a logical folder structure. A simple application might use the following stack configuration:

.
├── development
│   ├── _defaults.yml
│   ├── api.yml
│   └── web.yml
└── production
    ├── _defaults.yml
    ├── api.yml
    └── web.yml

You'll point cfn-stack to an individual stack configuration (e.g. production/api.yml). A _defaults.yml file can supply default parameters to every stack. These defaults are read recursively (up to the working directory) so you can apply defaults at multiple levels in the file tree.

Your stack file might look like this:

Template: api.yml
Parameters:
  DnsName: api.web

The live stack that cfn-stack creates will be named based on the file path. production/api.yml is created as production-api. This allows you to store stack configurations outside of AWS, under version control, while still retaining a clear relationship between your source files and CloudFormation.

Install

To use the CLI:

npm install --global cfn-stack

Or to use the API:

npm install --save cfn-stack

Usage

CLI

cfn-stack stacks/production/api.yml

API

var cfnStack = require('cfn-stack')

var stack = {
  Name: 'my-stack',
  TemplateBody: fs.readFileSync('api.yml'),
  Parameters: {
    DnsName: 'api.web'
  }
}

cfnStack(stack, {region: 'us-east-1'}, callback)

CLI

cfn-stack <stack>

Creates a live CloudFormation stack using the configuration specified in the stack YAML file.

--stack-name

Type: string

A custom name to use for the stack. If omitted, a stack name will be generated using the stack file path.

cfn-stack stacks/production/api.yml --stack-name 'my-custom-name'
--load

Type: string

An expression that will be used to generate a shell command for loading/pre-processing the template. The token $0 will be replaced with the template path.

cfn-stack stacks/production/api.yml --load 'my-cfn-preprocessor $0'
--template-directory

Type: string
Default: templates/

Specifies the directory where template paths will be resolved.

--disable-rollback

Type: boolean
Default: false

Prevents CloudFormation from rolling back and deleting resources when stack creation fails. Does not apply to stack updates.

--region

Type: string
Default: us-east-1

The AWS region where the stack will be deployed.

API

cfnStack(stack, options, callback) -> output

stack

Required
Type: object

A stack object defining the stack name, parameters, and template.

Name

Required
Type: string

The name that will be assigned to the stack.

Capabilities

Type: array
Default: []

An array of strings specifying stack capabilities.

Template

Required
Type: string

A JSON or YAML CloudFormation template string.

Parameters

Type: object
Default: undefined

The stack parameters expressed as an object of strings/numbers/arrays. All values will be coerced to strings (required by CloudFormation). Arrays will be converted to comma delimited lists.

options
region

Required
Type: string

The AWS region where the stack will be launched.

disableRollback

Type: boolean
Default: false

Disables rollback of stacks that cannot be created successfully.

update

Type: boolean
Default: false

Specifies that the stack already exists and should be updated instead of created. By default, the library will first try to create a stack and then update an existing one if it already exists.

License

MIT © Ben Drucker