# Bug: in ec2\_elb - exception being thrown for new instance registration with ELB

**URL:** <https://forum.ansible.com/t/bug-in-ec2-elb-exception-being-thrown-for-new-instance-registration-with-elb/14271>\
**Category:** Ansible Developer\
**Tags:** ubuntu\
**Created:** [January 5, 2014, 10:45am UTC](https://forum.ansible.com/t/bug-in-ec2-elb-exception-being-thrown-for-new-instance-registration-with-elb/14271 "2014-01-05T10:45:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohan\_Krishnan](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@Mohan\_Krishnan](https://forum.ansible.com/u/Mohan_Krishnan)\
**Post date:** [January 5, 2014, 10:45am UTC](https://forum.ansible.com/t/bug-in-ec2-elb-exception-being-thrown-for-new-instance-registration-with-elb/14271/1 "2014-01-05T10:45:20Z")

</div>

Hello,

Currently if we are trying to register an instance that has not yetbeen registered with the elb an exception is thrown as follows:

Traceback (most recent call last):  
File “/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2\_elb”, line 1412, in  
main()  
File “/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2\_elb”, line 335, in main  
elb\_man.register(wait, enable\_availability\_zone)  
File “/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2\_elb”, line 168, in register  
self._await_elb\_instance\_state(lb, ‘InService’, initial\_state)  
File “/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2\_elb”, line 213, in_await_elb\_instance\_state  
if instance\_state.state != initial\_state.state:  
AttributeError: ‘NoneType’ object has no attribute ‘state’

This is expected because the code is querying the elb for the state of the new instance and it responds with a “InvalidInstance” response (as its not been registered with the ELB yet) and the code sets the value of the initial\_state to None.

This code change checks if the initial\_state is None. If it is, its safe to assume that its state has changed - [https://github.com/ansible/ansible/pull/5506](https://github.com/ansible/ansible/pull/5506)

I hope this is a small enough to be merged 🙂

Mphan

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 5, 2014, 6:36pm UTC](https://forum.ansible.com/t/bug-in-ec2-elb-exception-being-thrown-for-new-instance-registration-with-elb/14271/2 "2014-01-05T18:36:41Z")

</div>

Bugs should be reported on GitHub.

Please read instructions here and don’t spam the list.

[https://github.com/ansible/ansible/blob/devel/CONTRIBUTING.md](https://github.com/ansible/ansible/blob/devel/CONTRIBUTING.md)
