diff --git a/manifests/psc/setting-psc.sh b/manifests/psc/setting-psc.sh index cc0686ea5fd09bdfdfd7778b4d26b1ccd637a304..989db28a413da35932a6385333179c57b274033d 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