title: CloudFormation throws "Value () for parameter groupId is invalid. The value cannot be empty" when launching EC2 instance
body: <p>I was wanting to write a complete CloudFormation template for a single Linux EC2 Instance in a public subnet.  I used <a href="https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/EC2InstanceWithSecurityGroupSample.template" rel="noreferrer">AWS CloudFormation template for creating an EC2 Instance with a Security Group</a> as my starting point.  This template launches an instance into your default VPC.</p>
  
  <p>My goal was to have a self contained template that creates everything needed in a new stack but not into the default VPC.  I wanted a new VPC, Security Group, Route Table, Internet Gateway, Subnet and launch a new Linux EC2 instance.</p>
  
  <p>So I used the above template and added the needed resources and linked them using <code>Ref</code> s.  Everything created fine: VPC, Subnet, Security Group, Internet GW, RouteTables, etc.  But My EC2 would error out and the the stack would roll back.</p>
  
  <p>The status reason was:</p>
  
  <p><code>Value () for parameter groupId is invalid. The value cannot be empty (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx)</code></p>
  
  <p>The EC2 resource in the CloudFormation template looked like:</p>
  
  <pre><code>"EC2Instance" : {
          "Type" : "AWS::EC2::Instance",
          "Properties" : {
            "InstanceType" : { "Ref" : "InstanceType" },
            "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
            "KeyName" : { "Ref" : "KeyName" },
            "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
                              { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] }
            }
        }
  </code></pre>
  
  <p>The error message was not clear on what to do.</p>