Commit 9d543962 authored by nimrod's avatar nimrod
Browse files

Template for Terraform jobs.

parent e38d3312
Loading
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
---
variables:
  TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default
  TF_INPUT: !!str 0
  TF_IN_AUTOMATION: !!str 1
  TF_CLI_ARGS: ""
  TF_WORKSPACE: default

.tf_validate:
  stage: test
  image: &tf_image registry.gitlab.com/gitlab-org/terraform-images/stable:latest
  before_script: &tf_before_script
    - |-
      [ -z "${TF_ROOT:-}" ] ||  cd "${TF_ROOT}"
  script:
    - gitlab-terraform validate

.tf_fmt:
  stage: test
  image: *tf_image
  before_script: *tf_before_script
  script:
    - gitlab-terraform fmt

.tf_validate_fmt:
  stage: test
  image: *tf_image
  before_script: *tf_before_script
  script:
    - gitlab-terraform validate
    - gitlab-terraform fmt

.tf_plan:
  image: *tf_image
  before_script: &tf_before_script
    - cd "${TF_ROOT}"
  script:
    - gitlab-terraform plan
    - gitlab-terraform plan-json
  artifacts:
    name: plan
    paths:
      - plan.cache
    reports:
      terraform: plan.json

.tf_apply:
  image: *tf_image
  script:
    - gitlab-terraform apply
  when: manual