Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import boto3
- import sys
- def print_ec2(az = None):
- ec2 = boto3.resource('ec2')
- instances = ec2.instances.filter(Filters=[{'Name': 'availability-zone', 'Values': [az]}])
- for instance in instances:
- print("Instance name:", instance.name, ", Instance primary address", instance.network_interface.adress.primary)
- if __name__ == '__main__':
- if len(sys.argv) != 2:
- print("You need to specify an availability zone...")
- exit(1)
- az = sys.argv[1]
- print_ec2(az)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement