Commit 7ad1ccab authored by John Jarvis's avatar John Jarvis

Putting validation into a new stage

parent a9c2bad7
image: "alpine:latest" image: "alpine:latest"
stages: stages:
- validate
- planning - planning
- deployment - deployment
before_script: before_script:
- apk add --no-cache bash unzip wget ca-certificates make gnupg && update-ca-certificates - apk add --no-cache bash unzip wget ca-certificates make gnupg && update-ca-certificates
tf_validate:
stage: validate
# Validate every directory that contains terraform config
# (`terraform validate` does not do a full recurse)
script: |
#!/bin/bash
envs=$(ls -d environments/*)
for env in $envs; do
TF_VERSION="$(cat "${env}/.terraform_version")" make tfinstall
(
cd "$env" || exit
/terraform get
/bin/bash -e -c 'for d in $(find . -name "*.tf" -type f -exec dirname {} \; | sort | uniq); do echo "Checking $d for $0" && /terraform validate "$d"; done' "$env"
)
done
staging_tf_plan: staging_tf_plan:
stage: planning stage: planning
environment: environment:
name: staging name: staging
script: script:
- TF_VERSION="$(cat environments/staging/.terraform_version)" make tfinstall - TF_VERSION="$(cat environments/staging/.terraform_version)" make tfinstall
# Validate every directory that contains terraform config
# (`terraform validate` does not do a full recurse)
- /bin/bash -e -c 'for d in $(find . -name "*.tf" -type f -exec dirname {} \; | sort | uniq); do echo "Checking $d" && /terraform validate "$d"; done'
- cd environments/staging && /terraform init -input=false -backend-config="bucket=${STATE_S3_BUCKET}" -backend-config="key=${STATE_S3_KEY}" -backend-config="region=${STATE_S3_REGION}" && /terraform plan -input=false - cd environments/staging && /terraform init -input=false -backend-config="bucket=${STATE_S3_BUCKET}" -backend-config="key=${STATE_S3_KEY}" -backend-config="region=${STATE_S3_REGION}" && /terraform plan -input=false
except: except:
- master - master
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment