forked from plus3it/terraform-aws-watchmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
33 lines (31 loc) · 1.33 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
version: 0.2
env:
variables:
YQ_INSTALL: https://github.com/mikefarah/yq/releases/download/v4.31.1/yq_linux_amd64
phases:
install:
commands:
- cd tests/
- curl -L "${YQ_INSTALL}" -o yq && chmod +x yq # install yq
- terraform_version=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | ./yq -r -M '.current_version')
- terraform_url="${TERRAFORM_URL:-https://releases.hashicorp.com/terraform/${terraform_version}/terraform_${terraform_version}_linux_amd64.zip}"
- curl -L "${terraform_url}" -o tf.zip && unzip tf.zip # install terraform
- mv terraform /usr/local/bin/ && terraform -version
pre_build:
commands:
- export TF_VAR_build_id="${CODEBUILD_BUILD_ID}"
- terraform init -no-color -input=false # init terraform
- terraform plan -no-color -out=tfplan -input=false # plan terraform
build:
commands:
- terraform apply -no-color -input=false tfplan # apply terraform
post_build:
commands:
- if [ "${DESTROY_AFTER_TEST}" = "true" ]; then terraform destroy -no-color -input=false -auto-approve; fi
artifacts:
files:
- tests/terraform.tfstate
- tests/terraform.log
- tests/terraform_output.log
discard-paths: true