This project demonstrates the implementation of a complete Continuous Integration and Continuous Deployment (CI/CD) pipeline using AWS services. The pipeline automates the software delivery process from code commit to production deployment, ensuring faster, more reliable, and consistent deployments.
- π Automated Build Process - Seamless code compilation and testing
- π Continuous Deployment - Automatic application deployment to target environments
- π GitHub Integration - Direct integration with GitHub repositories
- π Pipeline Monitoring - Real-time tracking of deployment status
- π‘οΈ Secure Deployment - IAM roles and policies for secure operations
- AWS CodeBuild - Automated build and testing
- AWS CodeDeploy - Application deployment automation
- AWS CodePipeline - End-to-end pipeline orchestration
- GitHub - Source code repository
This CI/CD pipeline consists of four main components that work together to automate the software delivery process:
- Source Stage - Code repository (GitHub)
- Build Stage - Code compilation and testing (CodeBuild)
- Deploy Stage - Application deployment (CodeDeploy)
- Pipeline Orchestration - Workflow management (CodePipeline)
For this CI/CD project, I have created a GitHub repository that implements a comprehensive continuous integration and continuous deployment pipeline.
https://github.com/AbhayGhante/aws-cicd-pipeline
Ensure the repository contains all essential configuration files including
buildspec.yml (Required for Build Stage) β¬οΈ
version: 0.2
env: # setup in aws-secrets-manager
parameter-store:
DOCKER_REGISTRY_USERNAME: /project/docker-credentials/username
DOCKER_REGISTRY_PASSWORD: /project/docker-credentials/password
DOCKER_REGISTRY_URL: /project/docker-credentials/url
phases:
install:
runtime-versions:
python: 3.10
pre_build:
commands:
- echo "Installing dependencies..."
- pip install -r requirements.txt
build:
commands:
- echo "docker logging"
- echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
- echo "docker build"
- docker build -t "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/flask-app:latest" .
- echo "build completed now pushing image to DOCKER_REGISTRY_URL"
- docker push "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/flask-app:latest"
post_build:
commands:
- echo "Build completed successfully!"
artifacts:
files:
- "scripts/*"
- "appspec.yml"
base-directory: .& Appspec.yml (Required for Deploy Stage) β¬οΈ
version: 0.0
os: linux
hooks:
ApplicationStop:
- location: /scripts/stop_container.sh # to delete the running container
timeout: 300
runas: root
AfterInstall:
- location: /scripts/start_container.sh # to run new container
timeout: 300
runas: rootNavigate to the CodeBuild dashboard and click on Create Project.
Provide a meaningful project name and select GitHub as the source provider since we're using GitHub repository instead of AWS CodeCommit.
Configure the appropriate environment settings and specify the buildspec.yml file name that exists in your GitHub repository. Click Create Build Project to proceed.
Click Start Build to verify that the build process executes correctly and all configurations are properly set.
After this stage, the Docker image is built and then pushed to the registry for storage and deployment
Note: This completes the Continuous Integration (CI) portion of the pipeline.
Navigate to the CodeDeploy dashboard and click Create Application.
After successfully creating the application, click Create Deployment Group.
Provide an appropriate name for the deployment group, select the proper service role, choose deployment type, configure environment settings, and click Create Deployment Group.
After creating the deployment group, create a new deployment with an appropriate name, select the GitHub option, and click Create Deployment.
The
appspec.ymlfile present in your GitHub repository is used by CodeDeploy during the deployment process
Note: This completes the Continuous Deployment (CD) portion of the pipeline.
Navigate to the CodePipeline dashboard and click Create Pipeline.
Follow these sequential steps to configure your pipeline:
Step 1: Choose Creation Option Select Build Custom Pipeline for maximum flexibility.
Step 2: Configure Pipeline Settings Provide a descriptive pipeline name and select the appropriate service role.
Step 3: Add Source Stage Select the source provider (GitHub), specify your repository name, and choose the target branch.
Step 4: Add Build Stage Select the build provider (CodeBuild) and specify your project name created in the previous steps.
Step 5: Add Deploy Stage Select the deploy provider (CodeDeploy), specify the application name and deployment group created earlier, then click Create Pipeline.
- Code Push β Developer pushes code to GitHub repository
- Trigger β Pipeline automatically detects changes
- Build β CodeBuild compiles and tests the application
- Deploy β CodeDeploy deploys the application to target environment
- Monitor β Pipeline status and logs are available in real-time
- π Always include comprehensive
buildspec.ymlconfiguration - π Use least-privilege IAM roles and policies
- π§ͺ Test your pipeline with small changes before major deployments
- π Monitor pipeline execution logs for troubleshooting
- π Implement proper rollback strategies
Common issues and solutions:
- Build Failures: Check
buildspec.ymlsyntax and environment configurations - Deployment Errors: Verify IAM roles and target environment accessibility
- Pipeline Stuck: Review service roles and permissions
Feel free to contribute to this project by submitting issues or pull requests.