cloudform
TypeScript-based imperative way to define AWS CloudFormation templates
Installation
npm install --save-dev cloudform
Usage
- 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 ...