Skip to content

Instantly share code, notes, and snippets.

@chaspy
Last active August 30, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaspy/526b6fa1eec1c36bae59c3dbd5c46dc5 to your computer and use it in GitHub Desktop.
Save chaspy/526b6fa1eec1c36bae59c3dbd5c46dc5 to your computer and use it in GitHub Desktop.
get ip-addr of instances in ASG(searched by peco)
aws autoscaling describe-auto-scaling-groups |\
jq -r '.AutoScalingGroups[].AutoScalingGroupName' |\
peco |\
xargs -I{} aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names {} |\
jq -r '.AutoScalingGroups[]|.Instances[]|select(.LifecycleState == "InService")|select(.HealthStatus == "Healthy")|.InstanceId' |\
xargs aws ec2 describe-instances --instance-ids |\
jq -r '.Reservations[].Instances[]|select(.State.Name == "running")|.PrivateIpAddress'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment