Params Layering Support
Intro: Common Layers
Params support layering for the
configs/demo/params folder. Params files are layered if they exist. Let’s say you have the following params directory structure:
configs/demo/params ├── base.txt ├── development.txt └── production.txt
base.txtis always evaluated.
production.txtis evaluated based on LONO_ENV.
In this case, you want to define your common params used for templates in the
base.txt and overrides in
production.txt. For example, let’s say we’re setting the min and max size of an autoscaling group. We could have something like this:
Lono will use the
InstanceType=m5.large parameter value when launching the stack with
LONO_ENV=production. Lono will use
InstanceType=t3.micro for all other
LONO_ENV values. Example:
$ lono cfn deploy demo # InstanceType=t3.micro $ LONO_ENV=production lono cfn deploy demo # InstanceType=m5.large
Remember params can be used to affect templates at run-time. Here’s the lifecycle flow to see when the run-time phase happens.
Full Layering: Conventional Requested
Additionally, layering also considers params files that match the stack name. Here is a list of the full layering possibilities.
|env||configs/BLUEPRINT/params/LONO_ENV.txt||evaluated based on
|params level||configs/BLUEPRINT/params/REQUESTED.txt||common evaluated based on REQUESTED|
|env level||configs/BLUEPRINT/params/LONO_ENV/REQUESTED.txt||generally recommended|
TEMPLATE placeholders are self-explanatory.
REQUESTED requires a little more explanation.
REQUESTED is usually the requested
stack name. Here’s a concrete example with
lono cfn deploy my-stack --blueprint demo # REQUESTED=my-stack
The layers would be:
- configs/demo/params/development/my-stack.txt (recommended)
If you need to use a different param file that does not match the stack name, you can explicitly specify the param file with the
--param option. Here’s an example with the
--param option. Here
REQUESTED comes from
lono cfn deploy my-stack --blueprint demo --param my-param # REQUESTED=my-param
These params files are layered on top of the “Common”
- configs/demo/params/development/my-param.txt (recommended)
You can also specify relative and full paths for the
--param value. Example:
lono cfn deploy my-stack --blueprint demo --param configs/demo/params/my-param.txt
You can specify params files that exist outside of the lono project too.
lono cfn deploy my-stack --blueprint demo --param /tmp/my-param.txt
Relative and full paths generally remove the “Conventional” lookups for the layers. So you’ll end up with this:
Pro tip: Use the <- and -> arrow keys to move back and forward.