From c1c183494e9a2c98d900ce35f221f39f4f6721e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20B=C3=A9jean?= <nicolas@bejean.fr>
Date: Sat, 29 Jan 2022 12:46:26 +0100
Subject: [PATCH] refactoring: Add version in variable

---
 .gitlab-ci.yml                 | 2 +-
 manifests/elastic/main.tf      | 2 +-
 manifests/elastic/variables.tf | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2055088..cc73646 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -83,7 +83,6 @@ apply-gke:
       gitlab-terraform init
       gitlab-terraform apply -auto-approve
 
-
 gcloud-psc:
   stage: psc
   needs:
@@ -134,6 +133,7 @@ check-elastic:
   variables:
     TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/elastic
     TF_VAR_ec_apikey: $EC_API_KEY
+    TF_var_ec_version: $EC_VERSION
   before_script:
     - |
       export TF_VAR_psc_connection_id=$(cat ${CI_PROJECT_DIR}/pscConnectionId.env | grep GCP_PSC_CONNECTION_ID | cut -d = -f2)
diff --git a/manifests/elastic/main.tf b/manifests/elastic/main.tf
index 021607d..b09c784 100644
--- a/manifests/elastic/main.tf
+++ b/manifests/elastic/main.tf
@@ -15,7 +15,7 @@ provider "ec" {
 }
 
 data "ec_stack" "stack" {
-  version_regex = "7.16.1"
+  version_regex = var.ec_version
   region        = var.region
 }
 
diff --git a/manifests/elastic/variables.tf b/manifests/elastic/variables.tf
index 02a5f46..79299aa 100644
--- a/manifests/elastic/variables.tf
+++ b/manifests/elastic/variables.tf
@@ -16,3 +16,7 @@ variable "cluster_name" {
   type    = string
   default = "elastic-for-gke"
 }
+
+variable "ec_version" {
+  type = string
+}
\ No newline at end of file
-- 
GitLab