Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Boto EC2 find instance given its IP address

Using boto in Python, how can I find the boto.ec2 instance object given an IP address?

like image 985
alonsovb Avatar asked Dec 24 '22 19:12

alonsovb


1 Answers

boto3

ec2 = boto3.client('ec2')

filters = [{
    'Name': 'ip-address', 
    'Values': ['1.1.1.1'],
}]
result_list = ec2.describe_instances(Filters=filters)
like image 192
ThorSummoner Avatar answered Jan 09 '23 22:01

ThorSummoner