AWS, DevOps

AWS has a mature ecosystem of tools and services that support DevOps workflows in organisations of all sizes. One of the key services that AWS offers with DevOps in mind is CodeDeploy. In this post, we’ll look at how CodeDeploy works, and why it deserves a place in your DevOps toolkit.

Why CodeDeploy

Deployments break things. Missing files, incorrect access settings, insufficient server resources, and manual configuration of infrastructure make deployment a nightmare for DevOps teams. These teams have quite likely adopted CI to automate their builds and tests, but haven’t figured out the CD part of the DevOps pipeline.

AWS CodeDeploy coordinates application deployments to Amazon EC2 instances, on-premises instances, or both - making it easier for you to rapidly release new features, eliminate downtime during deployment, and avoid the need for error-prone, manual operations.

If you’re on the fence about adopting continuous delivery because of the complexity of it all, and the high stakes, then CodeDeploy is built for you.

How CodeDeploy works

Here’s a really simplified version of how CodeDeploy works:

How AWS CodeDeploy Doubles Down on DevOps_2.png

Source: enokawa.co

It starts with uploading your code, its dependencies, packages, and other artefacts along with an AppSpec file from your local machine to an S3 bucket, GitHub, or BitBucket. This compressed file is called a “Revision”. CodeDeploy spots that there’s been a new revision, and it automatically deploys the latest revision on a group of EC2 instances or an auto scaling group. In this way, CodeDeploy does one thing and does it well—deployment.

The AppSpec file is a critical part of CodeDeploy. It is a YAML file that contains details about four components—OS, files, permissions, and hooks. It tells the CodeDeploy “Agent” which files to deploy, and which scripts to execute in what order. Every EC2 instance must contain an Agent that reads the data in the AppSpec file and executes the deployment accordingly.

Let’s look at the unique features of CodeDeploy that make it an indispensable part of DevOps teams, particularly an AWS shop.

Automates deployment

CodeDeploy can be configured to automate every step of the deployment process after you upload your revision. It can automatically deploy as a revision as soon as it is uploaded, send you alerts on the status of a deployment, and even automatically roll back to a previous version if the deployment fails. This requires some planning and configuring before your first deployment, but it saves you a lot of time as you start to deploy more frequently, and on numerous EC2 instances with varying configurations. CodeDeploy lets you finally adopt continuous delivery.

Enables high availability

With the automatic rollback feature, CodeDeploy ensures your app is highly available even when things go wrong (which they will). You can troubleshoot errors using CloudWatch metrics and CloudTrail logs, which are well integrated with CodeDeploy, and redeploy easily when your next revision is ready. This makes deployments more predictable, and improves the user experience.

Deeply integrated with AWS services

If you’re an AWS dev shop, you probably already take advantage of all the complementary services that come along with EC2 instances. These include services like CodePipeline to visually manage your development lifecycle, CloudWatch for metrics, CloudFormation to create and configure instances, SNS for alerts and notifications, CloudTrail for logs, and many more. It’s no surprise that CodeDeploy seamlessly integrates with all these services, giving you a consistent experience across AWS.

Integrates with your favourite tools

It’s a given that your DevOps toolset is not confined to just AWS. You probably take a best-of- breed approach to DevOps with tools like GitHub, Jenkins, CircleCI, Chef, Puppet, New Relic, and more. CodeDeploy integrates with these tools, and can easily blend into your workflow no matter what your toolset looks like. This goes a long way in driving CodeDeploy adoption. 

Supports hybrid infrastructure

You’ll mostly use CodeDeploy to deploy your app on EC2 instances. However, if you’re a large enterprise, it’s likely you deal with a hybrid infrastructure. In this case, CodeDeploy is still useful as it can deploy to on-prem instances just as well. All it needs is the CodeDeploy agent to be installed on every instance in your data centre.

It’s free

The best part about CodeDeploy is that it’s free—well, almost. Deploying to on-premises instances does have a charge. However, if you deploy to EC2 instances, you only pay for the instances you use, and not for CodeDeploy. Remember that if you use other AWS services like storing deployment logs in an S3 bucket, or sharing data via a Lambda function, those services include a separate cost, but the CodeDeploy service itself doesn’t cost a dime. This makes it a no brainer to try out even if you’re on the fence about it.

As mentioned at the start, making the move to DevOps starts with putting in place a CI process to automate builds and testing. However, many organisations don’t progress to adopting CD as well. They assume CD is only for the biggest tech companies with large teams, defined processes, and modern toolsets. With CodeDeploy, AWS gives any team considering the move to DevOps the confidence to go all-in. CodeDeploy simplifies deployment, making it automated, highly scalable, predictable, and almost free.

Looking to build a continuous delivery pipeline in AWS? We’ve built an automated framework for accelerating DevOps and Continuous Delivery on Amazon Web Services.

It is a lightweight solution for rapidly and repeatedly building cloud-based environments and CI/CD pipelines in a way that incorporates all best practices for agility, operability, and security. Check out our introductory blog post and demo!

Read more about Continuum here: http://blog.contino.io/introducing-continuum-our-automation-framework-for-accelerating-devops-in-aws

  • Benjamin Wootton

    Co-Founder and CTO

    Benjamin Wootton is the Co-Founder and CTO, EMEA of Contino. He has worked with tens of enterprise organisations on DevOps transformation and is a hands-on DevOps engineer with expertise in cloud and containers.

    More Articles by Benjamin