In this post, we’ll cover Lono Layering. Layering can be used to build separate environments like a development and production environment. For example, the production environment might have different instance sizes. This can be accomplished with Lono layering.


We covered Params configs in the previous article. Here it is again for review.

├── base.txt
├── development.txt
└── production.txt

Notice the base.txt file. Lono layering will use the base.txt and then “layers” the LONO_ENV specific file on top.


LONO_ENV=development lono cfn deploy demo

Will use both:



LONO_ENV=production lono cfn deploy demo

Will use:


Examples with Values




# empty file



In this case:

  • LONO_ENV=development would use InstanceType=t3.micro from base.txt
  • LONO_ENV=production would use InstanceType=t3.large from production.txt


Here’s the variables structure:

├── base.rb
├── development.rb
└── production.rb

Variables layering works the same as Params layering. Example:


@desc = "generic description from base.rb"


@desc = "description from development.rb"

In this case:

LONO_ENV=development lono cfn deploy demo

Will use the @desc value from development.rb.

If the production.rb does not exist or is empty, then:

LONO_ENV=production lono cfn deploy demo

Will use the @desc value from base.rb.


We’ll continue to use the EC2 instance example from previous posts to demonstrate Layering.

Add to and edit the configs files with the values above. The source code is also here: tongueroo/lono-cloudformation-examples tutorial-4 configs

Confirm that the @desc variable is being used in the template. It’ll look like this:


description @desc

Then deploy both environments with different stack names using these commands:

LONO_ENV=development lono cfn deploy demo-development --blueprint demo
LONO_ENV=production  lono cfn deploy demo-production  --blueprint demo

Let’s check the CloudFormation console for demo-development:

The demo-development template:

Now check that the demo-production stack values are different:

The demo-production template:


Let’s destroy the resources so we do not get charged more money than we have to. This is simple.

LONO_ENV=development lono cfn delete demo-development --sure --no-wait
LONO_ENV=production  lono cfn delete demo-production  --sure --no-wait


This was a brief introduction to Layering support in Lono. Layering essentially merges multiple files to produce a final result. Layering is useful for building multiple environments like development and production. By using Layering, we stay DRY and use the same blueprints for different environments. In the next post of this series, we’ll cover one of my favorite commands: lono code convert.

Prebuilt CloudFormation Templates

You may be interested in BoltOps Pro blueprints. Blueprints are essentially CloudFormation templates packaged up in a convenient and reusable way. The BoltOps Pro subscription gives you access to all the blueprints in the BoltOps Pro GitHub organization. Just configure, deploy, and run.

Also, if there is a blueprint you would like to see in the future. Please feel free to send us your suggestions: Pro Blueprint Suggestion.

Posts in This Series