title: CloudFormation typed parameter that can be empty
body: <p>I am trying to create a CloudFormation template that accepts an optional SSH key pair as a parameter. I want to use the <code>AWS::EC2::KeyPair::KeyName</code> type so the CloudFormation interface gives the user a list of available keys like in the picture.</p>
  
  <p><a href="https://i.stack.imgur.com/wig3C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wig3C.png" alt="enter image description here"></a></p>
  
  <p>The problem I'm having is with the optional part. If the user leaves the selection empty, the default value is used but is not considered valid. I get:</p>
  
  <pre><code>Parameter validation failed: parameter value for parameter name SSHKey does not exist. Rollback requested by user.
  </code></pre>
  
  <p>Is there a way to define a parameter that can be left empty but has a non-generic type?</p>
  
  <p>Here's a sample template that shows the problem:</p>
  
  <pre><code>{
    "Parameters": {
      "SSHKey": {
        "Type": "AWS::EC2::KeyPair::KeyName",
        "Description": "Leave empty to disable SSH",
        "Default": ""
      }
    },
    "Conditions": {
      "EnableSSH": {
        "Fn::Not": [
          {
            "Fn::Equals": [
              "",
              {
                "Ref": "SSHKey"
              }
            ]
          }
        ]
      }
    },
    "Resources": {
      "LaunchConfig": {
        "Type": "AWS::AutoScaling::LaunchConfiguration",
        "Properties": {
          "ImageId": "ami-9eb4b1e5",
          "InstanceType": "t2.micro",
          "KeyName": {
            "Fn::If": [
              "EnableSSH",
              {
                "Ref": "SSHKey"
              },
              {
                "Ref": "AWS::NoValue"
              }
            ]
          },
          "BlockDeviceMappings": [
            {
              "DeviceName": "/dev/xvda",
              "Ebs": {
                "VolumeSize": "8"
              }
            }
          ]
        }
      }
    }
  }
  </code></pre>