Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Last active July 2, 2018 17:18
Show Gist options
  • Save rhelmer/a49cc673ad20a1e7fb56 to your computer and use it in GitHub Desktop.
Save rhelmer/a49cc673ad20a1e7fb56 to your computer and use it in GitHub Desktop.
aws-cli + jq

Using aws-cli and jq

list all instances for all ASGs

aws autoscaling describe-auto-scaling-instances \
  | jq '.AutoScalingInstances[] | {AutoScalingGroupName, InstanceId}'

list instance IDs for a particular ASG

aws autoscaling describe-auto-scaling-instances \
  | jq '.AutoScalingInstances[] | select(
          .AutoScalingGroupName=="rhelmer__asg_for_webapp")
        .InstanceId'

list all instances

aws ec2 describe-instances \
  | jq '.Reservations[].Instances[] | {PublicDnsName, InstanceId}'

list public DNS entry for a particular instance ID

aws ec2 describe-instances \
  | jq '.Reservations[].Instances[] | select(.InstanceId=="i-07c2630a")
        .PublicDnsName'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment