Reputation: 947
I am trying to get the public ip address of all the running instances. I am using boto3 and python version 2.7.6.
>>> instances = ec2.instances.filter(
... Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
>>> for instance in instances:
... print(instance.public_ip_address,instance.platform,instance.public_dns_name);
It lists all the instances along with instances not having public ip address assigned to it.
(None, None, '')
Is there any way to filter out those instances which do not have a public ip while populating instances using ec2.instances.filter?
Upvotes: 3
Views: 4120