0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby gem to create AWS CloudFormation descriptions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.5
~> 10.1
 Project Readme

CloudFormation

A Ruby gem to create AWS CloudFormation descriptions.

Installation

Add this line to your application's Gemfile:

gem 'cloud_formation'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloud_formation

Usage

Generate a template

template = CloudFormation::Template.new

template.build do |t|
  t.name = "stack-name"
  t.description = "A description of the stack"
end

template.render

Running this will generate a nicely compacted:

{"AWSTemplateFormatVersion":"2010-09-09","Name":"stack-name","Description":"A description of the stack","Resources":{}}

Generate a DynamoDB table

Generating a DynamoDB table is as simple as:

template = CloudFormation::Template.new

template.build do |t|
  t.name = "stack-name"
  t.description = "A description of the stack"
end

dynamo_db = CloudFormation::DynamoDB.new

table = dynamo_db.build_table do |t|
  t.name = "commentsTable"
  t.read_capacity_units = 10
  t.write_capacity_units = 5
  t.hash_key = { blog_post_id: :number }
  t.range_key = { comment_id: :number }
end

template.add_resource table

puts template.render pretty: true

Running with the pretty true options will generate an easier to read version:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Name": "stack-name",
  "Description": "A description of the stack",
  "Resources": {
    "commentsTable": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
        "ProvisionedThroughput": {
          "WriteCapacityUnits": "5",
          "ReadCapacityUnits": "10"
        },
        "KeySchema": {
          "RangeKeyElement": {
            "AttributeName": "comment_id",
            "AttributeType": "N"
          },
          "HashKeyElement": {
            "AttributeName": "blog_post_id",
            "AttributeType": "N"
          }
        }
      }
    }
  }
}

Contributing

  1. Fork it ( http://github.com/davidrhyswhite/cloud_formation/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request