# Ansible and EC2 Auto-Scaling

**URL:** <https://forum.ansible.com/t/ansible-and-ec2-auto-scaling/22745>\
**Category:** Ansible Project\
**Created:** [October 7, 2016, 7:38pm UTC](https://forum.ansible.com/t/ansible-and-ec2-auto-scaling/22745 "2016-10-07T19:38:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [October 7, 2016, 7:38pm UTC](https://forum.ansible.com/t/ansible-and-ec2-auto-scaling/22745/1 "2016-10-07T19:38:24Z")

</div>

We are slowly starting our migration away from Puppet towards Ansible and have a use case I’d like the community’s feedback on. Some notes to frame the question:

1. Puppet isn’t going away immediately. We still have legacy code/infrastructure (who doesn’t).
2. Ansible can’t break Puppet and vice versa.
3. DNS records have to be created for new hosts (puppet, ya know).

And now the question(s):

1. How can I make Ansible aware EC2 auto-scaling has created new systems?
2. How can I get Ansible to assign consistent host names and DNS records (Route 53) automatically?

---

<div class="post-metadata">

**Author:** ![Brian\_Jackson](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@Brian\_Jackson](https://forum.ansible.com/u/Brian_Jackson)\
**Post date:** [October 12, 2016, 6:29pm UTC](https://forum.ansible.com/t/ansible-and-ec2-auto-scaling/22745/2 "2016-10-12T18:29:09Z")

</div>

Chris I haven’t gotten this far yet so YMMV…see inline

> …
> 
> And now the question(s):
> 
> 1. How can I make Ansible aware EC2 auto-scaling has created new systems?

I think you are looking for the concept of the Dynamic Inventory  
[http://docs.ansible.com/ansible/intro\_dynamic\_inventory.html#example-aws-ec2-external-inventory-script](http://docs.ansible.com/ansible/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script)

> 1. How can I get Ansible to assign consistent host names and DNS records (Route 53) automatically?

For this I think you’d want to do something like this:  
[https://aws.amazon.com/blogs/compute/building-a-dynamic-dns-for-route-53-using-cloudwatch-events-and-lambda/](https://aws.amazon.com/blogs/compute/building-a-dynamic-dns-for-route-53-using-cloudwatch-events-and-lambda/)

An similar example of how to setup CloudWatch Events and Lambda Functions with Ansible:  
[https://gist.github.com/danvaida/e369838ceaa65a7a6f57de7d08af805f](https://gist.github.com/danvaida/e369838ceaa65a7a6f57de7d08af805f)  
Note this requires features merged but not available yet until 2.2 gets released.
