Skip to content

Commit

Permalink
Merge pull request #82 from jungleBadger/boilerplate-adjustments
Browse files Browse the repository at this point in the history
Boilerplate adjustments to avoid Pods creation issue
  • Loading branch information
SudKul authored Apr 1, 2024
2 parents cac4e7c + 1c42b21 commit b9f5782
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use the `python:3.7` as a source image from the Amazon ECR Public Gallery
# We are not using `python:3.7.2-slim` from Dockerhub because it has put a pull rate limit.
FROM public.ecr.aws/sam/build-python3.7:latest
# Use the `python:3.9` as a source image from the Amazon ECR Public Gallery
# We are not using `python:3.7.2-slim` from Dockerhub because it has put a pull rate limit.
FROM public.ecr.aws/sam/build-python3.9:latest

# Set up an app directory for your code
COPY . /app
Expand Down
24 changes: 13 additions & 11 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ phases:
# You must use a kubectl version that is within one minor version difference of your Amazon EKS cluster control plane.
# For example, a 1.21 kubectl client works with Kubernetes 1.20, 1.21 and 1.22 clusters.
# Ref: https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html OR https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
# To download a specific version v1.22.0 on Linux, use:
- curl -LO https://dl.k8s.io/release/v1.23.6/bin/linux/amd64/kubectl
# To download a specific version v1.27.9 on Linux, use:
- curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.9/2024-01-04/bin/linux/amd64/kubectl
# Download the kubectl checksum file
- curl -LO "https://dl.k8s.io/v1.23.6/bin/linux/amd64/kubectl.sha256"
- curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.9/2024-01-04/bin/linux/amd64/kubectl.sha256
# Validate the kubectl binary against the checksum file
- echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
- sha256sum -c kubectl.sha256
# Install kubectl
- chmod +x ./kubectl ./aws-iam-authenticator
# - mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
Expand All @@ -30,14 +30,16 @@ phases:
- echo 'export PATH=$PWD/:$PATH' >> $HOME/.bashrc
- echo `kubectl version --short --client`
- python -m pip install --upgrade --force pip
- apt-get update && apt-get -y install jq && pip install --upgrade awscli
- wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add
- apt-get update && apt-get -y install jq && pip install --upgrade awscli pytest
pre_build:
commands:
- TAG="$REPOSITORY_NAME.$REPOSITORY_BRANCH.$ENVIRONMENT_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- sed -i 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' simple_jwt_api.yml
- $(aws ecr get-login --no-include-email)
- export KUBECONFIG=$HOME/.kube/config
- echo `ls -l`
commands:
- TAG="$REPOSITORY_NAME.$REPOSITORY_BRANCH.$ENVIRONMENT_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- sed -i 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' simple_jwt_api.yml
- $(aws ecr get-login --no-include-email)
- export KUBECONFIG=$HOME/.kube/config
- echo `ls -l`
- pip install -r requirements.txt
build:
commands:
- docker build --tag $REPOSITORY_URI:$TAG .
Expand Down
14 changes: 9 additions & 5 deletions ci-cd-codepipeline.cfn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Resources:
ZipFile: |
import json
import boto3
from botocore.vendored import requests
import urllib3
def handler(event, context):
response = {
'Status': 'SUCCESS',
Expand All @@ -130,7 +130,8 @@ Resources:
'LogicalResourceId': event['LogicalResourceId'],
'Data': {"Message": "Resource creation successful!"},
}
http = urllib3.PoolManager()
client = boto3.client('iam')
try:
if event['RequestType'] == 'Create':
Expand All @@ -155,13 +156,16 @@ Resources:
response['Data'] = {"Message": "Resource creation failed"}
response_body = json.dumps(response)
headers = {'content-type': '', "content-length": str(len(response_body)) }
put_response = requests.put(event['ResponseURL'], headers=headers, data=response_body)
headers = {'Content-Type': 'application/json', "content-length": str(len(response_body)) }
put_response = http.request('PUT',
event['ResponseURL'],
body = response_body,
headers=headers)
return response
Handler: index.handler
Role: !GetAtt CustomResourceLambdaExecutionRole.Arn
Runtime: python3.7
Runtime: python3.9
Timeout: 300

CustomResourceLambdaExecutionRole:
Expand Down

0 comments on commit b9f5782

Please sign in to comment.