-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuildspec.yaml
32 lines (30 loc) · 1.4 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
version: 0.2
env:
variables:
EKS_KUBECTL_ROLE_ARN: arn:aws:iam::<YOUR_ACCOUNT_ID>:role/EksCodeBuildKubectlRole
EKS_CLUSTER_NAME: airflow
AWS_DEFAULT_REGION: us-east-1
phases:
pre_build:
commands:
- echo Entered the pre_build phase...
- pip3 install j2cli
- curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash -s -- --version v3.8.2
build:
commands:
# Extracting AWS Credential Information using STS Assume Role for kubectl
- echo "Setting Environment Variables related to AWS CLI for Kube Config Setup"
- CREDENTIALS=$(aws sts assume-role --role-arn $EKS_KUBECTL_ROLE_ARN --role-session-name codebuild-kubectl --duration-seconds 900)
- export AWS_ACCESS_KEY_ID="$(echo ${CREDENTIALS} | jq -r '.Credentials.AccessKeyId')"
- export AWS_SECRET_ACCESS_KEY="$(echo ${CREDENTIALS} | jq -r '.Credentials.SecretAccessKey')"
- export AWS_SESSION_TOKEN="$(echo ${CREDENTIALS} | jq -r '.Credentials.SessionToken')"
- export AWS_EXPIRATION=$(echo ${CREDENTIALS} | jq -r '.Credentials.Expiration')
# Setup kubectl with our EKS Cluster
- echo "Update Kube Config"
- aws eks update-kubeconfig --name $EKS_CLUSTER_NAME
- echo Build started on `date`
- chmod 777 ./scripts/deploy.sh
- ./scripts/deploy.sh
post_build:
commands:
- echo Build completed on `date`