Sometimes you want a CloudFormation Parameter to be optional. Unfortunately a blank Parameter contains an empty string. If you pass this empty string to e.g. the KeyName
Property of an EC2 Instance or Launch Configuration you end up with a validation error.
Imagine the following CloudFormation template:
{ |
If you leave the KeyName
blank you will get the following error:
Parameter validation failed: parameter value for parameter name KeyName
does not exist. Rollback requested by user.
The solution is the make use of CloudFormation Conditions
, the Condition Function Fn::If
and the Pseudo Parameter AWS::NoValue
.
{ |
Now you can leave the KeyName
parameter blank to not add a EC2 KeyPair to the LaunchConfiguration
.
- Master Microsoft MD-102 Certification: Your 2025 Guide to Supercharging IT Support Skills
- Worldwide availability of EC2 instance types
- Mastering Java Development with 2V0-72.22 Certification: Your 2025 Blueprint to Career Growth and Success
- How to filter S3 events by object size
- AWS Velocity Series: Containerized ECS based app infrastructure