项目作者: KablamoOSS

项目描述 :
Extend CloudFormation with plugins
高级语言: Go
项目地址: git://github.com/KablamoOSS/kombustion.git
创建时间: 2018-05-21T12:22:12Z
项目社区:https://github.com/KablamoOSS/kombustion

开源协议:MIT License

下载


Kombustion Logo

Kombustion

Build Status

Go Report Card
Coverage Status

Extend CloudFormation with plugins

Kombustion uses plugins to preprocess and extend your CloudFormation templates.

In addition to generating templates, Kombustion can also create, update and
delete your CloudFormation stacks.

Kombustion has automatic support for new CloudFormation types as they are
released.

See the Quick start for more
details.

Getting Started

Kombustion is built for Linux, FreeBSD, MacOS and Windows.

Get the latest release from the
release page.

After downloading for MacOS or Linux, you will need to move the kombustion
binary into your $PATH, and make it executable.

  1. sudo chmod +x kombustion
  2. sudo cp kombustion /usr/local/bin/kombustion

Usage

Initialise a kombustion.yaml file with the following:

  1. $ kombustion init

This is an example of kombustion.yaml, it should be committed to version
control.

  1. # Name of this project. This is used with `--environment` to create a stack name, which can
  2. # be overridden with `--stack-name`
  3. Name: KombustionExample
  4. # Region is the default region stacks will be deployed into. Can be overridden with `--region us-east-2`
  5. Region: us-east-1
  6. # Plugins can be installed by running `kombustion add github.com/KablamoOSS/kombustion-plugin-serverless`
  7. Plugins:
  8. github.com/KablamoOSS/kombustion-plugin-serverless@0.1.0:
  9. Name: github.com/KablamoOSS/kombustion-plugin-serverless
  10. Version: 0.1.0
  11. Environments:
  12. Development:
  13. # Optionally allowlist the accounts for the environment `development`, this will
  14. # ensure CloudFormation actions are only performed in this account
  15. AccountIDs:
  16. - "1234567890"
  17. # Parameters are added to the CloudFormation Stack during upsert
  18. Parameters:
  19. Environment: development
  20. # Kombustion can generate default outputs for your resources to use as references in other
  21. # stacks.
  22. GenerateDefaultOutputs: false

CloudFormation Stack Management

Upsert a CloudFormation template:

  1. $ kombustion upsert examples/stacks/test.yaml --stackName test-stack

Delete a CloudFormation stack:

  1. $ kombustion delete examples/stacks/test.yaml

Print all the events for a stack:

  1. $ kombustion events examples/stacks/test.yaml

StackName

You don’t need to specify --stack-name, instead when you pass an environment
--environment it gets merged in with the project name from kombustion.yaml
and the filename as {ProjectName}-{FileName}-{Environment}.

This applies to upsert,delete, and events.

CloudFormation Stacks

A stack template is written in the same way as standard CloudFormation.
Kombustion allows plugins to extend the syntax, but the end result is always
standard CloudFormation.

The following example shows how a small definition for a
bastion host, can be processed
into a bigger template. This lets your plugin maintain safe, sane defaults, and
ensure you don’t miss any required fields.

  1. # In this example we're going to create a bastion host.
  2. # This is a small EC2 instance, configured with a public IP
  3. # and a security group to allow us to SSH into our AWS cloud.
  4. AWSTemplateFormatVersion: 2010-09-09
  5. Description: Example EC2 Instance
  6. Parameters: {}
  7. Mappings: {}
  8. Resources:
  9. BastionHost:
  10. Type: Kombustion::Examples::BastionHost
  11. Properties:
  12. # In this example, this key would have been uploaded to AWS
  13. KeyName: my-ssh-key
  14. Size: t2.micro
  15. # Using a filter, find the most recent AMI of Amazon Linux 2
  16. AmiFilter:
  17. VirtualizationType: "hvm"
  18. Name: "amzn2-ami-*",
  19. RootDeviceType: "ebs"
  20. owners: ["amazon"],
  21. Latest: true

The Plugin Kombustion::Examples::BastionHost is used to generate the following
template. It uses the AmiFilter to find the correct AMI, and creates two
parameters for the KeyName and SSHLocation. The latter being the IP address
allowed through the security group.

  1. AWSTemplateFormatVersion: 2010-09-09
  2. Description: Example EC2 Instance
  3. Parameters:
  4. KombustionExampleBastionHostKeyName:
  5. Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
  6. Type: 'AWS::EC2::KeyPair::KeyName'
  7. Default: 'my-ssh-key'
  8. ConstraintDescription: must be the name of an existing EC2 KeyPair.
  9. KombustionExampleBastionHostSSHLocation:
  10. Description: The IP address range that can be used to SSH to the EC2 instances
  11. Type: String
  12. MinLength: '9'
  13. MaxLength: '18'
  14. Default: 0.0.0.0/0
  15. AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})'
  16. ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
  17. Mappings: {}
  18. Resources:
  19. Resources:
  20. EC2Instance:
  21. Type: 'AWS::EC2::Instance'
  22. Properties:
  23. InstanceType: !Ref InstanceType
  24. SecurityGroups:
  25. - !Ref InstanceSecurityGroup
  26. KeyName: !Ref KombustionExampleBastionHostKeyName
  27. ImageId: 'ami-c267b0a0'
  28. InstanceSecurityGroup:
  29. Type: 'AWS::EC2::SecurityGroup'
  30. Properties:
  31. GroupDescription: Enable SSH access
  32. SecurityGroupIngress:
  33. - IpProtocol: tcp
  34. FromPort: '22'
  35. ToPort: '22'
  36. CidrIp: !Ref KombustionExampleBastionHostSSHLocation
  37. IPAddress:
  38. Type: 'AWS::EC2::EIP'
  39. IPAssoc:
  40. Type: 'AWS::EC2::EIPAssociation'
  41. Properties:
  42. InstanceId: !Ref EC2Instance
  43. EIP: !Ref IPAddress

Check out the
examples
directory for example stacks.

Credentials

Kombustion uses the same method as the aws cli to get
credential information.
You can either use the standard environment variables AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN.

Or use a profile you have configured, for example:

  1. $ kombustion --profile myAwsProfile upsert examples/stacks/test.yaml --stackName test-stack

Plugins

Kombustion plugins are not yet supported on Windows, due to
this issue. Please use Docker or
WSL in the meantime.

Install a plugin:

  1. $ kombustion add github.com/Example/ExamplePlugin

Contributing

Please read
CONTRIBUTING.md
for details on our code of conduct, and the process for submitting pull requests
to us.

Versioning

We use SemVer for versioning. For the versions available,
see the
tags on this repository.

Maintainers

Kombustion is primarily maintained by the Kablamo
team. Pull requests are welcome.

Acknowledgements

The Kombustion logo is based on an original design by Renee French.

License

This project is licensed under the
MIT License.


Made with :heart: in Australia.