CloudFormation + CodePipeline Template Configuration For CLI Tools
Making development closer to production use of CodePipeline
See Limitations section towards the bottom
Supported CLI Tools
aws cloudformation
https://aws.amazon.com/cli/deploy | create-stack | create-change-set | create-stack-instances | create-stack-set | update-stack | update-stack-instances | update-stack-set
aws serverlessrepo create-cloud-formation-change-set
https://aws.amazon.com/cli/sam deploy
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.htmlrain deploy
https://github.com/aws-cloudformation/rain
Fed up of the following commands all differing in their parameter overrides and tags parameter formats? and them all differing from how CloudFormation Actions in CodePipeline are configured?
Then do one of these:
$ tc aws cloudformation deploy ...$ tc aws cloudformation create-change-set ... $ tc sam deploy ... $ tc rain deploy ...
With a template configuration file template-configuration/default.json
(see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-cfn-artifacts.html#w2ab1c21c17c15)
And do away with your flakey non-production-like deploy scripts, and stop doing these:
$ aws cloudformation deploy \ --parameter-overrides \ Key=Value \ Key2=Value2 \ ...
$ aws cloudformation create-change-set \ --parameters \ ParameterKey=Key,ParameterValue=Value \ ParameterKey=Key2,ParameterValue=Value2 \ ...
$ sam deploy \ --parameter-overrides \ ParameterKey=Key,ParameterValue=Value \ ParameterKey=Key2,ParameterValue=Value2 \ ...
$ rain \ --params \ Key=Value,Key2=Value2
Implicit Proxy
Add the following to your shell rc/profile file to replace aws
, sam
,
and/or rain
with implicit tc
proxying (e.g. ~/.bashrc
, ~/.zshrc
, etc)
Then tc
is implicit and no longer needed
$ aws cloudformation deploy ...$ aws cloudformation create-change-set ...$ sam deploy ...$ rain deploy ...
Limitations
- only supports commands without global arguments between them (where they
would otherwise be supported)
- supported
aws cloudformation deploy ... --profile <profile> --region <region>
- not-supported
aws --profile <profile> --region <region> cloudformation deploy ...
- supported
- only supports proxying to help commands where help arguments are the last argument e.g.
aws cloudformation deploy help
- does not and does not plan to support merging each commands existing parameter arguments with a template configuration file
- add support for
tc --parameters ... [cmd ...]
for 1 single way override template configuration file values - test / add support for parameters with quoted values
- support
UsePreviousValue
-
tc help --help -h
- support
StackPolicy
for those commands that support it, and maybe do 2nd api call if needed for those where it is not
Arguments
Some arguments can come before the proxied command e.g. tc <here> aws ...
tc init
create atemplate-configuration/default.json
file, with optional additional--config
argument--debug
echos out the command that is also ran--dryrun
only echo out the command that would otherwise be ran – implies--debug
--config <configuration-file>
overridetemplate-configuration/default.json
with another local file path- e.g.
tc --config template-configuration/test.json sam deploy ...
- e.g.