# using ec2.py in AWS dynamic envionment

**URL:** <https://forum.ansible.com/t/using-ec2-py-in-aws-dynamic-envionment/29077>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 20, 2018, 2:04pm UTC](https://forum.ansible.com/t/using-ec2-py-in-aws-dynamic-envionment/29077 "2018-11-20T14:04:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey\_Arlashin](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Sergey\_Arlashin](https://forum.ansible.com/u/Sergey_Arlashin)\
**Post date:** [November 20, 2018, 2:04pm UTC](https://forum.ansible.com/t/using-ec2-py-in-aws-dynamic-envionment/29077/1 "2018-11-20T14:04:09Z")

</div>

Hi!

We have an EC2 autoscaling group in AWS environment. We'd like to execute shell scripts on EC2 instances launched within this ASG with Ansible.

For that I'm using ec2.py script.

Each instance in this ASG has tag "Inventory\_Group = testenv-autoscale".

when I launch ./ec2.py script, I get the following output for this tag

&nbsp;&nbsp;"tag\_Inventory\_Group\_ testenv\_autoscale": [  
&nbsp;&nbsp;&nbsp;&nbsp;"testenv\_autoscale",  
&nbsp;&nbsp;&nbsp;&nbsp;"testenv\_autoscale",  
&nbsp;&nbsp;&nbsp;&nbsp;"testenv\_autoscale",  
&nbsp;&nbsp;&nbsp;&nbsp;"testenv\_autoscale"  
&nbsp;&nbsp;],

However there is only one record for testenv\_autoscale host

"testenv\_autoscale": {  
&nbsp;&nbsp;"ansible\_host": "10.1.1.10",  
&nbsp;&nbsp;...  
&nbsp;&nbsp;...  
}

And when I execute ansible filtering by "tag\_Inventory\_Group\_ testenv\_autoscale" I get connected only to 1 host in the group.

All testenv\_autoscale instances are properly tagged.

So my question is - what can be wrong with either ec2.py script or my set up?

Thanks!

Regards,  
Sergey
