diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-16 15:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-16 15:09:17 +0300 |
commit | 09dff3eec735ccbe001d165293ecebf195452071 (patch) | |
tree | 03c73077d0703edb9452145e7109835da2cd4918 /lib/gitlab/ci/templates/Terraform | |
parent | 78e911431fc575ff4f6c9b7e0f95c02b57a5e926 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/templates/Terraform')
-rw-r--r-- | lib/gitlab/ci/templates/Terraform/Base.gitlab-ci.yml | 64 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml | 16 |
2 files changed, 74 insertions, 6 deletions
diff --git a/lib/gitlab/ci/templates/Terraform/Base.gitlab-ci.yml b/lib/gitlab/ci/templates/Terraform/Base.gitlab-ci.yml new file mode 100644 index 00000000000..39c3374e534 --- /dev/null +++ b/lib/gitlab/ci/templates/Terraform/Base.gitlab-ci.yml @@ -0,0 +1,64 @@ +# 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/releases/terraform:1.0.3 + +variables: + TF_ROOT: ${CI_PROJECT_DIR} # The relative path to the root directory of the Terraform project + TF_STATE_NAME: ${TF_STATE_NAME:-default} # The name of the state file used by the GitLab Managed Terraform state backend + +cache: + key: "${TF_ROOT}" + paths: + - ${TF_ROOT}/.terraform/ + - ${TF_ROOT}/.terraform.lock.hcl + +.init: &init + stage: init + script: + - cd ${TF_ROOT} + - gitlab-terraform init + +.validate: &validate + stage: validate + script: + - cd ${TF_ROOT} + - gitlab-terraform validate + +.build: &build + stage: build + script: + - cd ${TF_ROOT} + - gitlab-terraform plan + - gitlab-terraform plan-json + artifacts: + paths: + - ${TF_ROOT}/plan.cache + reports: + terraform: ${TF_ROOT}/plan.json + +.deploy: &deploy + stage: deploy + script: + - cd ${TF_ROOT} + - gitlab-terraform apply + when: manual + only: + variables: + - $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +.destroy: &destroy + stage: cleanup + script: + - cd ${TF_ROOT} + - gitlab-terraform destroy + when: manual diff --git a/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml b/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml index 200388a274c..c30860ad174 100644 --- a/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml @@ -13,7 +13,8 @@ image: name: registry.gitlab.com/gitlab-org/terraform-images/stable:latest variables: - TF_ROOT: ${CI_PROJECT_DIR} + TF_ROOT: ${CI_PROJECT_DIR} # The relative path to the root directory of the Terraform project + TF_STATE_NAME: ${TF_STATE_NAME:-default} # The name of the state file used by the GitLab Managed Terraform state backend cache: key: "${TF_ROOT}" @@ -21,43 +22,46 @@ cache: - ${TF_ROOT}/.terraform/ - ${TF_ROOT}/.terraform.lock.hcl -.init: &init +.terraform:init: &terraform_init stage: init script: - cd ${TF_ROOT} - gitlab-terraform init -.validate: &validate +.terraform:validate: &terraform_validate stage: validate script: - cd ${TF_ROOT} - gitlab-terraform validate -.build: &build +.terraform:build: &terraform_build stage: build script: - cd ${TF_ROOT} - gitlab-terraform plan - gitlab-terraform plan-json + resource_group: ${TF_STATE_NAME} artifacts: paths: - ${TF_ROOT}/plan.cache reports: terraform: ${TF_ROOT}/plan.json -.deploy: &deploy +.terraform:deploy: &terraform_deploy stage: deploy script: - cd ${TF_ROOT} - gitlab-terraform apply + resource_group: ${TF_STATE_NAME} when: manual only: variables: - $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH -.destroy: &destroy +.terraform:destroy: &terraform_destroy stage: cleanup script: - cd ${TF_ROOT} - gitlab-terraform destroy + resource_group: ${TF_STATE_NAME} when: manual |