# Creating Dynamic Inventory with CloudFormation Outputs

**URL:** <https://forum.ansible.com/t/creating-dynamic-inventory-with-cloudformation-outputs/21799>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [June 17, 2016, 11:40am UTC](https://forum.ansible.com/t/creating-dynamic-inventory-with-cloudformation-outputs/21799 "2016-06-17T11:40:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![divya\_mangotra](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@divya\_mangotra](https://forum.ansible.com/u/divya_mangotra)\
**Post date:** [June 17, 2016, 11:40am UTC](https://forum.ansible.com/t/creating-dynamic-inventory-with-cloudformation-outputs/21799/1 "2016-06-17T11:40:40Z")

</div>

I am using AWS CloudFormation to create infrastructure and the template creates EC2 instances, Elasticache cluster and RDS instance. Now, I am wondering as to how to use the CloudFormation outputs to create Ansible Dynamic Inventory? In the static inventory files I also have **groups of groups**. How do I tweak my _ec2.ini_ and _ec2.py_ to accomodate the same?

---

<div class="post-metadata">

**Author:** ![Le\_Van1](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@Le\_Van1](https://forum.ansible.com/u/Le_Van1)\
**Post date:** [June 28, 2016, 10:03am UTC](https://forum.ansible.com/t/creating-dynamic-inventory-with-cloudformation-outputs/21799/2 "2016-06-28T10:03:37Z")

</div>

I have the same question. Why there isn’t any answer here?

---

<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:** [June 28, 2016, 6:04pm UTC](https://forum.ansible.com/t/creating-dynamic-inventory-with-cloudformation-outputs/21799/3 "2016-06-28T18:04:50Z")

</div>

Just a quick response, some what self promoting but hopefully helpful.

[https://github.com/ansible/ansible-modules-extras/pull/2329](https://github.com/ansible/ansible-modules-extras/pull/2329)

cloudformation\_facts module

I’d previously put together a lookup plugin (mainly through combining others efforts)  
[https://github.com/ansible/ansible/pull/12880](https://github.com/ansible/ansible/pull/12880)

I’m going to make the time to rewrite this using boto3 and try and get it completed before the end of July.

This will give you the resources that were created by the cloudformation stacks. It’s also possible to use the ec2\_facts, [http://docs.ansible.com/ansible/ec2\_facts\_module.html](http://docs.ansible.com/ansible/ec2_facts_module.html) and ec2\_remote\_facts [http://docs.ansible.com/ansible/ec2\_remote\_facts\_module.html](http://docs.ansible.com/ansible/ec2_remote_facts_module.html) to get a list of the ec2 instances and then iterate them through through the add\_host [http://docs.ansible.com/ansible/add\_host\_module.html](http://docs.ansible.com/ansible/add_host_module.html) to add them to an in-memory inventory.

Similar to the example here, [http://docs.ansible.com/ansible/ec2\_module.html#examples](http://docs.ansible.com/ansible/ec2_module.html#examples)
