Skip to content

Instantly share code, notes, and snippets.

@undeadops
Created August 10, 2017 18:07
Show Gist options
  • Save undeadops/b14d5dcba3ae91d82f5d84147c1337a0 to your computer and use it in GitHub Desktop.
Save undeadops/b14d5dcba3ae91d82f5d84147c1337a0 to your computer and use it in GitHub Desktop.
version: 2.0
jobs:
build:
working_directory: ~/knex
docker:
- image: hashicorp/terraform:0.10.0
steps:
- checkout
- run:
name: Initialize terraform
command: 'terraform init'
- run:
name: Fetch Terraform Statefile
command: 'terraform get'
- run:
name: Validate Terraform Config
command: 'terraform validate'
test:
working_directory: ~/knex
docker:
- image: hashicorp/terraform:0.10.0
steps:
- checkout
- run:
name: Plan Terraform Deployment
command: 'terraform plan -out=terraform.plan'
deploy:
docker:
- image: hashicorp/terraform:0.10.0
steps:
- checkout
- deploy:
command: |
if [ "${CIRCLE_BRANCH}" == "master" ];
then terraform apply terraform.plan;
fi
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
- hold:
type: approval
requires:
- build
- test
- deploy:
requires:
- hold
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment