From 4c167c5997b1b97e1ea9c0240167fb82f9a50ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20B=C3=A9jean?= <nicolas@bejean.fr> Date: Sun, 12 Dec 2021 21:27:22 +0100 Subject: [PATCH] Add test for DNS Zone --- manifests/psc/setting-psc.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/manifests/psc/setting-psc.sh b/manifests/psc/setting-psc.sh index cc0686e..989db28 100644 --- a/manifests/psc/setting-psc.sh +++ b/manifests/psc/setting-psc.sh @@ -26,9 +26,15 @@ else gcloud compute forwarding-rules create $GCP_PSC_NAME --region=$GCP_REGION --network=$GCP_NETWORK_NAME --address=$GCP_INTERNAL_IP_NAME --target-service-attachment=$ELASTIC_SERVICE_ATTACHMENT_URI fi -#DNS_ZONE_CREATED=$(gcloud) -gcloud dns managed-zones create $GCP_DNS_ZONE_MAGENTO_ELASTIC --description="Managed by GitLab CI" --dns-name=$ELASTIC_DNS_ZONE. --visibility=private --networks=$GCP_NETWORK_NAME -gcloud dns record-sets transaction start --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC" -gcloud dns record-sets transaction add $(gcloud compute addresses describe $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --format="get(address)") --name="*.$ELASTIC_DNS_ZONE." --ttl="30" --type="A" --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC" -gcloud dns record-sets transaction execute --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC" +gcloud dns managed-zones describe $GCP_DNS_ZONE_MAGENTO_ELASTIC > /dev/null 2>&1 +DNS_ZONE_CREATED=$? + +if [[ $DNS_ZONE_CREATED -ne 0 ]]; then + echo 'DNS_ZONE_CREATED' +else + gcloud dns managed-zones create $GCP_DNS_ZONE_MAGENTO_ELASTIC --description="Managed by GitLab CI" --dns-name=$ELASTIC_DNS_ZONE. --visibility=private --networks=$GCP_NETWORK_NAME + gcloud dns record-sets transaction start --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC" + gcloud dns record-sets transaction add $(gcloud compute addresses describe $GCP_INTERNAL_IP_NAME --region=$GCP_REGION --format="get(address)") --name="*.$ELASTIC_DNS_ZONE." --ttl="30" --type="A" --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC" + gcloud dns record-sets transaction execute --zone="$GCP_DNS_ZONE_MAGENTO_ELASTIC" +fi -- GitLab