I want to create a CloudFormation template on AWS which some optional setting. This should be controlled over a parameter.
Let’s say we have a CloudFront Distribution which get should pre validated from a Lambda. This looks like this snippet of code:
Here is missing a variable option to enable/disable the authentication lambda.
We need somthing like an if-function and this function is supported by CloudFormation. AWS give us some functions in YAML or JSON to make dynamic templates.
We want to use
Fn::If. The next part is that this function only allow two parameters to say
B. But we don’t want a
B value. To solve this we can use
So we need to extend our template like this:
- Condition Functions
- Pseudo Parameters Reference
- How to make a list item conditional in Cloud Formation template?
If you have questions or corrections contact me at email@example.com.
Author: Fabian Keunecke