Created
March 7, 2020 11:40
-
-
Save kusw3/3c263f2aa0586a0aac0782cbd51b28eb to your computer and use it in GitHub Desktop.
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 | |
# Helper program to get a domain ip into terraform | |
# Tested on amzlinux2 OS, macosx | |
# marc@kusw3.com | |
if [[ $# -ne 1 ]]; then | |
echo "ERROR: expected 1 argument as domain name" | |
exit 1; | |
fi | |
IP=$(dig +short $1 | tail -1) | |
if [[ "$IP" == "" ]]; then | |
echo "ERROR: domain name not found" | |
exit 2; | |
fi | |
echo "{ \"ip\": \"$IP/32\" }" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment