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?

  • More information might be helpful, like whats the end result? You want to run commands on these servers? Why not use ansible?
    – Levi
    Jun 2, 2018 at 23:20
  • @Levi I need to extract some information from database.yml files residing in each ec2 instances
    – Prashast
    Jun 4, 2018 at 18:57

1 Answer 1


You can benefit from EC2 inventory script provided by Ansible - click It will allow you to to connect to all ec2-instances, one by one (in serial: 1 mode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.