Skip to content

Instantly share code, notes, and snippets.

@t0mmyt
Last active April 21, 2016 15:20
Show Gist options
  • Select an option

  • Save t0mmyt/8ec0ba86f16488bb6b50ce60c151de90 to your computer and use it in GitHub Desktop.

Select an option

Save t0mmyt/8ec0ba86f16488bb6b50ce60c151de90 to your computer and use it in GitHub Desktop.
AWS CLI
# Requires describe tags in IAM
aws ec2 --region eu-west-1 describe-tags --filter "Name=resource-id,Values=$(curl -ss http://169.254.169.254/latest/meta-data/instance-id)" | jq '.Tags[] | select(.Key=="aws:autoscaling:groupName").Value'
# Get IPs of other instances in my ASG
aws ec2 --region eu-west-1 describe-instances --filter Name=tag:aws:autoscaling:groupName,Values=$(aws ec2 --region eu-west-1 describe-tags --filter "Name=resource-id,Values=$(curl -ss http://169.254.169.254/latest/meta-data/instance-id)" | jq '.Tags[] | select(.Key=="aws:autoscaling:groupName").Value') | jq '.Reservations[].Instances[] | select(.State.Name=="running") | .NetworkInterfaces[0].PrivateIpAddress'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment