# ElastiCache error in Ec2.py while running playbooks

**URL:** <https://forum.ansible.com/t/elasticache-error-in-ec2-py-while-running-playbooks/23240>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 12, 2016, 6:13pm UTC](https://forum.ansible.com/t/elasticache-error-in-ec2-py-while-running-playbooks/23240 "2016-12-12T18:13:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhilash\_Panickar](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Abhilash\_Panickar](https://forum.ansible.com/u/Abhilash_Panickar)\
**Post date:** [December 12, 2016, 6:13pm UTC](https://forum.ansible.com/t/elasticache-error-in-ec2-py-while-running-playbooks/23240/1 "2016-12-12T18:13:04Z")

</div>

Hi,

For the past few days I am getting the following error when running ansible playbooks using the AWS cloud modules or when directly running the ec2.py file with the --refresh-cache command from my local machine:

ap:~ ap$ /ansible/inventory/ec2.py --refresh-cache  
Traceback (most recent call last):  
File “/ansible/inventory/ec2.py”, line 1510, in   
Ec2Inventory()  
File “/ansible/inventory/ec2.py”, line 186, in **init**  
self.do\_api\_calls\_update\_cache()  
File “/ansible/inventory/ec2.py”, line 492, in do\_api\_calls\_update\_cache  
self.get\_elasticache\_replication\_groups\_by\_region(region)  
File “/ansible/inventory/ec2.py”, line 722, in get\_elasticache\_replication\_groups\_by\_region  
self.add\_elasticache\_replication\_group(replication\_group, region)  
File “/ansible/inventory/ec2.py”, line 1198, in add\_elasticache\_replication\_group  
dest = replication\_group[‘NodeGroups’][0][‘PrimaryEndpoint’][‘Address’]  
TypeError: ‘NoneType’ object has no attribute ‘ **getitem** ’

This issue seems to be go away when running from an Ec2 instance in the AWS account.

I have the latest EC2.py and EC2.ini files, ansible version is 2.2.0.0 and boto3 is installed and I do set the valid AWS credentials before running the playbook,

Any ideas on what’s going on?

---

<div class="post-metadata">

**Author:** ![Abhilash\_Panickar](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Abhilash\_Panickar](https://forum.ansible.com/u/Abhilash_Panickar)\
**Post date:** [April 6, 2017, 2:08pm UTC](https://forum.ansible.com/t/elasticache-error-in-ec2-py-while-running-playbooks/23240/2 "2017-04-06T14:08:06Z")

</div>

Just to close the thread, i got a response to this question on StackOverflow:

[http://stackoverflow.com/questions/41107045/error-refreshing-elasticache-in-ec2-py-when-running-ansible-playbooks](http://stackoverflow.com/questions/41107045/error-refreshing-elasticache-in-ec2-py-when-running-ansible-playbooks)
