From 8ad9776a4f02cdbda5abb523c2bebd68c8f752f9 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Sun, 2 May 2021 12:07:26 +0300
Subject: [PATCH] Use CI templates for Terraform jobs.

---
 .gitlab-ci.yml | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4af2668..209ecc3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,9 +2,8 @@
 include:
   - project: shore/ci-templates
     file: templates/pre-commit.yml
-
-variables:
-  TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default
+  - project: shore/ci-templates
+    file: templates/terraform.yml
 
 stages:
   - test
@@ -30,27 +29,15 @@ Generate payload:
       - .cache/
 
 Terraform plan:
+  extends: .tf_plan
   stage: plan
-  image: &tf_image registry.gitlab.com/gitlab-org/terraform-images/stable:latest
-  script:
-    - gitlab-terraform plan
-    - gitlab-terraform plan-json
   dependencies:
     - Generate payload
-  artifacts:
-    name: plan
-    paths:
-      - plan.cache
-    reports:
-      terraform: plan.json
 
 Terraform apply:
+  extends: .tf_apply
   stage: apply
-  image: *tf_image
-  script:
-    - gitlab-terraform apply
   dependencies: &tf_apply_dependecies
     - Generate payload
     - Terraform plan
-  when: manual
   needs: *tf_apply_dependecies
-- 
GitLab