Reputation: 537
How to check if the public IP address attached to an instance is Elastic or not, using boto3 ?
Is there a method that i can call and get this information ?
Upvotes: 1
Views: 1049
Reputation: 269370
It appears that Network Interface association has an owner field:
"NetworkInterfaces": [
{
"Status": "in-use",
"MacAddress": "06:68:22:33:44:c1",
"SourceDestCheck": true,
"VpcId": "vpc-1234",
"Description": "",
"Association": {
"PublicIp": "13.54.133.222",
"PublicDnsName": "ec2-13-54-133-222.ap-southeast-2.compute.amazonaws.com",
"IpOwnerId": "amazon"
},
The IpOwnerId
is either the AWS Account number (for an Elastic IP address) or amazon
(for a temporary public IP address).
You can retrieve it with:
aws ec2 describe-instances --query 'Reservations[*].Instances[*].NetworkInterfaces[*].Association.[PublicIp,IpOwnerId]'
You could similarly access this information via boto3
.
Upvotes: 2