Continuously Generate CloudFormation Templates with Lono and Guard

Tung Nguyen
BoltOps
Published in
2 min readMay 24, 2017

When using lono if you sometimes forgot to regenerate the templates after making changes you can use lono with guard to never have to remember again.

Setup lono and guard

If you have created a lono project with the lono new command then the Guardfile should had already been set up for you. Then all you have to do is run:

bundle exec guard

If you manually set up the lono project, then you can have to install the gem and setup the Guardfile. Add guard-lon to your Gemfile and run bundle. Then set up the Guardfile by running the following.

guard init lono
bundle exec guard

Watching lono and guard

Once guard is running you should see something like this:

$ bundle exec guard
Generating CloudFormation templates:
./output/asg.yml
15:51:54 - INFO - Guard is now watching at '/Users/tung/src/tongueroo/cloudformation-examples-lono'
[1] guard(main)>

As you edit and save any files in the templates or config folders, the lono generate command will automatically run 😊 Here’s what it looks like after I’ve saved some files twice:

tung cloudformation-examples-lono (asg)$ bolt-dev $ bundle exec guard
Generating CloudFormation templates:
./output/asg.yml
15:51:54 - INFO - Guard is now watching at '/Users/tung/src/tongueroo/cloudformation-examples-lono'
Generating CloudFormation templates:
./output/asg.yml
Generating CloudFormation templates:
./output/asg.yml
[1] guard(main)>

Hope this was helpful! If you enjoyed this post, you also might like these:

Thanks for reading this far. If you found this post useful, I’d really appreciate it if you recommend this post (by clicking the clap button) so others can find it too! Also, connect with me on LinkedIn.

P.S. Be sure to join the BoltOps newsletter to receive free DevOps tips and updates.

--

--