Answers: <p>You can benefit from EC2 inventory script provided by Ansible - <a href="https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py" rel="nofollow noreferrer">click</a>
  It will allow you to to connect to all ec2-instances, one by one (in <code>serial: 1</code> mode)</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-06-12T12:30:27.300Z
Answers: 2018-06-12T12:30:27.300Z
Answers: 13dimitar
Body: <p>Is there any way through which I can connect to all ec2-instances one by one through Python script to extract some server information from there. Please note that all ec2-instances lies behind a bastion host. Using shell script I can do that but how about python. Is there any specific library?</p>
  
Comments: CC BY-SA 4.0
Comments: 2018-06-02T23:20:34.993Z
Comments: More information might be helpful, like whats the end result? You want to run commands on these servers? Why not use ansible?
Comments: Levi
Comments: CC BY-SA 4.0
Comments: 2018-06-04T18:57:51.557Z
Comments: @Levi I need to extract some information from database.yml files residing in each ec2 instances
Comments: Prashast
Tags: <amazon-web-services><amazon-ec2><python>
Title: Way to Connect to all ec2-instances one by one
UserDisplayName: Prashast
ThreadText: # Way to Connect to all ec2-instances one by one
  
  (Asked by: username_0 on 2018-06-01)
  
  Is there any way through which I can connect to all ec2-instances one by one through Python script to extract some server information from there. Please note that all ec2-instances lies behind a bastion host. Using shell script I can do that but how about python. Is there any specific library?
  
  **Tags:** amazon-web-services, amazon-ec2, python
  
  > **Comments:**
  > **username_1**: More information might be helpful, like whats the end result? You want to run commands on these servers? Why not use ansible?  
  > **username_0**: @username_1 I need to extract some information from database.yml files residing in each ec2 instances  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-06-12. Score: 0 | Accepted answer
  
  You can benefit from EC2 inventory script provided by Ansible - [click](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py)
  It will allow you to to connect to all ec2-instances, one by one (in `serial: 1` mode)
  
  
  ---
  
  