Answers: <p>You are looking for <em>Dynamic Inventory</em></p>
  
  <p>Please look into <a href="https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py" rel="noreferrer"><code>ec2.py</code></a> and <a href="https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py" rel="noreferrer"><code>ec2.ini</code></a> of Ansible, and also the <a href="http://docs.ansible.com/ansible/intro_dynamic_inventory.html" rel="noreferrer"><code>Dynamic Inventory</code></a> docs of Ansible are very good for understanding how to manage your AWS inventory.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-03-02T13:28:43.307Z
Answers: thank you, so for example if I give to some instances specific tag, I could access the dynamic inventory file and take the instances under specific tag  ? is it best practice?
Answers: Berlin
Answers: CC BY-SA 3.0
Answers: 2017-03-02T15:27:33.747Z
Answers: @Berlin Yeah, why not.  The tag is called a host group :)
Answers: Dawny33
Answers: CC BY-SA 3.0
Answers: 2017-03-02T11:43:15.133Z
Answers: 2017-03-02T11:43:15.133Z
Answers: Dawny33
Body: <p>I am new to Ansible, with some experience in Chef. I am considering learn and use Ansible to manage environments.</p>
  
  <p>I was wondering, what would be the best practice to manage inventory of AWS spot instances?</p>
  
  <p>For example, when a spot instance is shut down the old IP is not relevant anymore in the inventory of hosts.</p>
  
  <p>Are there any other alternative approaches for the use case of elastic environments?</p>
  
Tags: <ansible><amazon-web-services><amazon-ec2>
Title: How do you manage your inventory of spot instances on AWS with Ansible
UserDisplayName: Berlin
ThreadText: # How do you manage your inventory of spot instances on AWS with Ansible
  
  (Asked by: username_0 on 2017-03-02)
  
  I am new to Ansible, with some experience in Chef. I am considering learn and use Ansible to manage environments.
  
  I was wondering, what would be the best practice to manage inventory of AWS spot instances?
  
  For example, when a spot instance is shut down the old IP is not relevant anymore in the inventory of hosts.
  
  Are there any other alternative approaches for the use case of elastic environments?
  
  **Tags:** ansible, amazon-web-services, amazon-ec2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-02. Score: 15 | Accepted answer
  
  You are looking for *Dynamic Inventory*
  
  Please look into [`ec2.py`](https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py) and [`ec2.ini`](https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py) of Ansible, and also the [`Dynamic Inventory`](http://docs.ansible.com/ansible/intro_dynamic_inventory.html) docs of Ansible are very good for understanding how to manage your AWS inventory.
  
  > **Comments:**
  > **username_0**: thank you, so for example if I give to some instances specific tag, I could access the dynamic inventory file and take the instances under specific tag  ? is it best practice?  
  > **username_1**: @username_0 Yeah, why not.  The tag is called a host group :)  
  
  ---
  
  