Terraform and Gitlab CI integration

terraform planterraform apply
plan-stg-airflow_project:  environment:    url: workspaces/airflow_aerotrade/extends:  - .stg-env-tpl  - .tf-build-tplonly:  refs:    - merge_requests    - master  changes:    - “workspaces/access_management/stg/*”    - “workspaces/airflow_project/stg/*”    - “modules/gcs_provider/*”    - “modules/google_apis/*”    - “modules/airflow/*”    - “modules/compute/*”    - “workspaces/compute/stg/*”except:  - triggers
.tf-build-tpl:  extends: .tf-base-buildonly:  - merge_requests  - master  - branches
.tf-base-build: extends: .tf-infra-tpl stage: build script: - echo “tf-base-build” - echo ${CI_ENVIRONMENT_URL} - echo ${CI_ENVIRONMENT_NAME} - cd ${CI_ENVIRONMENT_URL}/${CI_ENVIRONMENT_NAME} - ls -l - md5sum ${GOOGLE_APPLICATION_CREDENTIALS} - terraform init - terraform validate - export PLAN=current_plan.txt - terraform plan -lock=false -out=$PLAN artifacts: name: plan paths: - current_plan.txt
.tf-infra-tpl:  tags:    - blockchainimage:  name: hashicorp/terraform:0.13.1  entrypoint: [“”]before_script:  - echo “tf-infra-tpl”  - export TF_IN_AUTOMATION=true  - terraform version  - echo ${TERRAFORM_SA_FILE} | base64 -d > creds.json  - export GOOGLE_APPLICATION_CREDENTIALS=”${PWD}/creds.json”
only:  changes:    - workspaces/access_management/prd/*    - modules/gcs_provider/*    - modules/google_apis/*    - modules/ro_access/*    - modules/oauth/*

--

--

--

Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Victor Yeo

Victor Yeo

Engineer

More from Medium

Working with Hashicorp Vault API’s

Deploying a Gitlab Project on GKE Cluster

Managing Repositories in GitHub via Terraform (Part 1)

Vault Cluster in AWS using Terraform and Packer