# cfn-nest

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

Latest version **3.0.1** (published 2019-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install cfn-nest
pnpm add cfn-nest
yarn add cfn-nest
bun add cfn-nest
```

Provides the command `cfn-nest`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2019-04-22 |
| First published | 2017-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8 |
| Dependencies | 10 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | aws, cloudformation, cfn, nested, stack, s3 |

## Links

- npm: https://www.npmjs.com/package/cfn-nest
- Repository: https://github.com/bendrucker/cfn-nest
- Homepage: https://github.com/bendrucker/cfn-nest#readme
- Issues: https://github.com/bendrucker/cfn-nest/issues
- npm.io page: https://npm.io/package/cfn-nest

## Dependencies (10)

- [ap](https://npm.io/package/ap.md) ~0.2.0
- [meow](https://npm.io/package/meow.md) ~5.0.0
- [hasha](https://npm.io/package/hasha.md) ~5.0.0
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.355.0
- [filter-obj](https://npm.io/package/filter-obj.md) ~2.0.0
- [map-values](https://npm.io/package/map-values.md) ~1.0.1
- [run-parallel](https://npm.io/package/run-parallel.md) ~1.1.6
- [concat-stream](https://npm.io/package/concat-stream.md) ~2.0.0
- [run-waterfall](https://npm.io/package/run-waterfall.md) ~1.1.3
- [cfn-template-stream](https://npm.io/package/cfn-template-stream.md) ~1.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2019-04-22
- 3.0.0 — 2019-04-06
- 2.1.0 — 2017-04-24
- 2.0.0 — 2017-02-21
- 1.0.3 — 2017-02-16
- 1.0.2 — 2017-02-16
- 1.0.1 — 2017-02-16
- 1.0.0 — 2017-02-14

## README

# cfn-nest [![Build Status](https://travis-ci.org/bendrucker/cfn-nest.svg?branch=master)](https://travis-ci.org/bendrucker/cfn-nest) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/cfn-nest.svg)](https://greenkeeper.io/)

> 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:

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

### CLI

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

Any nested templates will be uploaded to S3 as [required by CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html#cfn-cloudformation-stack-templateurl). 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

```js
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](http://bendrucker.me)

---
_Source: https://npm.io/package/cfn-nest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
