title: Can i replace aws keys with IAM role in .aws/credentials for boto3 usage?
body: <p>I tried to use the role as:</p>
  
  <pre><code>~/.aws/credentials
  [default]
  role_arn=arn:aws:iam::xxxxxxx:role/yyyy
  </code></pre>
  
  <p>but i get error:</p>
  
  <pre><code>Partial credentials found in assume-role, missing: source_profile or credential_source
  </code></pre>
  
  <p>so it seems IAM role cannot replace </p>
  
  <pre><code>[default]
  aws_access_key_id = AAAAAAAAAAAAAAAAAAAAAAAA
  aws_secret_access_key =  BBBBBBBBBBBBBBBBBBBBBBBBBBB
  </code></pre>
  
  <p>since as per <a href="http://boto3.readthedocs.io/en/latest/guide/configuration.html" rel="noreferrer">http://boto3.readthedocs.io/en/latest/guide/configuration.html</a></p>
  
  <pre><code># In ~/.aws/credentials:
  [development]
  aws_access_key_id=foo
  aws_access_key_id=bar
  
  # In ~/.aws/config
  [profile crossaccount]
  role_arn=arn:aws:iam:...
  source_profile=development
  </code></pre>
  
  <p>I would still have to use keys, which could be a security risk, even though not being used in the code</p>
  
  <p>Is there a way to use boto3 with admin privileges without using aws API credentials?</p>
  
  <p>so basically:</p>
  
  <ol>
  <li>Associate "admin" role to the ec2 instance, which you are going to use to run your boto3 scripts</li>
  <li>Make sure it looks good. <code>$curl <a href="http://169.254.169.254/latest/meta-data/iam/security-credentials/" rel="noreferrer">http://169.254.169.254/latest/meta-data/iam/security-credentials/</a></li>
  <li><p>test boto3 script</p>
  
  <p>#!/usr/bin/env python 
  import boto3<br>
  ec2_client = boto3.client('ec2')<br>
  def main():
      vpcs = ec2_client.describe_vpcs()
      for vpc_info in vpcs['Vpcs']:
          print(vpc_info['VpcId'])<br>
  if <strong>name</strong> == "<strong>main</strong>":
      main()</code></p></li>
  </ol>
  
  <p>I came across an Application on github which addresses this issue:</p>
  
  <p><a href="https://github.com/AdRoll/hologram" rel="noreferrer">https://github.com/AdRoll/hologram</a></p>