Simple utility for creating temporary AWS CloudFormation stacks (featurestacks) for feature branches
cfn-featurestack will by default use any locally pre-configured AWS account. You can pre-configure your account by any of the following methods:
- With aws-cli, by running
aws-cli configure
(Recommended for local environments) - Set
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,AWS_PROFILE
andAWS_REGION
environment variables (Recommended for server/container environments) - Directly configure to
.aws\config
and.aws\credentials
files
Additionally, you can define your AWS access and secret keys as parameters, but this is not recommended as they A) can end to version control or B) will stay readable in logs.
cfn-featurestack will add IsFeatureStack
parameter to your stack parameters, which enables you
to set conditions for CloudFormation not to create specific resources for featurestacks (such as
CloudFront distributions and Route53 domain names).
- Add
IsFeatureStack
parameter and conditions for it.
Parameters:
IsFeatureStack:
Description: "Is this a feature stack. (Defaults to \"false\")"
Type: String
Default: "false"
Conditions:
IsNotFeatureStack: !Equals [ !Ref IsFeatureStack, "false" ]
IsFeatureStack: !Equals [ !Ref IsFeatureStack, "true" ]
- Add
IsNotFeatureStack
to any resource that must be unique across stacks and cannot be duplicated to feature stacks, such as CloudFront distributions and Route53 domain names.
Resources:
CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Condition: IsNotFeatureStack
Properties:
# ...
npm install cfn-featurestack -g
cfn-featurestack --template=./cfn/cfn-stack.yaml
See options for more details.
npm install cfn-featurestack --save-dev
Add deploy script to package.json
:
{
"scripts": {
"deploy": "cfn-featurestack --template=./cfn/cfn-stack.yaml"
}
}
See options for more details.
Path to template file
Path to parameters file (.json). Multiple parameters options are allowed and values are combined in the order they are defined, with values from latter overwriting previous
Valid .json files:
-
aws-cli cloudformation
type:
[
{
"ParameterKey": "FirstParam",
"ParameterValue": "first-param-value"
},
{
"ParameterKey": "SecondParam",
"ParameterValue": "second-param-value"
}
]
- AWS CodePipeline parameters type:
{
"Parameters": {
"FirstParam": "first-param-value",
"SecondParam": "second-param-value"
}
}
- Plain JSON object
{
"FirstParam": "first-param-value",
"SecondParam": "second-param-value"
}
Multiple parameters files
cfn-featurestack --template=./cfn/cfn-stack.yaml --parameters=./cfn/params1.json --parameters=./cfn/params2.json
AWS region
AWS IAM capabilities
Valid values:
- CAPABILITY_IAM
- CAPABILITY_NAMED_IAM
Load profile from shared credentials file (in .aws\credentials
)
AWS Access Key
AWS Secret Access Key
Show version number
Show help