
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
An Elastic IP address is a static public IP address that is typically associated with one of your EC2 instances as a way to have a static public IP address that can be used to route traffic into your Amazon Web Services cluster. Typically, you will create a DNS A record to bind a hostname such as www.example.com to the elastic IP address. The DNS can be done using Amazon Web Services Route 53.
The aws ec2 describe-addresses command can be used to list the Elastic IP addresses you have associated to your EC2 instances. In this example, the Elastic IP address is 154.19.50.198.
~]$ aws ec2 describe-addresses
{
"Addresses": [
{
"InstanceId": "i-09e2e375cf14807b2",
"PublicIp": "154.19.50.198",
"AllocationId": "eipalloc-0a5c72c343bc546b0",
"AssociationId": "eipassoc-0b12eaaacc74f9e24",
"Domain": "vpc",
"NetworkInterfaceId": "eni-004a4335b85583ae2",
"NetworkInterfaceOwnerId": "123456789012",
"PrivateIpAddress": "172.31.19.227",
"Tags": [
{
"Key": "Name",
"Value": "haproxy-ip"
}
],
"PublicIpv4Pool": "amazon",
"NetworkBorderGroup": "us-east-1"
}
]
}
And here is an example of how to limit the output using the --query option.
aws ec2 describe-addresses --query 'Addresses[?PublicIp==`154.19.50.198`]'
And here is an example of how to limit the output using the --filters option. This will only work if the Elastic IP has Tags.
aws ec2 describe-addresses --filters "Name=tag-value,Values=haproxy-ip"
The aws route53 list-resource-record-sets command can be used to determine if there are any A records pointing to the Elastic IP address.
~]$ aws route53 list-resource-record-sets --hosted-zone-id Z056866DJM1OE9C45GH42
{
"ResourceRecordSets": [
{
"Name": "example.com.",
"Type": "NS",
"TTL": 172800,
"ResourceRecords": [
{
"Value": "ns-550.awsdns-04.net."
},
{
"Value": "ns-499.awsdns-62.com."
},
{
"Value": "ns-1687.awsdns-18.co.uk."
},
{
"Value": "ns-1193.awsdns-21.org."
}
]
},
{
"Name": "example.com.",
"Type": "SOA",
"TTL": 900,
"ResourceRecords": [
{
"Value": "ns-550.awsdns-04.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"
}
]
},
{
"Name": "foo.example.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "154.19.50.198"
}
]
}
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at