This project demonstrates an end-to-end DevSecOps pipeline using AWS and Kubernetes.
It automates build, test, security scanning, containerization, and deployment of a Python application.
- AWS CodePipeline (CI/CD)
- AWS CodeBuild (Build & Test)
- AWS ECR (Container Registry)
- AWS EKS (Kubernetes)
- Docker
- Python (Flask)
- pytest
- Trivy and Bandit
- SNS (Notifications)
python-devsecops/
│── app/
│ └── app.py
│── tests/
│ └── test_app.py
│── Dockerfile
│── requirements.txt
│── deployment.yaml
│── service.yaml
│── buildspec.yml
│── architecture.png
│── README.mdSetup Instructions:
- Clone Repository
git clone https://github.com/asvin00/python-devsecops.git
cd python-devsecops- Run Application Locally
pip install -r requirements.txt
python run.pyOpen in browser:
http://localhost:5000
- Run Tests
pytest
- Build Docker Image
docker build -t python-devsecops .
- Configure AWS
aws configure
- Push Image to ECR
docker tag python-devsecops:latest <account-id>.dkr.ecr.ap-south-1.amazonaws.com/python-devsecops:latest
docker push <account-id>.dkr.ecr.ap-south-1.amazonaws.com/python-devsecops:latest
- Create EKS Cluster
eksctl create cluster \
--name devsecops-cluster \
--region ap-south-1 \
--node-type t3.medium \
--nodes 2
- wait for nearly 45 minutes.
- Configure Kubernetes
aws eks update-kubeconfig --region ap-south-1 --name devsecops-cluster
- Deploy Application
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
- Verify Deployment
kubectl get pods
kubectl get svc
- Open the EXTERNAL-IP in browser.
- Setup CodeBuild
-
Go to AWS Console → CodeBuild → Create Project
-
Configure Source:
- Source provider: GitHub
- Repository: Select your repository
- Branch: main
- Environment Configuration:
- Environment image: Managed image
- OS: Amazon Linux 2
- Runtime: Standard
- Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
- Privileged mode: Enabled (required for Docker)
- Service Role:
- Create new role or use existing with:
- ECR access
- EKS access
- S3 access
- Buildspec:
- Use `buildspec.yml` from repository
- Logs:
- Enable CloudWatch logs
- Create Build Project
- Setup CodePipeline
-
Go to AWS Console → CodePipeline → Create Pipeline
-
Pipeline Settings:
- Pipeline name: devsecops-pipeline
- Service role: Create new role
- Artifact store: Default S3
- Add Source Stage:
- Source provider: GitHub
- Connect your GitHub account
- Repository: Select your repo
- Branch: main
- Add Build Stage:
- Build provider: CodeBuild
- Select previously created CodeBuild project
- Add Deploy Stage (Optional if handled in buildspec):
- You can skip this if deployment is done via `kubectl` in buildspec.yml
- Review and Create Pipeline
- Trigger Pipeline
git add .
git commit -m "Trigger pipeline"
git push origin main