Reputation: 10470
When I run ...
$ aws ec2 describe-instances --region=us-west-1 \
> --filters Name=instance-state-name,Values=stopped \
> Name=ip-address,Values=null \
> Name=block-device-mapping.status,Values=attached \
> --query "Reservations[].Instances[].[InstanceId,PublicIpAddress,BlockDeviceMappings[].Ebs.VolumeId]"
I get back ...
[]
If I take out the filter Name=ip-address,Values=null
I get this back ...
[
[
"i-XXXXX",
null,
[
"vol-f6f6f6f"
]
],
[
"i-d4XXXX8b",
"XX.XX.XXX.XX",
[
"vol-0ca0ca0ca"
]
],
How can I just get those EC2 instances that just have "null" for the PublicIpAddress?
Upvotes: 1
Views: 438
Reputation: 269282
Since there is no public-ip
, that filter doesn't seem to work.
Instead, I notice that such instances seem to have this entry:
"PublicDnsName": "",
Therefore, you should be able to use this logic:
aws ec2 describe-instances --query 'Reservations[].Instances[?PublicDnsName==``].InstanceId'
Upvotes: 1