From d748c79a3265863c828e291f024f6b0590fd90ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20B=C3=A9jean?= <nicolas@bejean.fr> Date: Thu, 9 Dec 2021 21:17:32 +0100 Subject: [PATCH] Use Gitlab Terraform state --- .gitlab-ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1d05b6..d491a3b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,11 @@ image: busybox:latest +cache: + key: manifests-elastic + paths: + - ${TF_ROOT}/.terraform + +# docs: https://docs.gitlab.com/ee/user/infrastructure/iac/terraform_state.html#get-started-using-gitlab-ci elastic: stage: deploy tags: @@ -8,10 +14,13 @@ elastic: image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest entrypoint: [""] variables: + TF_ROOT: ${CI_PROJECT_DIR}/manifests/elastic + TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/manifests/elastic TF_VAR_ec_apikey: $EC_API_KEY script: - - cd ./manifests/elastic + - cd ${TF_ROOT} - terraform init + - terraform validate - terraform fmt -check - terraform plan - terraform apply -auto-approve -- GitLab