Skip to content

Instantly share code, notes, and snippets.

@kusw3
Created March 7, 2020 11:40
Show Gist options
  • Save kusw3/3c263f2aa0586a0aac0782cbd51b28eb to your computer and use it in GitHub Desktop.
Save kusw3/3c263f2aa0586a0aac0782cbd51b28eb to your computer and use it in GitHub Desktop.
#!/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