Shared Variables are configs that you define to affect how the templates are generated at compile-time. Shared variables are available to all templates, helpers, and parameters.
The variables are defined in the
configs/ ├── ecs-spot │ └── variables │ ├── development.rb │ └── production.rb └── vpc └── variables ├── development.rb └── production.rb
The variables files are merely Ruby scripts where instance variables (variables with an @ sign in front) are made available.
Here’s an example:
@ami = "ami-base"
@ami variable is now available to all of your templates.
Here’s an another example:
@ami = "ami-production"
@ami = "ami-production" variable will be used when
Variables allow you to affect the way your templates are built at compile time. This allows doing things that are outside of the ability of run-time parameters. Effective use of shared variables can dramatically shorten down your templates.
Variables also support layering. Layering support is covered in Layering Support.
Pro tip: Use the <- and -> arrow keys to move back and forward.