# Dynamic Inventory for Windows EC2 Instances

**URL:** <https://forum.ansible.com/t/dynamic-inventory-for-windows-ec2-instances/29232>\
**Category:** Ansible Project\
**Tags:** windows, aws\
**Created:** [December 10, 2018, 12:45pm UTC](https://forum.ansible.com/t/dynamic-inventory-for-windows-ec2-instances/29232 "2018-12-10T12:45:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawan\_Sawalani](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@Pawan\_Sawalani](https://forum.ansible.com/u/Pawan_Sawalani)\
**Post date:** [December 10, 2018, 12:45pm UTC](https://forum.ansible.com/t/dynamic-inventory-for-windows-ec2-instances/29232/1 "2018-12-10T12:45:25Z")

</div>

Hi All,

I am trying to use [EC2 external inventory](https://raw.github.com/ansible/ansible/devel/contrib/inventory/ec2.py) script (ec2.py/ec2.ini) for AWS instances.

All my AWS EC2 instances are Windows hosts.

When I run below command:

`  
ansible ec2 -i /etc/ansible/ec2.py -m win\_ping

`

I get below error:

`

172.31.86.58 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: ssh: connect to host 172.31.86.58 port 22: Connection timed out\r\n”,  
“unreachable”: true  
}

`

How do I edit ec2.ini/ec2.py, so that it tries connecting only via winrm and not using ssh?

Regards,  
Pawan Sawalani
