3

I need to find all unallocated elasstic Ips using AWS CLI.

I am trying aws ec2 describe-addresses --region eu-west-1

can see entries as follows

{
            "PublicIp": "52.50.106.17",
            "Domain": "vpc",
            "AllocationId": "eipalloc-205cc745"
        },
        {
            "Domain": "vpc",
            "InstanceId": "i-fff12747",
            "NetworkInterfaceId": "eni-279dfe7c",
            "AssociationId": "eipassoc-c92f5ead",
            "NetworkInterfaceOwnerId": "463466179279",
            "PublicIp": "52.30.89.148",
            "AllocationId": "eipalloc-3367c656",
            "PrivateIpAddress": "172.29.72.93"
        },

How can I find only Ips which are not allocated to any of the instances.

I am trying

aws ec2 describe-addresses --region eu-west-1 --filter Name=instance-id,Value="null"

Parameter validation failed:
Unknown parameter in Filters[0]: "Value", must be one of: Name, Values

Can you please suggest how can I find unallocated Ips. Thanks in advance.

Bhavik Joshi
  • 2,557
  • 6
  • 24
  • 48

1 Answers1

2

Do not add value = null just use Values="" check below command to filter them it will work.

aws ec2 describe-addresses --region us-east-1 --filter Name="instance-id",Values=""
Piyush Patil
  • 14,512
  • 6
  • 35
  • 54
  • This returns no results for me (and I do have elastic IPs, they are returned if I don't specify a filter). I can use `Values="*"` to find all allocated IPs, but would love to know how to find the unallocated ones (other than getting all of them and manually filtering out the allocated ones). – EM0 Nov 17 '17 at 10:00
  • 1
    This answer worked for me: https://stackoverflow.com/questions/33832460/how-can-i-select-all-elastic-ips-that-are-not-assigned-to-an-ec2-instance – EM0 Nov 17 '17 at 10:13