dns.j2.sh 671 B

12345678910111213
  1. #!/bin/bash
  2. set -euo pipefail
  3. dns_zone="{{ dns_managed_zone | default(provision_prefix + 'managed-zone') }}"
  4. # Check the DNS managed zone in Google Cloud DNS, create it if it doesn't exist
  5. if ! gcloud --project "{{ gce_project_id }}" dns managed-zones describe "${dns_zone}" &>/dev/null; then
  6. gcloud --project "{{ gce_project_id }}" dns managed-zones create "${dns_zone}" --dns-name "{{ public_hosted_zone }}" --description "{{ public_hosted_zone }} domain" >/dev/null
  7. fi
  8. # Always output the expected nameservers as a comma delimited list
  9. gcloud --project "{{ gce_project_id }}" dns managed-zones describe "${dns_zone}" --format='value(nameServers)' | tr ';' ','