Created
September 18, 2017 21:50
-
-
Save sjmcgrath/4da23bde08e8477c5655e02bf72d3510 to your computer and use it in GitHub Desktop.
Gets a list of Digital Ocean droplets and their IP addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
# DO_KEY_CONFIG_FILE should contain one line similar to the following with a Digital Ocean read key | |
# header = "Authorization: Bearer 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" | |
DO_KEY_CONFIG_FILE=${DO_KEY_CONFIG_FILE:?Must specify DO_KEY_CONFIG_FILE} | |
BASE="https://api.digitalocean.com" | |
ENDPOINT="/v2/droplets" | |
URL="${BASE}${ENDPOINT}" | |
curl --silent -X GET -K "${DO_KEY_CONFIG_FILE}" -- "${URL}" \ | |
| jq -r '.droplets[] | [.name, .networks.v4[0].ip_address] | join(" ")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment