Skip to content

Instantly share code, notes, and snippets.

@gsantovena
Last active May 16, 2018 22:07
Show Gist options
  • Save gsantovena/7f18457c9ba8db5ff8d9 to your computer and use it in GitHub Desktop.
Save gsantovena/7f18457c9ba8db5ff8d9 to your computer and use it in GitHub Desktop.
AWS CLI to get InstanceId and Private IP Address of Instances in AutoScalingGroup
aws --output text --region ${REGION} ec2 describe-instances --instance-ids $(
aws --output text --region ${REGION} \
autoscaling describe-auto-scaling-instances \
--query 'AutoScalingInstances[*].[AutoScalingGroupName,InstanceId]' |
grep ${ASG} |
awk '{ print $2 }'
) --query 'Reservations[*].Instances[*].[InstanceId,PrivateIpAddress]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment