<p dir="auto"><b>Issue Type:</b>  Feature Idea<br>
<b>Component Name:</b> module_utils/ec2.py<br>
<b>Ansible Version:</b> devel<br>
<b>Summary:</b><br>
I know there is this module:</p>
<p dir="auto"><a href="http://docs.ansible.com/ansible/sts_assume_role_module.html" rel="nofollow">http://docs.ansible.com/ansible/sts_assume_role_module.html</a></p>
<p dir="auto">But having this in the ec2.py module utility seems like a much better way to go as it is a lot of boiler plate to have to add sts_assume_role to every playbook that assumes roles. We only assume roles at our company to do anything with AWS so it is painful for us. It would be pretty trivial for me to add this to ec2.py.</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">ec2 dynamic inventory script</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">ansible 2.0.1.0</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">On Ubuntu Linux, and Amazon Linux on AWS</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">I cannot assume a role on the command line by exporting the new temporary credentials as environment variables and run the inventory script.</p>
<p dir="auto">I have my 'master' AWS account's credentials in ~/.aws/credentials, then I assume a role on another account, and export the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SECRET_TOKEN and AWS_SESSION_TOKEN values it gives me. When I run the inventory script (which I have updated from latest devel, as of now) I get:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR: &quot;Authentication error retrieving ec2 inventory.
 - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment vars found but may not be correct
 - Boto configs found at '~/.aws/credentials', but the credentials contained may not be correct&quot;, while: getting EC2 instances"><pre class="notranslate"><code class="notranslate">ERROR: "Authentication error retrieving ec2 inventory.
 - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment vars found but may not be correct
 - Boto configs found at '~/.aws/credentials', but the credentials contained may not be correct", while: getting EC2 instances
</code></pre></div>
<p dir="auto">I am using the latest inv/ec2.py as of now.</p>
<p dir="auto">Thanks</p>