项目作者: mokele

项目描述 :
CloudFormation + CodePipeline Template Configuration For CLI Tools
高级语言: JavaScript
项目地址: git://github.com/mokele/template-configuration.git
创建时间: 2020-10-31T23:19:25Z
项目社区:https://github.com/mokele/template-configuration

开源协议:

下载


CloudFormation + CodePipeline Template Configuration For CLI Tools

Making development closer to production use of CodePipeline

See Limitations section towards the bottom

Supported CLI Tools

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:

  1. $ tc aws cloudformation deploy ...
  2. $ tc aws cloudformation create-change-set ...
  3. $ tc sam deploy ...
  4. $ 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)

  1. {
  2. "Parameters": {
  3. "Key": "Value"
  4. },
  5. "Tags": {
  6. "TagKey": "TagValue"
  7. },
  8. "StackPolicy": {
  9. "Statement": [
  10. {
  11. "Effect": "Allow",
  12. "NotAction": "Update:Delete",
  13. "Principal": "*",
  14. "Resource": "*"
  15. }
  16. ]
  17. }
  18. }

And do away with your flakey non-production-like deploy scripts, and stop
doing these:

  1. $ aws cloudformation deploy \
  2. --parameter-overrides \
  3. Key=Value \
  4. Key2=Value2 \
  5. ...
  1. $ aws cloudformation create-change-set \
  2. --parameters \
  3. ParameterKey=Key,ParameterValue=Value \
  4. ParameterKey=Key2,ParameterValue=Value2 \
  5. ...
  1. $ sam deploy \
  2. --parameter-overrides \
  3. ParameterKey=Key,ParameterValue=Value \
  4. ParameterKey=Key2,ParameterValue=Value2 \
  5. ...
  1. $ rain \
  2. --params \
  3. 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)

  1. aws () { template-configuration "$0" "$@" }
  2. sam () { template-configuration "$0" "$@" }
  3. rain () { template-configuration "$0" "$@" }

Then tc is implicit and no longer needed

  1. $ aws cloudformation deploy ...
  2. $ aws cloudformation create-change-set ...
  3. $ sam deploy ...
  4. $ 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 ...
  • 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 a template-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> override template-configuration/default.json with another local file path
    • e.g. tc --config template-configuration/test.json sam deploy ...