Helpers
You can extend Lono’s DSL with helpers. This is a powerful way to keep your code organized and readable.
Example Helper
You define helpers in the blueprint’s app/helpers
folder as a module. The module name should be the camelized version of the file name. Here’s an example:
app/helpers/ec2_helper.rb:
module Ec2Helper
def ec2_instance(logical_id, props={})
default = {
InstanceType: "t3.micro",
ImageId: ref("AmiId"),
}
props.reverse_merge!(default)
resource("Instance", "AWS::EC2::Instance", props)
end
def security_group(logical_id, props={})
resource("SecurityGroup", "AWS::EC2::SecurityGroup", props)
end
end
You can use the helper in your templates:
app/templates/demo.rb:
ec2_instance("Instance",
SecurityGroupIds: [get_att("SecurityGroup.GroupId")]
)
security_group("SecurityGroup",
GroupDescription: "demo security group",
)
These are helpers you can define. Lono also comes with some builtin Lono helpers
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!
- Suggest an edit to this page (here's the contributing guide).
- Open an issue about this page to report a problem.