# Lono [![Build History][2]][1] [1]: http://travis-ci.org/tongueroo/lono [2]: https://secure.travis-ci.org/tongueroo/lono.png?branch=master Lono is a Cloud Formation Template ruby generator. Lono generates Cloud Formation templates based on ERB templates. ## Usage
$ gem install lono $ mkdir lono_project $ lono initThis sets up the basic lono project with an example template in source/app.json.erb.
$ lono generateThis generates the templates that have been defined in config/lono.rb. The example starter config/lono.rb looks like this: ```ruby template "prod-api-app.json" do source "app.json.erb" variables( :env => 'prod', :app => 'api', :role => "app", :ami => "ami-123", :instance_type => "c1.xlarge", :port => "80", :high_threshold => "15", :high_periods => "4", :low_threshold => "5", :low_periods => "10", :max_size => "24", :min_size => "6", :down_adjustment => "-3", :up_adjustment => "3", :ssl_cert => "arn:aws:iam::12345:server-certificate/wildcard" ) end template "prod-br-app.json" do source "app.json.erb" variables( :env => "prod", :app => 'br', :role => "app", :ami => "ami-456", :instance_type => "m1.medium", :port => "80", :high_threshold => "35", :high_periods => "4", :low_threshold => "20", :low_periods => "2", :max_size => "6", :min_size => "3", :down_adjustment => "-1", :up_adjustment => "2" ) end ``` The example ERB template file is in templates/app.json.erb. ## User Data Helper In the template files, there's user_data helper method available which can be used to include a user data script. The user data script should be in in the templates/user_data folder of the project. So: * user_data('bootstrap.sh.erb') -> templates/user_data/bootstrap.sh.erb * user_data('db.sh.erb') -> templates/user_data/db.sh.erb Here's how you would call it in the template. ```json "UserData": { "Fn::Base64": { "Fn::Join": [ "", [ <%= user_data('bootstrap.sh.erb') %> ] ] } ``` ## Generate You can generate the CF templates by running:
$ lono generateThe lono init command also sets up guard-lono. Guard-lono continuously generates the cloud formation templates. Just run guard.
$ guard