Fully automated continuous integration and continuous deployment pipeline for web applications on AWS
This project implements a complete CI/CD pipeline on AWS for a Todo List web application. It demonstrates how to automate the build and deployment process for both static websites hosted on S3 and dynamic Flask applications running in containers on ECS.
- Automated build and deployment pipeline using AWS CodeBuild
- Containerized Flask application with Docker and AWS ECS/ECR
- Static website hosting on AWS S3
- Source code management with Git and GitHub
- Infrastructure as Code (IaC) approach for AWS resources
- DevOps engineers looking to implement AWS-based CI/CD pipelines
- Web developers seeking to automate deployment workflows
- Cloud architects designing scalable application infrastructures
- Students and professionals learning AWS services and modern deployment practices
This project bridges the gap between development and operations by providing a complete, working example of integrating multiple AWS services into a cohesive pipeline. Unlike theoretical examples, this implementation includes actual application code (Todo List) that makes the CI/CD concepts tangible and practical.
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Backend: Python 3.9, Flask 2.3.2
- Containerization: Docker
- CI/CD: AWS CodeBuild
- Cloud Services:
- AWS S3 (Static website hosting)
- AWS ECR (Container registry)
- AWS ECS (Container orchestration)
- Version Control: Git, GitHub
- Web Server: Nginx (for static content)
- AWS Account with appropriate permissions
- AWS CLI installed and configured
- Git installed
- Docker installed (for local testing)
- Python 3.9 installed (for local development)
git clone https://github.com/muhammadhamzagova666/aws-cicd-pipeline.git
cd aws-cicd-pipeline# Navigate to the static website directory
cd CodeBuild\ Static/
# You can use any simple HTTP server to test locally
# For Python:
python -m http.server 8000# Navigate to the Flask app directory
cd CodeBuild\ Dynamic/
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the Flask application
python app.pyAfter starting your local server, navigate to http://localhost:8000 in your browser to see the Todo List application. You can:
- Add new todo items
- Delete individual items
- Select multiple items with checkboxes and delete them together
After starting the Flask server, navigate to http://localhost:5000 in your browser.
The CI/CD pipeline automatically deploys your application when you push changes to the repository. The process includes:
- CodeBuild picks up changes from the repository
- Builds the application (compiles Python code or prepares static assets)
- Creates Docker images for the dynamic application
- Pushes images to ECR
- Updates ECS services to use the new images
- Updates static content on S3
aws-cicd-pipeline/
├── CodeBuild Dynamic/ # Flask application with CodeBuild configuration
│ ├── app.py # Main Flask application file
│ ├── buildspec.yml # AWS CodeBuild configuration
│ └── requirements.txt # Python dependencies
│
├── CodeBuild Static/ # Static website with CodeBuild configuration
│ ├── buildspec.yml # AWS CodeBuild configuration for static site
│ ├── index.html # Main HTML file for the Todo List app
│ ├── ten.css # Stylesheet for the Todo List app
│ └── ten.js # JavaScript functionality for the Todo List app
│
├── documentation/ # Additional documentation
│ └── ...
│
└── README.md # This file
For AWS CodeBuild:
AWS_REGION: The AWS region to deploy toECR_REPOSITORY_URI: URI of your ECR repositoryECS_CLUSTER: Name of your ECS clusterECS_SERVICE: Name of your ECS serviceTASK_DEFINITION: Path to your task definition file
Example .env file:
AWS_REGION=us-east-1
ECR_REPOSITORY_URI=123456789012.dkr.ecr.us-east-1.amazonaws.com/my-repo
ECS_CLUSTER=my-cluster
ECS_SERVICE=my-service
TASK_DEFINITION=task-definition.json
-
Create an S3 Bucket for Static Hosting
aws s3 mb s3://my-todo-app-static-bucket aws s3 website s3://my-todo-app-static-bucket --index-document index.html
-
Create ECR Repository
aws ecr create-repository --repository-name todo-app-dynamic
-
Create ECS Cluster
aws ecs create-cluster --cluster-name todo-app-cluster
-
Set Up CodeBuild Projects
- Create one CodeBuild project for the static website
- Create another CodeBuild project for the dynamic Flask application
- Configure both to use the respective buildspec.yml files
- Configure GitHub repository as the source for both CodeBuild projects
- Set up webhooks to trigger builds on code push
- Configure the appropriate IAM roles and policies for CodeBuild to access other AWS services
# For the Flask application
cd CodeBuild\ Dynamic/
python -m pytest
# For static files, you can use tools like lighthouse
lighthouse http://localhost:8000- CodeBuild Fails: Check the CodeBuild logs for specific error messages
- ECS Deployment Fails: Verify your task definition and that the container can start properly
- S3 Website Not Accessible: Check bucket policies and public access settings
- Enable S3 bucket caching for static assets with appropriate cache headers
- Implement AWS CloudFront for global content delivery
- Configure container resource allocation in ECS task definitions based on actual usage
- Use IAM roles with least privilege access
- Implement S3 bucket policies to restrict access
- Enable encryption for S3 buckets
- Scan container images for vulnerabilities before deployment
- Use AWS Secrets Manager for sensitive information
I welcome contributions to improve the AWS CI/CD Pipeline project!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Ensure code follows the project's style guidelines
- Update documentation as needed
- Add tests for new features
- Make sure all tests pass
- AWS services configuration
- Application architecture
- Detailed deployment workflows
- Troubleshooting guides
- Implement automated testing in the CI/CD pipeline
- Add monitoring and alerting with AWS CloudWatch
- Create Infrastructure as Code templates (CloudFormation/Terraform)
- Add user authentication to the Todo List application
- Implement data persistence with AWS DynamoDB
Q: Can I use this pipeline for other applications?
A: Yes, the pipeline can be adapted for other web applications by modifying the buildspec files.
Q: How do I add custom domains to my deployed applications?
A: You can use AWS Route 53 and create A records pointing to your S3 website or Application Load Balancer.
Q: How much does it cost to run this infrastructure on AWS?
A: Costs depend on usage but include charges for CodeBuild minutes, S3 storage/requests, ECR storage, and ECS compute resources.
- Flask framework for the backend implementation
- AWS documentation for service integration guidance
- The open-source community for inspiration and best practices
For questions, suggestions, or collaborations, please reach out:
- GitHub: muhammadhamzagova666
- LinkedIn: muhammadhamzagova666