Imagine Yashvi and Mishi are new joiners at an e-commerce company. They are part of a team developing new features for the online store.
Continuous Delivery (CD) means that every change to the website's code should be automatically tested and ready to be released to real customers quickly and safely.
- Small Changes, Big Impact:
Yashvi works on a new feature: "Personalized Product Recommendations." Instead of writing a massive chunk of code, she breaks it down into smaller, manageable pieces and commits them to AWS CodeCommit, the company's secure Git-based repository.
Mishi writes automated tests for each small piece of Yashvi's code to ensure it works as expected. These tests are also stored in CodeCommit.
- Building and Testing:
AWS CodePipeline triggers when Yashvi pushes code to CodeCommit. This initiates the CI/CD pipeline.
AWS CodeBuild automatically builds the code, runs the tests written by Mishi, and packages the application into a deployable format (e.g., a Docker image).
If the build and tests are successful, CodePipeline proceeds to the next stage.
- Testing in a Safe Environment:
AWS CodeDeploy deploys the new code to a staging environment in Amazon Elastic Beanstalk or Amazon ECS. This staging environment is a replica of the production environment where customers don't interact.
Yashvi and Mishi, along with other testers, can thoroughly test the new feature in this safe environment before releasing it to the public.
- Releasing to Customers:
If the feature passes all tests in the staging environment, CodePipeline automatically promotes the deployment to the production environment.
The company might use techniques like Canary Releases within CodeDeploy to gradually roll out the new feature to a small group of customers first, monitoring for any issues before releasing it to everyone.
- Utilizing AWS Services:
Amazon ECR (Elastic Container Registry): If the application is containerized (using Docker), CodeBuild creates and pushes the Docker images to ECR. CodeDeploy then pulls the images from ECR for deployment.
AWS CloudWatch: CloudWatch monitors the application's performance and health in both staging and production environments. It can send alerts if any issues arise.
AWS Lambda: If parts of the application are serverless functions, Lambda can be used to execute those functions within the CD pipeline.
Benefits for Yashvi and Mishi:
Faster Feedback: They get immediate feedback on their code changes through the automated pipeline, allowing them to quickly identify and fix any problems.
Reduced Stress: They don't have to worry about manual deployments and the potential for errors. The AWS services handle the deployment process reliably.
Improved Quality: Automated testing and continuous monitoring help ensure that the website remains stable and reliable.
Increased Productivity: The streamlined CD process allows Yashvi and Mishi to focus on developing new features and improving the customer experience.
Further Yashvi and Mishi, demonstrating the practical application of AWS services within a real-world scenario give level 1 tasks to new interns in AWS Ops Team will be covered in next blog.
GIST
Continuous Delivery (CD) is a software development practice to automate and streamline code deployment process during changes applied to production.
-
code changes are always in a deployable state, that allow dev teams to release updates frequently and reliably.
-
- Speed: Faster delivery of features and bug fixes.
- Reliability: Consistent and predictable deployments.
- Reduced Risk: Smaller, incremental changes minimize the chance of breaking things.
- Feedback Loop: Frequent releases enable faster user feedback.
- Example: Imagine how for e-commerce website we used AWS CI CD where new product features are continuously deployed without disrupting the shopping experience.
-
-
Code Changes:
- Smaller Commits: Break down changes into smaller, manageable pieces.
- Automated Tests: Write unit tests, integration tests, and end-to-end tests.
-
Version Control: Use Git or other version control systems.
- Example: A developer commits a small feature enhancement, and automated tests validate it.
-
Architecting for Continuous Delivery:
- Microservices: Decouple components to deploy independently.
- Containerization: Use Docker or Kubernetes for consistent deployment.
- Infrastructure as Code (IaC): Define infrastructure using tools like Terraform / AWS CloudFormation.
- Example: An application split into microservices, each with its own deployment pipeline.
Backend, Frontend , Webhook and Admin app separate services.
-
Mutable vs. Immutable Servers:
-
Mutable Servers:
- Pros: Easy to modify in-place.
- Cons: Accumulate configuration drift, harder to reproduce.
-
Immutable Servers:
- Pros: Always reproducible, no drift.
- Cons: Requires replacing instances instead of modifying them.
- Example: Immutable servers created from predefined images (e.g., Amazon Machine Images).
-
Mutable Servers:
-
Deployment Methods:
- Blue-Green Deployment: Spin up a new environment (green) alongside the existing one (blue), then switch traffic.
- Canary Deployment: Gradually route a subset of users to the new version.
- Feature Flags: Enable/disable features dynamically.
- Example: A blue-green deployment ensures zero downtime during updates.
-
Continuous Delivery Tools:
- CI/CD Pipelines: Tools like Jenkins, GitLab CI/CD, or Azure DevOps automate builds, tests, and deployments.
- Container Orchestration: Kubernetes manages containerized applications.
- Configuration Management: Ansible, Puppet, or Chef for server configuration.
- Example: Jenkins pipeline triggers automated tests and deploys to production.
-
Putting it All Together:
-
Workflow:
- Developers commit code.
- CI/CD pipeline builds, tests, and packages the application.
- Deploy to staging for further testing.
- If successful, promote to production.
-
Workflow:
AWS CodeStar is an Amazon Web Service that allows you to quickly develop, build, and deploy applications on AWS.
- Developers commit code to either CodeCommit (AWS’s Git-based repository) or GitHub.
- The CI/CD pipeline starts with CodeBuild, which compiles, tests, and packages the application.
- The packaged application is deployed to staging using CodeDeploy.
- If successful, the code is promoted to production via CodePipeline.
If your application uses containers, integrate with Docker and store Docker images in Amazon ECR.
-
Developers Commit Code:
- AWS CodeCommit: A fully-managed source control service that hosts secure Git-based repositories. You can create a repository in CodeCommit to store your application and deployment code¹.
- GitHub: While not an AWS service, GitHub is widely used for version control. You can integrate your CodeStar project with GitHub repositories as well.
-
CI/CD Pipeline Builds, Tests, and Packages the Application:
- AWS CodeBuild: A fully managed continuous integration service that compiles source code, runs tests, and produces software packages ready for deployment. CodeBuild builds and tests your code, preparing it for deployment⁶.
- Docker: If your application uses containers, you can integrate Docker with CodeBuild to build and package your application into Docker images.
-
Deploy to Staging for Further Testing:
- AWS CodeDeploy: A fully managed deployment service that automates software deployments to various compute services (e.g., Amazon EC2, AWS Fargate, AWS Lambda). CodeDeploy ensures consistent and reliable deployments⁶.
- Amazon Elastic Beanstalk (EBS): If you're using EBS for your application, CodeDeploy can deploy your code to Elastic Beanstalk environments.
- Amazon ECS (Elastic Container Service): For containerized applications, ECS is a great choice. CodeDeploy can deploy your Docker containers to ECS clusters.
-
Promote to Production:
- AWS CodePipeline: A fully managed continuous delivery service that automates release pipelines. CodePipeline orchestrates the entire workflow, fetching code from CodeCommit, building with CodeBuild, and deploying with CodeDeploy. You can set up different stages (e.g., staging, production) in your pipeline⁶.
- Amazon ECR (Elastic Container Registry): If you're using Docker, ECR is a managed Docker registry where you can store and manage Docker images. CodePipeline can integrate with ECR for container image deployment.
Remember that AWS CodeStar streamlines the setup of these services, making it easier to create your entire CI/CD pipeline. You can choose from various templates (e.g., Amazon EC2, AWS Lambda, AWS Elastic Beanstalk) and select your preferred source control (CodeCommit or GitHub). Once configured, your pipeline will automate the entire process from development to production, ensuring efficient and reliable deployments.
- Example: DevOps Developer team follows this process for every code change, ensuring a smooth CD pipeline.
Remember, CD is about continuous improvement.
Teams iterate, learn, and adapt their processes to achieve faster, safer releases. 🚀
References:
(1) Continuous Delivery Toolchain - AWS CodeStar - AWS. https://aws.amazon.com/codestar/.
(2) Complete CI/CD with AWS CodeCommit, AWS CodeBuild, AWS CodeDeploy, and .... https://aws.amazon.com/blogs/devops/complete-ci-cd-with-aws-codecommit-aws-codebuild-aws-codedeploy-and-aws-codepipeline/.
(3) Deploy a React app with CodeStar - Medium. https://medium.com/@tenhold/deploy-a-react-app-with-codestar-e4f1162cf4bc.
(4) Use CodeStar to Develop and Deploy Apps on AWS - CloudHesive. https://www.cloudhesive.com/blog-posts/use-codestar-develop-deploy-apps-aws/.
(5) New- Introducing AWS CodeStar – Quickly Develop, Build, and Deploy .... https://aws.amazon.com/blogs/aws/new-aws-codestar/.
(6) Setting up CI/CD in AWS with CodeCommit, CodeDeploy, CodePipeline, ECR .... https://dev.to/aws-builders/setting-up-cicd-in-aws-with-codecommit-codedeploy-codepipeline-ecr-and-ecs-5g6b.
(7) AWS CI/CD Pipeline Creation - Step by Step - DEV Community. https://dev.to/aws-builders/aws-cicd-pipeline-creation-step-by-step-3cca.
(8) A Step by Step Guide to Create a CI/CD Pipeline with AWS Services. https://www.analyticsvidhya.com/blog/2021/07/a-step-by-step-guide-to-create-a-ci-cd-pipeline-with-aws-services/.