A comprehensive DevOps project demonstrating end-to-end CI/CD pipeline, containerization, and Infrastructure as Code (IaC) using AWS CloudFormation.
This project showcases a complete DevOps workflow from local development to production deployment:
- Python Application with unit tests and Flask web server
- Docker Containerization with optimized multi-stage builds
- GitHub Actions CI/CD Pipeline with automated testing and deployment
- AWS Infrastructure as Code using CloudFormation
- Automated Deployment to EC2 instances with zero-touch provisioning
- A[Local Code] --> B[GitHub Repository]
- B --> C[GitHub Actions CI/CD]
- C --> D[Docker Hub Registry]
- D --> E[AWS EC2 Instance]
- E --> F[CloudFormation IaC]
- F --> G[AWS S3 Storage]
- E --> H[🌐 Production Application]
- 🔧 DevOps & CI/CD
- GitHub Actions workflows for automated testing and building
- Docker containerization and image optimization
- Continuous Integration/Deployment pipeline implementation
- Automated testing with unittest framework
- ☁️ Cloud & Infrastructure
- AWS CloudFormation for Infrastructure as Code (IaC)
- EC2 instance management and auto-deployment
- S3 bucket configuration with versioning
- IAM roles with least privilege security principles
- VPC security groups with minimal open ports
- 💻 Development
- Python 3.10+ application development
- Flask web framework implementation
- Unit testing with comprehensive test coverage
- Dependency management with requirements.txt
- Python packaging with professional setup.py
- Python 3.10+
- Docker
- AWS CLI configured
- GitHub account
-
Clone the Repository:
git clone https://github.com/thomasasamba-bot/python-devops-demo.git\ cd python-devops-demo -
Local Development
-
Install dependencies:
pip install -r src/requirements.txt -
Run tests:
python -m unittest discover tests -v -
Run application locally:
python src/main.py
- Docker Containerization
-
Build Docker image:
docker build -t python-devops-demo:latest . -
Run container locally:
docker run -p 80:80 python-devops-demo:latest -
Test application:
curl http://localhost
- AWS Deployment
- Deploy complete infrastructure:
aws cloudformation create-stack
--stack-name python-devops-demo
--template-body file://infrastructure/infrastructure.yaml
--parameters
ParameterKey=KeyName,ParameterValue=MyPythonAppKey
ParameterKey=BucketNamePrefix,ParameterValue=python-devops-demo
ParameterKey=InstanceType,ParameterValue=t3.micro
--capabilities CAPABILITY_IAM
The GitHub Actions workflow automatically executes on every push:
- Testing Phase: Runs unit tests with unittest framework
- Build Phase: Builds Docker image with optimized layers
- Push Phase: Pushes image to Docker Hub registry
- Deployment Phase: Updates infrastructure via CloudFormation
✅ Tests: All unit tests must pass
✅ Build: Docker image builds successfully
✅ Security: No known vulnerabilities
✅ Deployment: Infrastructure updates complete \
aws ec2 create-key-pair
--key-name MyPythonAppKey
--query 'KeyMaterial'
--output text > MyPythonAppKey.pem
chmod 400 MyPythonAppKey.pem
✅ Private S3 buckets with versioning enabled
✅ Least privilege IAM roles for EC2 instances
✅ Security groups with minimal port exposure
✅ SSH key authentication only (no passwords)
✅ Docker image scanning in CI pipeline
- Service URL Description
- Web Application http://<EC2_PUBLIC_IP> Flask web interface
- Health Check http://<EC2_PUBLIC_IP>/health Application health status
- S3 Console https://s3.console.aws.amazon.com/s3/buckets/<BUCKET_NAME> Cloud storage management
-
Run all tests:
python -m unittest discover tests -v -
Test coverage:
python -m coverage run -m unittest discover tests -v
python -m coverage report
- Test Docker build and run:
docker build -t test-app .
docker run -d -p 80:80 test-app
curl http://localhost
- Docker container logs:
docker logs python-ci-app
docker logs -f python-ci-app
-
CloudFormation stack status:
aws cloudformation describe-stacks --stack-name python-devops-demo -
EC2 instance logs:
aws ec2 get-console-output --instance-id -
S3 bucket contents:
aws s3 ls s3://python-devops-demo-
-
Delete CloudFormation stack (deletes all resources except S3):
aws cloudformation delete-stack --stack-name python-devops-demo -
Manual S3 bucket cleanup (if needed):
aws s3 rb s3://python-devops-demo- --force
This project provides hands-on experience with:
- Infrastructure as Code with AWS CloudFormation
- CI/CD Pipelines with GitHub Actions
- Containerization Best Practices with Docker
- Cloud Security Principles and IAM management
- Automated Deployment Strategies for cloud environments
- DevOps Best Practices and workflow automation
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch (git checkout -b feature/amazing-feature)
- Commit changes (git commit -m 'Add amazing feature')
- Push to branch (git push origin feature/amazing-feature)
- Open a Pull Request
⭐ Star this repository if you found it helpful!