title: Unauthorized operation error occurs when using Boto3 to launch an EC2 instance with an IAM role
body: <p>I've read this question <a href="https://stackoverflow.com/questions/41518334/how-do-i-use-boto3-to-launch-an-ec2-instance-with-an-iam-role">How do I use Boto3 to launch an EC2 instance with an IAM role?</a> and try to launch an instance with IAM role in python script. Here's the code:</p>
  
  <pre><code>instance = ec2.create_instances(
      ImageId='ami-1a7f6d7e',
      KeyName='MyKeyPair',
      MinCount=1,
      MaxCount=1,
      SecurityGroups=['launch-wizard-3'],
      InstanceType='t2.micro',
      IamInstanceProfile={
          'Arn': 'arn:aws:iam::627714603946:instance-profile/SSMforCC'}
  )
  </code></pre>
  
  <p>However, I got this error after running the script <code>botocore.exceptions.ClientError: An error occurred (UnauthorizedOperation) when calling the RunInstances operation: You are not authorized to perform this operation.</code> I found this question <a href="https://stackoverflow.com/questions/13554392/how-do-i-launch-ec2-instance-with-iam-role">how do I launch ec2-instance with iam-role?</a> provides an solution for <code>Ruby</code> to solve the problem. Can anybody tell me if there's a way to solve this problem in python <code>Boto3</code>?</p>