JSPM

  • Created
  • Published
  • Downloads 21038
  • Score
    100M100P100Q134300F
  • License MIT

TypeScript-based imperative way to define AWS CloudFormation templates

Package Exports

  • cloudform

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cloudform) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cloudform

TypeScript-based imperative way to define AWS CloudFormation templates

Installation

npm install --save-dev cloudform

Usage

  1. Define your CloudFormation template in a TypeScript file, for example template.ts:
TODO imports

cloudform({
    Description: 'My template',
    Parameters: {
        DeployEnv: new StringParameter({
            Description: 'Deploy environment name',
            AllowedValues: ['dev', 'stage', 'production']
        })
    },
    Mappings: {
        SubnetConfig: {
            VPC: {
                CIDR: '10.0.0.0/16'
            }
        }
    },
    Resources: {
        VPC: new VPC({
            CidrBlock: Fn.FindInMap('SubnetConfig', 'VPC', 'CIDR'),
            EnableDnsHostnames: true,
            Tags: [
                new ResourceTag('Application', Refs.StackName),
                new ResourceTag('Network', 'Public'),
                new ResourceTag('Name', Fn.Join('-', [Refs.StackId, 'VPC']))
            ]
        })
    }
})

See also example/example.ts.

2. Run cloudform path/to/your/template.ts to generate the CloudFormation template as JSON.

It make sense to define it in your npm scripts and run within your build or deployment pipeline, for example:

"scripts": {
  // ...
  "generate-cloudformation-template": "cloudform path/to/your/template > template.aws"
}

API

The types are generated automatically from the AWS-provided schema file, so cloudform supports all the types available in AWS CloudFormation. The general layout is ...