In our previous recipes and the previous chapter, we have seen how easily we can create AWS resources. When running production loads on AWS Cloud, we tend to scale out and scale in the resources according to traffic and workloads. But with this dynamic nature of the cloud to scale in and out, managing a static inventory file for Ansible is an operational task and overhead, and it becomes really difficult if we want to implement features such as autoscaling.
With the help of dynamic inventory, we can solve this. Ansible provides an EC2 dynamic inventory script called ec2.py (https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py).