All Projects → seanedwards → Cfer

seanedwards / Cfer

Licence: mit
Toolkit and Ruby DSL for automating infrastructure using AWS CloudFormation

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Cfer

Serverless
This is intended to be a repo containing all of the official AWS Serverless architecture patterns built with CDK for developers to use. All patterns come in Typescript and Python with the exported CloudFormation also included.
Stars: ✭ 1,048 (+1077.53%)
Mutual labels:  aws, cloudformation
Awsconsolerecorder
Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.
Stars: ✭ 1,152 (+1194.38%)
Mutual labels:  aws, cloudformation
Quickstart Taskcat Ci
AWS Quick Start Team
Stars: ✭ 57 (-35.96%)
Mutual labels:  aws, cloudformation
Shorty.sls
Serverless URL shortener written in Python3 using the serverless framework
Stars: ✭ 35 (-60.67%)
Mutual labels:  aws, cloudformation
Cfn Sphere
AWS CloudFormation stack management tool
Stars: ✭ 76 (-14.61%)
Mutual labels:  aws, cloudformation
Aws Unifi Controller
Example of a Ubiquiti Unifi Controller in AWS using Network Load Balancer for TLS termination
Stars: ✭ 37 (-58.43%)
Mutual labels:  aws, cloudformation
Kube Aws
[EOL] A command-line tool to declaratively manage Kubernetes clusters on AWS
Stars: ✭ 1,146 (+1187.64%)
Mutual labels:  aws, cloudformation
Cfn Generic Custom Resource
CloudFormation generic custom resource provider
Stars: ✭ 26 (-70.79%)
Mutual labels:  aws, cloudformation
Aws Multi Account Viewer
Serverless app designed for any customer with two or more accounts to view resources across accounts/regions in simple single pane of glass website
Stars: ✭ 87 (-2.25%)
Mutual labels:  aws, cloudformation
Cform Vscode
CloudFormation extension for Visual Studio Code
Stars: ✭ 73 (-17.98%)
Mutual labels:  aws, cloudformation
Aws Scalable Big Blue Button Example
Demonstration of how to deploy a scalable video conference solution based on Big Blue Button
Stars: ✭ 29 (-67.42%)
Mutual labels:  aws, cloudformation
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-7.87%)
Mutual labels:  aws, cloudformation
Aws Auto Terminate Idle Emr
AWS Auto Terminate Idle AWS EMR Clusters Framework is an AWS based solution using AWS CloudWatch and AWS Lambda using a Python script that is using Boto3 to terminate AWS EMR clusters that have been idle for a specified period of time.
Stars: ✭ 21 (-76.4%)
Mutual labels:  aws, cloudformation
Aws Data Replication Hub
Seamless User Interface for replicating data into AWS.
Stars: ✭ 40 (-55.06%)
Mutual labels:  aws, cloudformation
Cloudmagick
CloudMagick is a serverless application which provides a dynamic image transformation like the small light module of apache2
Stars: ✭ 11 (-87.64%)
Mutual labels:  aws, cloudformation
Cfn Create Or Update
Create or update CloudFormation stack also if no updates are to be performed.
Stars: ✭ 59 (-33.71%)
Mutual labels:  aws, cloudformation
Serverless Aws Lambda Node Postgres
Serverless AWS Lambda with Node.js,Postgres Rest API with Sequelize.
Stars: ✭ 18 (-79.78%)
Mutual labels:  aws, cloudformation
Cfn Remediate Drift
Automated CloudFormation drift remediation using Import functionality
Stars: ✭ 19 (-78.65%)
Mutual labels:  aws, cloudformation
Sceptre
Build better AWS infrastructure
Stars: ✭ 1,160 (+1203.37%)
Mutual labels:  aws, cloudformation
Cloudformation Templates
Common tasks automated by CloudFormation
Stars: ✭ 79 (-11.24%)
Mutual labels:  aws, cloudformation

Cfer

Build Status Gem Version Code Climate Test Coverage Issue Count

Cfer is a lightweight toolkit for managing CloudFormation templates.

Read about Cfer here.

Sign up for the Cfer mailing list to receive updates when changes are made. Cfer is a slow-moving project, so you can expect around one or two updates per year at most.

Support

Cfer is pre-1.0 software, and may contain bugs or incomplete features. Please see the license for disclaimers.

If you would like support or guidance on Cfer, or CloudFormation in general, I offer DevOps consulting services. Please Contact me and I'll be happy to discuss your needs.

You can also find me at @tilmonedwards. If you use Cfer, or are considering it, I'd love to hear from you.

Installation

Add this line to your application's Gemfile:

gem 'cfer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cfer

Usage

To quickly see Cfer in action, try converging the example stacks:

cfer converge vpc -t examples/vpc.rb --profile [YOUR-PROFILE] --region [YOUR-REGION]
cfer converge instance -t examples/instance.rb --profile [YOUR-PROFILE] --region [YOUR-REGION] KeyName=[YOUR-EC2-SSH-KEY]

You should see something like this:

Demo

Command line

COMMANDS
    converge     Create or update a cloudformation stack according to the template
    delete       Deletes a CloudFormation stack
    describe     Fetches and prints information about a CloudFormation
    estimate     Prints a link to the Amazon cost caculator estimating the cost of the resulting CloudFormation stack
    generate     Generates a CloudFormation template by evaluating a Cfer template
    help         show help
    tail         Follows stack events on standard output as they occur

Template Anatomy

See the examples directory for some examples of complete templates.

Parameters

Parameters may be defined using the parameter function:

parameter :ParameterName,
  type: 'String',
  default: 'ParameterValue'

Any parameter can be referenced either in Ruby by using the parameters hash:

parameters[:ParameterName]

Parameters can also be used in a CloudFormation reference by using the Fn::ref function:

Fn::ref(:ParameterName)

Resources

Resources may be defined using the resource function:

resource :ResourceName, 'AWS::CloudFormation::CustomResource', AttributeName: {:attribute_key => 'attribute_value'} do
  property_name 'property_value'
end

Gets transformed into the corresponding CloudFormation block:

"ResourceName": {
  "Type": "AWS::CloudFormation::CustomResource",
  "AttributeName": {
    "attribute_key": "attribute_value"
  },
  "Properties": {
    "PropertyName": "property_value"
  }
}

Outputs

Outputs may be defined using the output function:

output :OutputName, Fn::ref(:ResourceName)

Outputs may be retireved from other stacks anywhere in a template by using the lookup_output function.

lookup_output('stack_name', 'output_name')

Including code from multiple files

Templates can get pretty large, and splitting template code into multiple files can help keep things more manageable. The include_template function works in a similar way to ruby's require_relative, but within the context of the CloudFormation stack:

include_template 'ec2.rb'

You can also include multiple files in a single call:

include_template(
  'stack/ec2.rb',
  'stack/elb.rb'
)

The path to included files is relative to the base template file (e.g. the converge command -t option).

SDK

Embedding the Cfer SDK involves interacting with two components: The Client and the Stack. The Cfer Client is the interface with the Cloud provider.

Basic API

The simplest way to use Cfer from Ruby looks similar to the CLI:

  Cfer.converge! '<stack-name>', template: '<template-file>'

This is identical to running cfer converge <stack-name> --template <template-file>, but is better suited to embedding in Rakefiles, chef recipes, or your own Ruby scripts. See the Rakefile in this repository for how this might look.

Cfn Client

The Client is a wrapper around Amazon's CloudFormation client from the AWS Ruby SDK. Its purpose is to interact with the CloudFormation API.

Create a new client:

Cfer::Cfn::Client.new(stack_name: <stack_name>)

Cfer::Cfn::Client also accepts options to be passed into the internal Aws::CloudFormation::Client constructor.

converge(stack)

Creates or updates the CloudFormation stack to match the input stack object. See below for how to create Cfer stack objects.

client.converge(<stack>)

tail(options = {})

Yields to the specified block for each CloudFormation event that qualifies given the specified options.

client.tail number: 1, follow: true do |event|
  # Called for each CloudFormation event, as they occur, until the stack enters a COMPLETE or FAILED state.
end

Cfer Stacks

A Cfer stack represents a baked CloudFormation template, which is ready to be converted to JSON.

Create a new stack:

stack_from_file

stack = Cfer::stack_from_file(<file>, client: <client>)

stack_from_block

stack = Cfer::stack_from_block(client: <client>) do
  # Stack definition goes here
end

Contributing

This project uses git-flow. Please name branches and pull requests according to that convention.

Always use --no-ff when merging into develop or master.

This project also contains a Code of Conduct, which should be followed when submitting feedback or contributions to this project.

New features

  • Branch from develop
  • Merge into develop
  • Name branch feature/<feature-name>

Unreleased bugs

  • Branch from develop
  • Merge into develop
  • Name branch bugfix/<issue-id>

Bugfixes against releases

  • Branch from master
  • Merge into develop and master
  • Name branch hotfix/<issue-id>

Releases

  • Branch from develop
  • Merge into develop and master
  • Name branch release/<major.minor>

Release Notes

Change Log

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].