2017-09-07 05:25:06 -04:00
|
|
|
# Official image for Hashicorp's Terraform. It uses light image which is Alpine
|
|
|
|
# based as it is much lighter.
|
|
|
|
#
|
|
|
|
# Entrypoint is also needed as image by default set `terraform` binary as an
|
|
|
|
# entrypoint.
|
|
|
|
image:
|
|
|
|
name: hashicorp/terraform:light
|
|
|
|
entrypoint:
|
|
|
|
- '/usr/bin/env'
|
|
|
|
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
|
|
|
|
|
|
|
# Default output file for Terraform plan
|
|
|
|
variables:
|
|
|
|
PLAN: plan.tfplan
|
|
|
|
|
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .terraform
|
|
|
|
|
|
|
|
before_script:
|
|
|
|
- terraform --version
|
|
|
|
- terraform init
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- validate
|
|
|
|
- build
|
2019-04-05 06:18:10 -04:00
|
|
|
- test
|
2017-09-07 05:25:06 -04:00
|
|
|
- deploy
|
|
|
|
|
|
|
|
validate:
|
|
|
|
stage: validate
|
|
|
|
script:
|
|
|
|
- terraform validate
|
|
|
|
|
|
|
|
plan:
|
|
|
|
stage: build
|
|
|
|
script:
|
|
|
|
- terraform plan -out=$PLAN
|
|
|
|
artifacts:
|
|
|
|
name: plan
|
|
|
|
paths:
|
|
|
|
- $PLAN
|
|
|
|
|
|
|
|
# Separate apply job for manual launching Terraform as it can be destructive
|
|
|
|
# action.
|
|
|
|
apply:
|
|
|
|
stage: deploy
|
|
|
|
environment:
|
|
|
|
name: production
|
|
|
|
script:
|
|
|
|
- terraform apply -input=false $PLAN
|
|
|
|
dependencies:
|
|
|
|
- plan
|
|
|
|
when: manual
|
|
|
|
only:
|
2019-11-13 16:06:45 -05:00
|
|
|
- master
|