From 9d4e8f7ec48ca06aae36c237fa4636fc8ef8f1c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20B=C3=A9jean?= <nicolas@bejean.fr>
Date: Sun, 12 Dec 2021 21:37:24 +0100
Subject: [PATCH] Get PSC Connection ID

---
 .gitlab-ci.yml               | 13 +++++++++++++
 manifests/psc/setting-psc.sh |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 53aefa3..92a32d6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -139,3 +139,16 @@ gcloud-psc:
     cd $GCLOUD_ROOT_PSC
     chmod +x ./setting-psc.sh
     ./setting-psc.sh
+  artifacts:
+    paths:
+      - ${CI_PROJECT_DIR}/pscConnectionId.env
+
+
+elastic-traffic-filter:
+  stage: deploy
+  needs:
+    - gcloud-psc
+  tags:
+    - docker
+  script: |-
+    cat ${CI_PROJECT_DIR}/pscConnectionId.env
diff --git a/manifests/psc/setting-psc.sh b/manifests/psc/setting-psc.sh
index 989db28..a9eb8da 100644
--- a/manifests/psc/setting-psc.sh
+++ b/manifests/psc/setting-psc.sh
@@ -38,3 +38,6 @@ else
   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
+
+
+echo "GCP_PSC_CONNECTION_ID=$(gcloud compute forwarding-rules describe $GCP_PSC_NAME --region=$GCP_REGION --format="get(pscConnectionId)")" > pscConnectionId.env
\ No newline at end of file
-- 
GitLab