This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
buildspec-dev.yml
44 lines (35 loc) · 1.26 KB
/
buildspec-dev.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
34
35
36
37
38
39
40
41
42
43
44
version: 0.2
env:
variables:
TF_VERSION: "0.10.7"
phases:
install:
commands:
# install required binary
- "curl -s -qL -o /usr/bin/jq https://stedolan.github.io/jq/download/linux64/jq"
- "chmod +x /usr/bin/jq"
- "cd /usr/bin"
- "curl -s -qL -o terraform.zip https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip"
- "unzip -o terraform.zip"
pre_build:
commands:
# Workaround until TF supports creds via Task Roles when running on ECS or CodeBuild
# See: https://github.com/hashicorp/terraform/issues/8746
- export AWS_RAW_CRED=$(curl --silent https://169.254.170.2:80$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)
- export AWS_ACCESS_KEY_ID=$(echo $AWS_RAW_CRED | jq -r '.AccessKeyId')
- export AWS_SECRET_ACCESS_KEY=$(echo $AWS_RAW_CRED | jq -r '.SecretAccessKey')
- export AWS_SESSION_TOKEN=$(echo $AWS_RAW_CRED | jq -r '.Token')
build:
commands:
- cd "$CODEBUILD_SRC_DIR"
- cd "environments/$TF_ENV/"
- echo " building $TF_ENV"
- terraform init -no-color
- terraform plan -no-color
- terraform apply -no-color
post_build:
commands:
- echo "terraform completed on `date`"
artifacts:
files:
- '**/*'