How can I select all elastic IPs that are not assigned to an EC2 instance?

后端 未结 2 2224
-上瘾入骨i
-上瘾入骨i 2021-02-20 15:38

I\'m trying to get all Elastic IPs that are not currently assigned to instances.

It\'s easy to get all of the Elastic IPs using this: aws ec2 describe-addresses

2条回答
  •  野性不改
    2021-02-20 16:41

    ElasticIPs are also attached to NAT Gateways. In that case InstanceID value will be null but AssociationID is the field which will be present there in any scenario. So better to use associationID to be sure that EIP is in use or not.

提交回复
热议问题