/
buildspec.yaml
36 lines (30 loc) · 1.17 KB
/
buildspec.yaml
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
version: 0.2
env:
variables:
TF_VERSION: "0.12.20"
phases:
install:
runtime-versions:
java: corretto8
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 http://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"
- terraform --version
- terraform init
- terraform apply -auto-approve
# - terraform destroy -auto-approve