2022 Gartner® Magic Quadrant™ SIEM
Get the reportMore
Continuous Delivery (CD) is a critical component of DevOps that can’t be overlooked. As you make the transition to CD, you need the right mindset, and the right tools. One tool that is indispensable if you host your apps in AWS is CodeDeploy. In this article, we look at why you would want to use a tool like AWS CodeDeploy, and how it doubles down on Continuous Delivery.
DevOps includes two key processes—Continuous Integration, (CI) and Continuous Delivery. In a rush to get on the DevOps bandwagon, some organizations set up a Git repository and a Jenkins server and call it DevOps. While this approach may improve their development to some extent, their releases are still chaotic, because Git and Jenkins do not fully automate the release process.
To complete your transition to DevOps, continuous builds and tests are not enough. You need to go the last mile and continuously deploy, too. Continuous Delivery is the method of releasing an app in short cycles, up to multiple times a day. This requires building and testing code so that it’s release-ready from the start.
Here are the main benefits of CD:
Discover how the Sumo Logic platform empowers DevOps teams for continuous delivery, no matter what the future brings.
When managing infrastructure on the AWS cloud, you have control over your EC2 instances so you can configure your storage, databases, and networking, depending on your workload. Every app runs on multiple EC2 instances. Deploying code to each of them individually can require a lot of time. As your app scales, this can be a bottleneck. Knowing this, AWS launched CodeDeploy way back in 2014.
AWS CodeDeploy deploys application code from AWS S3, GitHub, or BitBucket to EC2 instances or on-prem instances. If you aren’t yet on AWS and instead manage your infrastructure using a private cloud, CodeDeploy can even deploy to your on-premises servers. With hybrid infrastructure becoming the norm for many large implementations, this is a necessary feature for a cloud deployment tool.
CodeDeploy is powerful enough to deploy code across numerous hosts with varying configurations.
You can deploy your code in two ways with CodeDeploy.
Let’s examine how CodeDeploy handles deployments. Here’s what the entire process looks like:
Before you can start the deployment, you need to create an IAM user (if you don’t have one already) and ensure each of the components (your repositories, EC2 instances, and CodeDeploy) have access to each other.
There are two ways to deploy your app using CodeDeploy—either from the CodeDeploy console or from the AWS CLI. Whichever you choose, you’ll follow these steps to deploy your app:
This is the first step to decide how many EC2 instances your app needs, and launch them. You can either do this manually, or through an AWS CloudFormation template which makes it easy to create instances quickly. The instances must be tagged or belong to an auto scaling group so that CodeDeploy knows where to deploy your code.
Tags are used by other AWS services to identify instances. You can specify any combination of key-value pair, but be sure to use the correct one in your AppSpec file, or your deployment will not execute.
The instances must have the CodeDeploy agent installed and running inside each of them.
At this step, you create an empty root folder on your development machine where you store the text files, binaries, and packages that make up your app. Next, you need to create the AppSpec file in the same folder. You can use a template to include information about your code. You can include file names and their destinations, permissions as needed, and “Hooks” that inform CodeDeploy which scripts to run in what order during a deployment. You bundle all these files to form your first revision.
Once your revision is ready, you upload it to S3, GitHub, or BitBucket. From here, the CodeDeploy agent reads the AppSpec file—and from the “Hooks” section of the AppSpec file, understands which scripts should be run on the EC2 instances.
CodeDeploy automatically deploys your app every time you upload a revision. It lets you define how you’d like your app to be deployed. You can deploy your app on one instance at a time, on just half the instances first and the second half later, or on all instances at one time. For large clusters, you may want to opt for a phased-out deployment, and for smaller deployments, you can deploy all at once.
Once deployed, you can monitor your deployment using AWS CloudWatch, which integrates with CodeDeploy. Ensure you’ve set the appropriate IAM access permissions for CloudWatch to track CodeDeploy events.
If your deployment fails, you can set CodeDeploy to automatically rollback to the previous revision. This is critical to ensuring uptime despite deployment errors. You can then troubleshoot errors, and redeploy the revision when it’s fixed.
AWS is the most mature public cloud vendor. It has integrations with every possible IT vendor, and cloud services to meet every niche requirement. CodeDeploy is equally well integrated with other DevOps tools.
It has integrations with third-party tools that manage the workflow across the entire development lifecycle. This includes tools like:
While configuration management tools focus on provisioning and managing instances, CodeDeploy focuses exclusively on deploying code to EC2 instances once created. With these integrations, AWS has made it easy for CodeDeploy to be added to your development stack, no matter what mix of tools you use across your development pipeline.
CodeDeploy assigns a health status to every revision and EC2 instance. The revision status can be either “current,” “old,” or “unknown.” A “current” revision is when the revision on the EC2 instance matches the most recent revision in S3, GitHub, or BitBucket. “Old” revisions are when a revision on an instance matches an older revision in S3, GitHub, or BitBucket. “Unknown” is when there isn’t a match.
[Learn More: AWS Monitoring]
Similarly, for EC2 instances, CodeDeploy assigns a status of “healthy” or “unhealthy.” If a deployment is successful, the status is healthy, but if a deployment fails, the instance gets a status of “unhealthy.”
Using these checks, you can set rules to deploy revisions only if there are a minimum number of healthy EC2 instances. This ensures your deployment doesn’t break even more instances.
You can set up alerts for your failed deployments using AWS SNS (Simple Notification Service) via CloudWatch alarms. Stopped or failed deployments can be monitored by looking at the CodeDeploy logs. These logs are stored for seven days by default. You could do basic searching and filtering of your logs from inside CloudWatch.
CodeDeploy is an essential tool for AWS dev shops that are making the move to Continuous Delivery. Whether you perform in-place or blue-green deployments, or host your app exclusively in AWS’ public cloud or in a hybrid environment, with the need to integrate with other DevOps tools, CodeDeploy has you covered. It is invaluable to DevOps teams that want to speed up application delivery and not compromise on high availability.
Build, run, and secure modern applications and cloud infrastructures.Start free trial
The Amazon Web Services (AWS) Marketplace offers a large variety of commercial and open source offerings to augment software configuration and release within the AWS ecosystem. Sumo Logic's AWS Marketscape looks at the pros and cons of the most common configuration and release solutions from the Marketplace.