Skip to content

Instantly share code, notes, and snippets.

@pascalwhoop
Created September 19, 2019 12:33
Show Gist options
  • Save pascalwhoop/07c2eb3bb883b5b69cbf2eb4c65474ed to your computer and use it in GitHub Desktop.
Save pascalwhoop/07c2eb3bb883b5b69cbf2eb4c65474ed to your computer and use it in GitHub Desktop.
image:
name: hashicorp/terraform:0.12.8
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
## Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- mkdir -p ~/.ssh
- ssh-keyscan github.com >> ~/.ssh/known_hosts
- cd env/$CI_COMMIT_REF_NAME
- terraform init
stages:
- validate
- plan
- apply
validate:
stage: validate
script:
- terraform validate
plan:
stage: plan
script:
- terraform plan -out "planfile"
dependencies:
- validate
artifacts:
paths:
- planfile
apply:
stage: apply
script:
- terraform apply -input=false "planfile"
dependencies:
- plan
when: manual
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment