How do you manage your inventory of spot instances on AWS with Ansible
You are looking for Dynamic Inventory

Please look into ec2.py and ec2.ini of Ansible, and also the Dynamic Inventory docs of Ansible are very good for understanding how to manage your AWS inventory.