title: How do I use Boto3 to launch an EC2 instance with an IAM role?
body: <p>I can not figure out how to launch an EC2 instance in Boto3 with a specified IAM role. </p>
  
  <p>Here is some sampe code of how I have been able to successfully create an instance so far: </p>
  
  <pre><code>import boto3
  ec2 = boto3.resource('ec2', region_name='us-west-2')
  ec2.create_instances(ImageId='ami-1e299d7e', InstanceType='t2.micro',\
  MinCount=1, MaxCount=1, SecurityGroupIds=['Mysecuritygroup'], KeyName='mykeyname')
  </code></pre>