I have a parameter defined in my sceptre config file that I would like to reference in a Jinja2 conditional block.
template:
path: 'codepipeline.yaml.j2'
parameters:
Mode: 'OnDemand'
Parameters:
Mode:
Type: 'String'
Default: 'OnDemand'
AllowedValues: ['OnDemand', 'OnPush']
# What I want to do
{% if $Mode == 'OnDemand' %}
Triggers:
more_stuff:
{% else %}
Triggers:
other_stuff:
{% endif %}
What is the proper way to reference the parameter value?
I spent hours hunting for a solution to this problem.
This issue contained the solution. The list of parameters can be made available as a dictionary block within sceptre_user_data.
sceptre_user_data:
stack_parameters: !stack_attr parameters
{% if sceptre_user_data.stack_parameters.Mode == 'OnDemand' %}
Triggers:
more_stuff:
{% else %}
Triggers:
other_stuff:
{% endif %}
One caveat... sceptre_user_data.stack_parameters.Mode
will only contain the Parameter values defined in config files. The default value defined in the template will not populate into the dictionary in the Parameter is not provided in the configuration file.