Tool to import and merge sections of CloudFormation yaml
npm install @magicmark/cf-mergecf-merge brings import syntax to CloudFormation templates. Split up and modularize your stacks!
Use top-level imports to merge in other templates:
``yaml@import ./networking.yml
@import ./security.yml
AWSTemplateFormatVersion: 2010-09-09
Parameters:
- foo
Resources:
- bar
`
Use inline imports to merge in sections of other templates:
`yaml`
AWSTemplateFormatVersion: 2010-09-09
Parameters:
- foo
# @import ./ec2_instances.yml#Parameters
Resources:
- bar
# @import ./ec2_instances.yml#Resources
See the tests to see examples of this in action.
cf-merge is distributed as a nodejs package. You can install it via npm or yarn:
`sh`
yarn add @magicmark/cf-merge
You can then call cf-merge in your bash script when calling aws cloudformation deploy:
`sh`
aws cloudformation deploy \
--region $REGION \
--profile $CLI_PROFILE \
--stack-name $STACK_NAME \
--template-file "$(yarn cf-merge main.yml --tmpfile)" \
`
cf-merge
Positionals:
file path to a CloudFormation template file [string]
Options:
--version Show version number [boolean]
--help Show help [boolean]
--path, -p output file path (will print output to stdout if not specified)
[string]
--tmpfile, -t print template to a tmpfile. prints the filepath to stdout.
[boolean] [default: false]
``