# Unable to auth via ec2.py

**URL:** <https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 24, 2015, 7:03pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846 "2015-11-24T19:03:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 24, 2015, 7:03pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846/1 "2015-11-24T19:03:51Z")

</div>

I thought this would be the easiest part of creating a dynamic inventory, but I’m having a hell of a time connecting:

boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. [‘HmacAuthV4Handler’] Check your credentials

In my /ansible/development/ directory, I have ec2.py and ec2.ini files:

# /ansible/development/ec2.ini

– snip –  
boto\_profile = Client

# ~/.aws/credentials

[DifferentClient]

aws\_access\_key\_id = \<DIFFERENT\_CLIENT\_ACCESS\_KEY\>  
aws\_secret\_access\_key = \<DIFFERENT\_CLIENT\_SECRET\_KEY\>  
region = us-east-1  
output = json

[Client]  
aws\_access\_key\_id = \<PROJECT\_ACCESS\_KEY\>  
aws\_secret\_access\_key = \<PROJECT\_ACCESS\_KEY\>

The keys are for my IAM user with admin privileges and work just fine when specified directly in the ec2 module.

Any idea what I’ve got misconfigured here? I’m running Ansible 1.9.4.

Thanks.

---

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 24, 2015, 7:17pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846/2 "2015-11-24T19:17:02Z")

</div>

Also, for whatever it’s worth, I’ve tried putting the keys in ~/.boto, but the result is the same.

---

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 25, 2015, 9:14pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846/3 "2015-11-25T21:14:19Z")

</div>

One more note on this that I just realized is that the profile only seems to fail for the ec2 module.

This works:

- name: Key Pair | Ensure that the appropriate keypair exists  
ec2\_key:  
profile: Socrates  
name: “soc-{{ env\_short }}”  
region: “{{ aws\_region }}”  
state: present  
register: keypair

This doesn’t

- name: Instances | Create new instances  
ec2:  
profile: Socrates  
region: “{{ aws\_region }}”  
instance\_type: “{{ ec2.instance\_type }}”  
image: “{{ ec2.ami\_id }}”  
key\_name: “soc-{{ env\_short }}”  
group: “{{ env\_short }}-{{ server\_type }}”  
exact\_count: “{{ ec2.instance\_count }}”  
count\_tag:  
Env: “{{ env }}”  
ManagedBy: Ansible  
ServerType: “{{ server\_type }}”  
wait: yes  
assign\_public\_ip: no # TODO: change to ‘yes’ to assign public ip  
instance\_tags:  
Env: “{{ env }}”  
ManagedBy: “Ansible”  
ServerType: “{{ server\_type }}”  
Projects: “{{ install\_projects | join(‘,’) }}”

# termination\_protection: yes

volumes:

- device\_name: /dev/sda1  
snapshot: snap-2337bd2a

# volume\_type: gp2

device\_type: gp2  
volume\_size: 100  
delete\_on\_termination: false  
register: ec2

The profile also works for ensuring a security group is present. Any chance it’s a bug specific to the ec2 module? Maybe my options for the module (although these options do work if I remove the profile and include the aws\_access\_key and aws\_secret\_key directly)?

---

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 25, 2015, 9:38pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846/4 "2015-11-25T21:38:36Z")

</div>

Well, crap. Looks like this could be related to #981 ([https://github.com/ansible/ansible-modules-core/issues/981](https://github.com/ansible/ansible-modules-core/issues/981)) or #1701 ([https://github.com/ansible/ansible-modules-core/issues/1701](https://github.com/ansible/ansible-modules-core/issues/1701)). Or both.

---

<div class="post-metadata">

**Author:** ![viper233](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/viper233/32/2060_2.png) [@viper233](https://forum.ansible.com/u/viper233)\
**Post date:** [November 25, 2015, 10:44pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846/5 "2015-11-25T22:44:37Z")

</div>

Ansible 1.9.4

What version of boto are you using? I’ve noticed issues when using older versions and I’m wondering if the first bug was resolved by updating to a later version (2.38) version of boto.

Assuming you are running of OS X?

$ python -c “import boto; print boto. **version** ”

Good job on the debugging so far.

---

<div class="post-metadata">

**Author:** ![Rob\_Wilkerson](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Rob\_Wilkerson](https://forum.ansible.com/u/Rob_Wilkerson)\
**Post date:** [November 25, 2015, 10:46pm UTC](https://forum.ansible.com/t/unable-to-auth-via-ec2-py/19846/6 "2015-11-25T22:46:41Z")

</div>

I’m up to date running boto 2.38.0 on OS X. My OS is Yosemite, but I’d be a little shocked if that were the issue.
