From ce675714fb7f6749e2fa4e7d9240fb01614fbac1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20B=C3=A9jean?= <nicolas@bejean.fr>
Date: Sun, 12 Dec 2021 18:04:12 +0100
Subject: [PATCH] refactoring: Add new variable for PSC connection

---
 .gitlab-ci.yml                 | 10 ++++++++--
 manifests/magento/variables.tf |  2 --
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 478f7ab..ac38137 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -50,6 +50,8 @@ check-magento:
     TF_VAR_ec_apikey: $EC_API_KEY
     TF_VAR_project_id: $GCP_PROJECT_ID
     GCP_SA_GITLAB: $GCP_SA_GITLAB
+    GCP_REGION: $GCP_REGION
+    GCP_SUBNETWORK_NAME: $GCP_SUBNETWORK_NAME
   script: |-
     cd $TF_ROOT_MAGENTO
     echo $GCP_SA_GITLAB > gcp-sa.json
@@ -96,6 +98,8 @@ apply-magento:
     TF_VAR_ec_apikey: $EC_API_KEY
     TF_VAR_project_id: $GCP_PROJECT_ID
     GCP_SA_GITLAB: $GCP_SA_GITLAB
+    GCP_REGION: $GCP_REGION
+    GCP_SUBNETWORK_NAME: $GCP_SUBNETWORK_NAME
   script: |-
     cd $TF_ROOT_MAGENTO
     echo $GCP_SA_GITLAB > gcp-sa.json
@@ -103,7 +107,7 @@ apply-magento:
     gitlab-terraform apply -auto-approve
 
 gcloud-psc:
-  stage: deploy
+  stage: test
   needs:
     - apply-elastic
     - apply-magento
@@ -115,10 +119,12 @@ gcloud-psc:
   variables:
     GCP_PROJECT_ID: $GCP_PROJECT_ID
     GCP_SA_GITLAB: $GCP_SA_GITLAB
+    GCP_REGION: $GCP_REGION
+    GCP_SUBNETWORK_NAME: $GCP_SUBNETWORK_NAME
   script: |-
     echo $GCP_SA_GITLAB > gcp-sa.json
     gcloud auth activate-service-account --key-file gcp-sa.json
     echo "Activate Service Account: OK"
     gcloud config set project $GCP_PROJECT_ID
     echo "Set Project: OK"
-    gcloud projects list
\ No newline at end of file
+    echo "Private IP Google Access is enabled on subnet: $(gcloud compute networks subnets describe $GCP_SUBNETWORK_NAME --region=$GCP_REGION --format="get(privateIpGoogleAccess)")"
\ No newline at end of file
diff --git a/manifests/magento/variables.tf b/manifests/magento/variables.tf
index de77fc7..224805b 100644
--- a/manifests/magento/variables.tf
+++ b/manifests/magento/variables.tf
@@ -4,7 +4,6 @@ variable "project_id" {
 
 variable "region" {
   type    = string
-  default = "europe-west1"
 }
 
 ### Network & Subnetwork
@@ -14,7 +13,6 @@ variable "vpc_network_name" {
 }
 variable "vpc_subnetwork_name" {
   type    = string
-  default = "vpc-sb-magento"
 }
 variable "vpc_private_ip_address_name" {
   type    = string
-- 
GitLab