Is it possible to get aws ec2 instance id based on its IP address

aws ec2 describe-instances --filter Name=ip-address,Values=IP_1,..IP_N

Should do what you need.

use the filter name of private-ip-address to select using private address in your VPC.

Pipe through something like

jq -r '.Reservations[].Instances[] | .InstanceId, .PublicIpAddress'

if you want the corresponding InstanceID

Leave a Comment