Advertisement
Guest User

shit

a guest
Mar 28th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import boto3
  4. import sys
  5.  
  6. def print_ec2(region = None):
  7.     ec2 = boto3.resource('ec2')
  8.  
  9.     instances = ec2.instances.filter(Filters=[{'Name': 'availability-zone', 'Values': [region]}])
  10.  
  11.     for instance in instances:
  12.         print("Instance name:", instance.name, ", Instance primary address", instance.network_interface.adress.primary)
  13.  
  14.  
  15. if __name__ == '__main__':
  16.     region = None
  17.  
  18.     if len(sys.argv) == 2:
  19.         region = sys.argv[1]
  20.    
  21.     print_ec2(region)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement