cfn-nest
Transform relative stack paths in a CloudFormation template into full S3 URLs
Last updated 4 years ago by bendrucker .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cfn-nest 
SYNC missed versions from official npm registry.

cfn-nest Build Status Greenkeeper badge

Transform relative stack paths in a CloudFormation template into full S3 URLs

Install

$ npm install --save cfn-nest

Usage

Given a pseudo-valid nested stack template:

{
  "Resources": {
    "Nested": {
      "Type": "AWS::CloudFormation::Stack",
      "Properties": {
        "Template": "nested.json"
      }
    }
  }
}

CLI

cfn-nest template.json --bucket my-templates

Any nested templates will be uploaded to S3 as required by CloudFormation. The Template property will be replaced by a valid TemplateURL. This URL contains an MD5 hash of the file contents so different versions will always produce unique URLs. Un-nesting is performed recursively so you can write templates that reference templates that reference other templates (and so on).

The Template path is resolved relative to the template source file.

API

var CfnNest = require('cfn-nest')
var JSONStream = require('JSONStream')
var through = require('through2')

fs.createReadStream('template.json')
  .pipe(JSONStream.parse())
  .pipe(CfnNest({bucket: 'my-templates'}))
  .pipe(through.obj(function (chunk, enc, callback) {
    callback(null, JSON.stringify(chunk))  
  }))
  .pipe(process.stdout)

API

CfnNest(options) -> stream

Creates a new Transform stream that expects parsed CloudFormation template objects as input.

options
bucket

Required
Type: string

The name of the S3 bucket to use.

cwd

Type: string
Default: process.cwd()

The working directory to use when resolving template paths.

stream.on('upload', handler)

handler

Required
Type: function
Arguments: file

A listener that will be called after each file upload. The file is an object with local and s3 path properties.

License

MIT © Ben Drucker

Current Tags

  • 3.0.1                                ...           latest (2 years ago)

8 Versions

  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 1
Dependencies (11)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |