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?
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)