Skip to content

Bash script to update a DNS A and AAAA record in a GCP Cloud DNS zone

License

Notifications You must be signed in to change notification settings

300481/gcp-dns-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

gcp-dns-update

Bash script to update a DNS A and AAAA record in a GCP Cloud DNS zone

with the hosts public IP addresses.

It should run in the Alpine based gcloud container.

Usage

Mount the script and the service account key file into the same folder in the container.

Set the work directory to the directory where the script and key file is mounted to.

Name the key file service_account.json

Parameters

Let the bash script run with the following paramentes:

Parameter Description
-z [ ZONENAME ] The name of the GCP Cloud DNS Zone
-d [ DOMAIN ] The DOMAIN of the DNS record to update
-p [ PROJECT_ID ] The GCP Project ID
-t [ TTL ] The TTL for the records
-4 [ UPDATE_V4 ] Update the IPv4 address [true/false]
-6 [ UPDATE_V6 ] Update the IPv6 address [true/false]

Example Command

podman run \
  --rm \
  -v ${PWD}:/update:z \
  -w /update \
  gcr.io/google.com/cloudsdktool/google-cloud-cli:alpine \
  ./update.sh \
    -z ZONENAME \
    -d DOMAIN \
    -p PROJECT_ID \
    -t 60 \
    -4 true \
    -6 true