CodeDeploy 101
AWS CodeDeploy is an automated deployment service which allows you to deploy your application code automatically to EC2 instances, on-premise systems and Lambda functions.
- It allows you to quickly release new features, avoid downtime during application deployments, and avoid the risks associated with manual processes.
- Automatically scales with your infrastructure and integrates with various CI/CD tools, e.g. Jenkins, GitHub, Atlassian, AWS CodePipeline as well as config management tools like Ansible, Puppet, and Chef.
- Two Deployment approaches available: In-Place and Blue/Green
In-Place Deployment
- The application is stopped on each instance and the latest revision is installed
- The instance is out of service during this time and your capacity will be reduced
- If the instances are behind a load balancer, you can configure the load balancer to stop sending reqyests to the instances which are being upgraded
- In-place is also known as a Rolling Update
- It can only be used for EC2 and on-premise systems; it is not supported for Lambda
- If you need to roll back your changes, the previous version of the application will need to be re-deployed
Blue / Green Deployment
- Blue / green deployment - new instances are provisioned and the latest revision is installed on the new instances. Blue represents the active deployment, green is the new release.
- The new instances are registered with an Elastic Load Balancer, traffic is then routed to the new instances and the original instances are eventually terminated
- Advantages of a Blue/Green deployment are that the new instances can be created ahead of time and the code released to production by simply switching all traffic to the new servers.
- Switching back to the original environment is faster and more reliable and is just a case of routing the traffic back to the original servers (as long as you haven't already terminated them)