diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1d05b685263a8a2d700859d9c51c8db6b5395c0..d491a3bef9a29395f14e267d83fc4aeb014e1214 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