Skip to content

Instantly share code, notes, and snippets.

@jamesmoey
Last active January 23, 2018 00:02
Show Gist options
  • Save jamesmoey/678a1ee101bd03df9f05f04a50a44ef1 to your computer and use it in GitHub Desktop.
Save jamesmoey/678a1ee101bd03df9f05f04a50a44ef1 to your computer and use it in GitHub Desktop.
Create DNS Record On Google Cloud Compute Engine
#!/bin/sh
IP=$(curl http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip -H "Metadata-Flavor: Google")
gcloud dns record-sets transaction start -z=$1
gcloud dns record-sets transaction remove -z=$1 --name=$2 --type=A --ttl=3600
gcloud dns record-sets transaction add -z=$1 --name=$2 --type=A --ttl=3600 $IP
gcloud dns record-sets transaction execute -z=$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment