Ansible not reading credentials from ~/.aws/credentials
<p>I am running ansible with <code>dynamic inventory</code>. When the <code>aws cli</code> was setup with aws configure command than the ansible commands with dynamic invetory was running properly. But I want to have multiple profiles to be used by dynamic inventory so I have added profile in <code>~/.aws/credentials</code></p>

<pre><code>[personal]
aws_access_key_id = XXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXX

[default]
aws_access_key_id = XXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXX
</code></pre>

<p>ansible not picking up these credentials and on running <code>./ec2.py --list</code> it is giving the error:</p>

<pre><code>Looks like AWS is down again:
EC2ResponseError: 401 Unauthorized
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;Response&gt;&lt;Errors&gt;&lt;Error&gt;&lt;Code&gt;AuthFailure&lt;/Code&gt;&lt;Message&gt;Authorization header or parameters are not formatted correctly.&lt;/Message&gt;&lt;/Error&gt;&lt;/Errors&gt;&lt;RequestID&gt;349d5311-54db-4e79-9bbc-2d60b9f15da5&lt;/RequestID&gt;&lt;/Response&gt;
</code></pre>

<p>Have you tried adding --profile PROFILE switch to ec2.py as below.</p>

<pre><code>./ec2.py --list --profile personal
</code></pre>

python amazon-web-services ansible aws-cli