title: Cloudformation LaunchTemplate referencing IamInstanceProfile fails to create
body: <p>I am trying to create a <em>LaunchTemplate</em>, which references an <em>IamInstanceProfile</em>, in my Cloudformation stack. Here is the code- i have omitted the irrelevant parts:</p>
  
  <pre><code>...
              Resources:
                ServerLaunchTemplate:
                  Type: 'AWS::EC2::LaunchTemplate'
                  Properties:
                    LaunchTemplateData:
                      InstanceType: !Ref InstanceType
                      SecurityGroups:
                        - !Ref SecGroup
                      IamInstanceProfile: !Ref ServerProfile
                      UserData:
          ...
                ServerProfile:
                  Type: 'AWS::IAM::InstanceProfile'
                  Properties:
                    Path: /
                    Roles:
                      - !Ref ServerRole
  ...
  </code></pre>
  
  <p>The <em>ServerProfile</em> gets created successfully. However when the stack creation process reaches the step of creating the <em>ServerLaunchTemplate</em>, it fails with the error:</p>
  
  <pre><code>Property validation failure: [Value of property {/LaunchTemplateData/IamInstanceProfile} does not match type {Object}]
  </code></pre>
  
  <p>If i omit the reference to the <em>IamInstanceProfile</em>, the <em>LaunchTemplate</em> get created successfully.</p>
  
  <p>According to the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata.html#cfn-ec2-launchtemplate-launchtemplatedata-iaminstanceprofile" rel="noreferrer">documentation</a> and some examples this should work... Based on the error i understand, that the <em>InstanceType</em> field of the <em>LaunchTemplate</em> needs to reference an object, but "<em>!Ref InstanceType</em>" returns the resource id. </p>
  
  <p>How can i fix this? How could i retrieve the object, that is presumably required by the "<em>/LaunchTemplateData/IamInstanceProfile</em>" field?</p>
  
  <p>Thank you </p>