Lono provides the ability write your CloudFormation template with a DSL. The DSL is actually just Ruby code. This means we get the full power of a programming language. We can use loops, define methods, modules, etc.

While at the same time, the Lono DSL stays close to the declarative nature of CloudFormation. We get the best of both worlds.

Here’s an example of what the DSL looks like.


description "Demo stack"

parameter("InstanceType", "t3.micro")

  "us-east-1": { Ami: "ami-0de53d8956e8dcf80" },
  "us-west-2": { Ami: "ami-061392db613a6357b" }

resource("Instance", "AWS::EC2::Instance",
  InstanceType: ref("InstanceType"),
  ImageId: find_in_map("AmiMap", ref("AWS::Region"), "Ami"),
  SecurityGroupIds: [get_att("SecurityGroup.GroupId")],
  UserData: base64(user_data("bootstrap.sh"))
resource("SecurityGroup", "AWS::EC2::SecurityGroup",
  GroupDescription: "demo security group",

output("SecurityGroup", get_att("SecurityGroup.GroupId"))

Here are the top-level DSL methods.

Method Description
Format Version The optional AWSTemplateFormatVersion section identifies the capabilities of the template.
Condition The optional Conditions section contains statements that define the circumstances under which entities are created or configured.
Description The optional Description section enables you to include comments about your template. The Description must follow the AWSTemplateFormatVersion section.
Mapping The optional Mappings section matches a key to a corresponding set of named values.
Metadata The optional Mappings section matches a key to a corresponding set of named values.
Output The optional Outputs section declares output values shown in the CloudFormation outputs console.
Parameter Use the optional Parameters section to customize your templates. Parameters enable you to input custom values to your template each time you create or update a stack.
Resource The required Resources section declares the AWS resources that you want to include in the stack, such as an Amazon EC2 instance or an Amazon S3 bucket.
Section General way to add a section to the generated CloudFormation template.
Transform The optional Transform section specifies one or more macros that AWS CloudFormation uses to process your template.

The main methods correspond to sections of the CloudFormation anatomy sections.

The DSL provides full access to creating custom CloudFormation stacks and AWS resources. It is also easy wrap the DSL with your own Helpers. This helps you keep your code concise and more readable.

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!