2021-01-03 14:25:43 +05:30
|
|
|
# Terraform/Base.latest
|
|
|
|
#
|
|
|
|
# The purpose of this template is to provide flexibility to the user so
|
|
|
|
# they are able to only include the jobs that they find interesting.
|
|
|
|
#
|
|
|
|
# Therefore, this template is not supposed to run any jobs. The idea is to only
|
|
|
|
# create hidden jobs. See: https://docs.gitlab.com/ee/ci/yaml/#hide-jobs
|
|
|
|
#
|
|
|
|
# There is a more opinionated template which we suggest the users to abide,
|
|
|
|
# which is the lib/gitlab/ci/templates/Terraform.latest.gitlab-ci.yml
|
|
|
|
|
|
|
|
image:
|
|
|
|
name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
|
|
|
|
|
|
|
|
variables:
|
|
|
|
TF_ROOT: ${CI_PROJECT_DIR}
|
|
|
|
|
|
|
|
cache:
|
|
|
|
key: "${TF_ROOT}"
|
|
|
|
paths:
|
|
|
|
- ${TF_ROOT}/.terraform/
|
2021-03-08 18:12:59 +05:30
|
|
|
- ${TF_ROOT}/.terraform.lock.hcl
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
.init: &init
|
|
|
|
stage: init
|
|
|
|
script:
|
2021-01-29 00:20:46 +05:30
|
|
|
- cd ${TF_ROOT}
|
2021-01-03 14:25:43 +05:30
|
|
|
- gitlab-terraform init
|
|
|
|
|
|
|
|
.validate: &validate
|
|
|
|
stage: validate
|
|
|
|
script:
|
2021-01-29 00:20:46 +05:30
|
|
|
- cd ${TF_ROOT}
|
2021-01-03 14:25:43 +05:30
|
|
|
- gitlab-terraform validate
|
|
|
|
|
|
|
|
.build: &build
|
|
|
|
stage: build
|
|
|
|
script:
|
2021-01-29 00:20:46 +05:30
|
|
|
- cd ${TF_ROOT}
|
2021-01-03 14:25:43 +05:30
|
|
|
- gitlab-terraform plan
|
|
|
|
- gitlab-terraform plan-json
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- ${TF_ROOT}/plan.cache
|
|
|
|
reports:
|
|
|
|
terraform: ${TF_ROOT}/plan.json
|
|
|
|
|
|
|
|
.deploy: &deploy
|
|
|
|
stage: deploy
|
|
|
|
script:
|
2021-01-29 00:20:46 +05:30
|
|
|
- cd ${TF_ROOT}
|
2021-01-03 14:25:43 +05:30
|
|
|
- gitlab-terraform apply
|
|
|
|
when: manual
|
|
|
|
only:
|
2021-04-17 20:07:23 +05:30
|
|
|
variables:
|
|
|
|
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
.destroy: &destroy
|
|
|
|
stage: cleanup
|
|
|
|
script:
|
2021-02-22 17:27:13 +05:30
|
|
|
- cd ${TF_ROOT}
|
2021-01-29 00:20:46 +05:30
|
|
|
- gitlab-terraform destroy
|
|
|
|
when: manual
|