Lono Variables allow you to compile down different templates when run-time params do not suffice. This allows doing things that are outside of the ability of CloudFormation run-time parameters. Effective use of variables can dramatically reduce the amount of code you have to write.
Generally, it is recommended to use parameters when possible and drop down to variables when needed. This keeps you closer to CloudFormation’s native abilities. However, sometimes varables can dramatically clean up your code and make it more readable. It depends.
The variables are defined in the
config/blueprints/demo/vars ├── dev.rb └── prod.rb
The variables files are simply Ruby code where you set instance variables (variables with an @ sign in front). The instance variables are made available to templates, helpers, and params within the blueprint.
Here’s an example:
@ami = "ami-base"
@ami variable is now available to all of your templates.
Here’s an another example:
@ami = "ami-prod"
@ami = "ami-prod" variable will be used when
Variables also support layering. Layering support is covered in Layering Support.