This repository was archived by the owner on Jan 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathbuildspec.yml
More file actions
43 lines (40 loc) · 1.99 KB
/
buildspec.yml
File metadata and controls
43 lines (40 loc) · 1.99 KB
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
---
version: 0.2
phases:
install:
commands:
- curl -sS -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- chmod +x ./kubectl ./aws-iam-authenticator
- export PATH=$PWD/:$PATH
- yum -y install jq python3-pip python3-dev && pip3 install --upgrade awscli
pre_build:
commands:
- $(aws ecr get-login --no-include-email)
- export KUBECONFIG=$HOME/.kube/config
build:
commands:
- ls -xtra
- echo "Contents of Dockerfile"
- cat Dockerfile
# building Docker image for Python App
- docker build -f Dockerfile -t codeguru-python-app-deployment --build-arg IAM_ROLE=$IAM_ROLE --build-arg SQS_URL=$SQS_URL --build-arg S3_BUCKET=$S3_BUCKET .
- docker tag codeguru-python-app-deployment:latest $ECR_PYTHON_APP_REPO:latest
- docker push $ECR_PYTHON_APP_REPO:latest
post_build:
commands:
- 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')
- echo $AWS_ACCESS_KEY_ID $AWS_EXPIRATION
- aws eks update-kubeconfig --name $EKS_CLUSTER_NAME
- kubectl config get-contexts
- kubectl get nodes
- kubectl delete deployments.apps codeguru-python-app-deployment
- kubectl apply -f codeguru-python-app-deployment.yaml
- kubectl get all -n default
- echo $EKS_KUBECTL_ROLE_ARN:$EKS_CLUSTER_NAME > build.json
artifacts:
files: build.json