Last active
June 14, 2017 14:25
-
-
Save devth/10057a0e65dfa7081208d83fc05607fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile: clean | |
# -m / --multi <dir> Write multiple files to the directory, list files on stdout | |
jsonnet $(JSONNET_ARGS) -m $(BUILD_DIR) $(TF_FILE) | |
show: compile | |
jsonnet $(JSONNET_ARGS) $(TF_FILE) | |
clean: | |
rm -f $(BUILD_DIR)/*.tf.json | |
rm -f $(BUILD_DIR)/*.tfplan | |
init: | |
cd $(BUILD_DIR) && \ | |
terraform init | |
plan: # requires that compile was previously run | |
cd $(BUILD_DIR) && \ | |
terraform plan -out $(TF_PLAN_FILE) $(TF_ARGS) . | |
apply: | |
cd $(BUILD_DIR) && \ | |
terraform show $(TF_PLAN_FILE) && \ | |
terraform apply $(TF_PLAN_FILE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# infra {{{ | |
.infra: &infra | |
variables: | |
PROJECT: "${INFRA_PROJECT}" | |
cache: | |
key: "${CI_BUILD_REF_NAME}_${INFRA_PROJECT}" | |
paths: | |
- "project/${INFRA_PROJECT}/build" | |
# Compile jsonnet for `plan` | |
infra_compile: | |
<<: *infra | |
stage: compile | |
image: $JSONNET_DOCKER_IMAGE | |
script: | |
- make clean && make compile | |
# Create a plan of changes for `apply` | |
infra_terraform_plan: | |
<<: *infra | |
stage: plan | |
image: $TERRAFORM_DOCKER_IMAGE | |
script: | |
- apk -U add make | |
- make init && make plan | |
# Apply the plan generated by the previous step | |
infra_terraform_apply: | |
<<: *infra | |
stage: apply | |
only: | |
- master | |
when: manual | |
environment: | |
name: infra | |
url: $INFRA_URL | |
image: $TERRAFORM_DOCKER_IMAGE | |
script: | |
- apk -U add make | |
- make init | |
- make apply | |
# }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment