Skip to content

Instantly share code, notes, and snippets.

@yuya-takeyama
Created September 4, 2018 06:50
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 yuya-takeyama/c02ce697cf1d56521716b0fbfea1701e to your computer and use it in GitHub Desktop.
Save yuya-takeyama/c02ce697cf1d56521716b0fbfea1701e to your computer and use it in GitHub Desktop.
#!/bin/bash
ip_map=$(jq --raw-input . | jq --slurp . | jq 'to_entries | map({key: .value, value: true}) | from_entries' --compact-output)
aws --profile aya ec2 describe-instances | \
jq -r --argjson ipMap "${ip_map}" \
'.Reservations[].Instances[] | select(.PrivateIpAddress | in($ipMap)) | .InstanceId'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment