title: CloudFormation Template doesnt pick KeyPair
body: <p>I have created below four resources successfully using the <code>Cloud Formation Template (CFT)</code>:</p>
  <ol>
  <li>VPC</li>
  <li>Subnet</li>
  <li>InternetGateway</li>
  <li>AttachGateway</li>
  </ol>
  <p>Now, I am trying to create a security group with EC2 instance, here is the code.</p>
  <pre><code>  Type: AWS::EC2::SecurityGroup
    Properties:
        GroupDescription: Allow http and ssh to client host
        VpcId:
           Ref: InsuranceVPC
        SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: 0.0.0.0/0
        - IpProtocol: tcp
          FromPort: 22
          ToPort: 22
          CidrIp: 0.0.0.0/0
        SecurityGroupEgress:
        - IpProtocol: tcp
          FromPort: 80
          ToPort: 80
          CidrIp: 0.0.0.0/0
  
  Ec2Instance: 
    Type: AWS::EC2::Instance
    Properties: 
      ImageId: &quot;ami-08706cb5f68222d09&quot;
      KeyName: 
        Ref: &quot;DevOpsAutomation&quot;
      NetworkInterfaces: 
        - AssociatePublicIpAddress: &quot;true&quot;
          DeviceIndex: &quot;0&quot;
          GroupSet: 
            - Ref: &quot;InsuranceSecurityGroup&quot;
          SubnetId: 
            Ref: &quot;InsuranceSubnet&quot;
  </code></pre>
  <p>But, when I use the Key parameter in (CFT, as shown above, code) which is my key present in the same region of the resources, my CFT stack fails with below error:</p>
  <p><code>Template format error: Unresolved resource dependencies [DevOpsAutomation] in the Resources block of the template</code>
  <code>note: DevOpsAutomation is my keyname</code></p>
  <p>Steps I validated:</p>
  <ol>
  <li>CFT template resources and the key is in the same region</li>
  <li>deleted and freshly created key pair</li>
  <li>tried to use different key pair</li>
  <li>I couldn't see an option anywhere to import the key along with the CFT stack so that my EC2 instance can use it.</li>
  <li><strong>Even while creating the stack the key DOESN'T appear</strong> (which is visible in <code>keypair</code> section) in the <code>parameter</code> section of the stack.</li>
  </ol>
  <p>My query is, how should I create EC2 instance (as a part of CFT) using the key pair which is present in my AWS account?</p>