AWS CodeDeploy Popular2014年〜
A fully managed service that automates application deployments to EC2, Lambda, and ECS
What It Does
AWS CodeDeploy is a fully managed service that automates application deployments to EC2 instances, Lambda functions, and ECS services. It supports multiple deployment strategies including rolling, Blue/Green, and canary deployments, and can automatically roll back when issues are detected during deployment. When integrated with CodePipeline, you can build a complete CI/CD pipeline from code commit to deployment.
Use Cases
CodeDeploy is used across a wide range of deployment scenarios: rolling deployments to update applications across EC2 instance fleets, gradual Lambda function releases using traffic shifting, zero-downtime ECS service updates via Blue/Green deployments, application distribution to on-premises servers, and ensuring service stability through automatic rollback on deployment failures.
Everyday Analogy
Think of it like a professional moving company. Moving your belongings (application) to a new home (server) by yourself is hard work with a risk of things breaking along the way. Hiring a moving company (CodeDeploy) means your belongings are transported according to a plan, and if anything goes wrong, they can move everything back to the old place (rollback). Better yet, they can handle moves to multiple new homes at the same time.
What Is CodeDeploy?
AWS CodeDeploy is a service that automates the application deployment process. Manual deployments carry risks of human error and downtime, but CodeDeploy automates each step of the deployment, delivering a consistent and reliable release process. It supports three compute platforms - EC2, Lambda, and ECS - and provides optimized deployment methods for each.
Deployment Strategies
CodeDeploy offers multiple deployment strategies. In-Place deployment sequentially updates the application on existing instances. Blue/Green deployment creates a new set of instances, deploys the application to them, and then switches traffic over. For Lambda, canary deployment (gradually shifting traffic starting with a small percentage) and linear deployment (shifting traffic in equal increments) are also available. Each strategy allows you to fine-tune deployment settings such as timeouts and health check conditions.
Automatic Rollback and Monitoring
CodeDeploy includes the ability to detect issues during deployment and automatically roll back. By integrating with CloudWatch alarms, it can abort a deployment and revert to the previous version when error rates or latency exceed defined thresholds. Deployment progress can be monitored in real time through the console or API, and you can check the deployment status of each individual instance. Setting up SNS notifications lets you instantly share deployment successes or failures with your team. For reference materials on automatic rollback and monitoring, books on Amazon can also be helpful.
AppSpec File and Integrations
CodeDeploy's deployment behavior is defined in an AppSpec file (YAML or JSON). This file specifies file placement on the deployment target, lifecycle event hooks (BeforeInstall, AfterInstall, ApplicationStart, etc.), and permission settings. Lifecycle hooks can execute shell scripts, allowing you to automate custom pre- and post-deployment tasks such as database migrations and cache clearing.
Things to Watch Out For
- The CodeDeploy agent must be installed on each EC2 instance, and agent update management is part of your operational tasks
- Blue/Green deployments temporarily run both old and new instance sets, so be aware that costs increase temporarily during deployment