AWS CodeDeploy
Cloud service · AWS · Updated

AWS CodeDeploy

In short

AWS CodeDeploy is a fully managed deployment service that automates software deployments to a variety of compute services such as Amazon EC2, Amazon ECS, AWS Lambda, and your on-premises servers.

Cloud Services Hub →

7 key features of AWS CodeDeploy

AWS CodeDeploy is a fully managed deployment service that automates software deployments to various compute services such as Amazon EC2 and on-premises servers, offering features like automated rollbacks, centralized control, scalability, and customizable deployment configurations.

01
Automated Deployments

AWS CodeDeploy automates code deployments to any instance, including Amazon EC2 instances and on-premises servers, allowing you to rapidly release new features.

02
Centralized Control

Manage and configure your deployments from a central location, giving you the ability to track the progress of your deployments across your application.

03
Scalability

Designed to scale with your deployment needs, AWS CodeDeploy can handle deployments to a single instance or thousands of instances across the globe.

04
Rollbacks

In case of deployment issues, AWS CodeDeploy supports automatic or manual rollbacks to quickly revert to a previous stable version of your application.

05
Deployment Configurations

Customize your deployment strategies with deployment configurations, including canary, linear, and all-at-once deployments, to meet specific business, regulatory, or technical requirements.

06
Instance Deployment Groups

An EC2/On-Premises deployment group can target individually tagged instances, instances in Amazon EC2 Auto Scaling groups, or both.

07
Repository Deployment Sources

CodeDeploy can deploy server-based application content stored in GitHub or Bitbucket repositories.

Where AWS CodeDeploy is used

AWS CodeDeploy use cases revolve around automating deployment processes across various environments including EC2, Lambda, and on-premises servers, supporting strategies like high-availability, blue/green deployments, and integration with CI/CD pipelines for both traditional and serverless applications.

  1. 01
    Automated Deployment to AWS EC2 Instances

    AWS CodeDeploy automates code deployments to any number of EC2 instances, simplifying the process of releasing new features and ensuring that the application deployment process is repeatable and scalable. This use case involves automatically deploying application updates across a fleet of EC2 instances without downtime, ensuring a consistent and reliable deployment process.

  2. 02
    High-Availability Deployments

    Leverage AWS CodeDeploy to update applications deployed across availability zones while minimizing downtime. Deployments operate within a single AWS Region; multi-Region rollouts require defining the application in each target Region, copying the application bundle to an S3 bucket in each Region, and starting deployments serially or in parallel.

  3. 03
    Blue/Green Deployments

    AWS CodeDeploy supports blue/green deployment methodologies, allowing developers to release new versions of applications alongside the old version and seamlessly switch traffic. This can drastically reduce downtime and the risk associated with deploying new versions, providing an efficient method for quickly rolling back if issues arise.

  4. 04
    Integration with Continuous Integration/Continuous Deployment Pipelines

    CodeDeploy can be integrated into CI/CD pipelines to automate the deployment phase in the software development lifecycle. This deployment can trigger automatically after a successful build/test phase, ensuring that the software is continuously delivered to production environments or staging with minimal human intervention.

  5. 05
    Serverless Deployments

    AWS CodeDeploy now also supports deployments to AWS Lambda. This allows developers to automatically shift traffic between already-published Lambda function versions, enabling serverless applications to be updated with new code or configurations without managing servers.

How AWS CodeDeploy is priced

AWS CodeDeploy pricing is based on the Pay-As-You-Go model for the AWS resources used, and there is a Free Tier available for new accounts.

Pay-As-You-Go

There is no additional CodeDeploy charge for deployments to Amazon EC2, AWS Lambda, or Amazon ECS. Users still pay for other AWS resources used to store and run their applications.

On-Premises Instance Updates

CodeDeploy charges $0.02 per on-premises instance update.

Services AWS CodeDeploy works with

Amazon S3Amazon S3

CodeDeploy can fetch applications, deployment scripts, and resources stored in S3 buckets.

AWS LambdaAWS Lambda

CodeDeploy supports updating Lambda function versions and has the ability to shift traffic to new versions gradually.

Amazon EC2Amazon EC2

CodeDeploy deploys applications to EC2 instances with support for both in-place and blue/green deployment methods.

Amazon CloudWatchAmazon CloudWatch

CodeDeploy can monitor CloudWatch alarms during deployments and stop a deployment when an alarm enters the alarm state, with automatic rollback if configured. You can also send CodeDeploy agent logs to CloudWatch Logs for centralized troubleshooting.

Amazon DevOps GuruAmazon DevOps Guru

CodeDeploy deployment events appear in DevOps Guru's operational analysis, helping correlate application releases with anomalous behavior. This helps identify whether a recent deployment contributed to an operational issue.

Amazon EC2 Auto ScalingAmazon EC2 Auto Scaling

CodeDeploy automatically deploys application revisions to instances launched in an associated EC2 Auto Scaling group. It uses lifecycle hooks to coordinate deployments with instance launches and can run termination deployments during scale-in.

Amazon Elastic Container Service (Amazon ECS)Amazon Elastic Container Service (Amazon ECS)

CodeDeploy performs blue/green deployments for ECS services configured with the CodeDeploy deployment controller. It creates a replacement task set and shifts load balancer traffic to it, with optional validation hooks and automatic rollback.

Amazon EventBridgeAmazon EventBridge

CodeDeploy sends deployment and instance state-change events to EventBridge. Rules can route these events to targets that notify operators or automate responses to successful, failed, or stopped deployments.

Amazon Simple Notification Service (Amazon SNS)Amazon Simple Notification Service (Amazon SNS)

CodeDeploy deployment-group triggers publish notifications to SNS topics when selected deployment or instance lifecycle events occur. Subscribers can receive notifications when a deployment fails or requires attention.

AWS ChatbotAWS Chatbot

CodeDeploy notification rules can deliver deployment notifications to AWS Chatbot clients in supported chat channels. Teams can receive deployment failures and other selected events directly in their collaboration workspace.

What is AWS CodeDeploy

3 min read

AWS CodeDeploy is a fully managed deployment service provided by Amazon Web Services (AWS) that automates the deployment of software applications to various computing services such as Amazon EC2, Amazon ECS, AWS Lambda, and your on-premises servers. This service simplifies the process of rapidly releasing new features, helps avoid downtime during application deployment, and handles the complexity of updating your applications, allowing you to rapidly release new features. 

The essence of AWS CodeDeploy lies in its capability to automate the entire deployment process. Before the advent of continuous integration and continuous deployment (CI/CD) pipelines, deploying applications could be a cumbersome and error-prone process, often requiring manual steps that could lead to inconsistent configurations or deployment failures. 

CodeDeploy eliminates this friction by automating deployments, making them repeatable, predictable, and scalable. For instance deployments, CodeDeploy uses a YAML AppSpec file in the root directory of the revision to specify the files to copy and scripts to execute. This file specifies the deployment actions you want AWS CodeDeploy to execute. For example, it can specify the scripts to be run at various stages of the deployment process, such as installation, application stop, application start, and validation checks. Lambda deployment groups specify how to route traffic to a new function version. Amazon ECS deployment groups specify the ECS service, load balancer, and listener used to reroute production traffic to an updated containerized application. 

One of the key benefits of using AWS CodeDeploy is the ability to maintain application availability during the deployment process. CodeDeploy offers several deployment strategies, including in-place and blue/green deployments. In-place deployments, also called rolling updates, replace the current version of the application on each host with the latest version, with deployment concurrency controlled by the deployment configuration rather than always updating one host at a time, which can be useful for applications that can tolerate brief downtime. Blue/green deployments, on the other hand, redirect traffic from the current version of the application to a completely separate set of instances running the new version, which can drastically reduce downtime and risk by allowing a quick rollback if needed.

A deployment group can have only one concurrent deployment; this limit cannot be increased.

The EC2/On-Premises in-place deployment runtime limit is 12 hours for predefined deployment configurations and custom configurations created in June 2023 or later; custom configurations created before June 2023 retain an 8-hour limit.

Furthermore, AWS CodeDeploy integrates seamlessly with other AWS services and third-party tools, enhancing its utility in CI/CD pipelines. For instance, developers can integrate CodeDeploy with AWS CodePipeline to automate the entire software release process, from code commit through build, test, and deployment. 

Additionally, AWS CloudWatch can be used for monitoring deployments and alerting on failures, while AWS Identity and Access Management (IAM) ensures that deployments are secure and only authorized personnel can execute deployments.

In conclusion, AWS CodeDeploy represents an essential service for developers and businesses looking to streamline their deployment processes. By automating deployments, ensuring high availability, and providing flexible deployment strategies, CodeDeploy facilitates a more reliable, scalable, and efficient software deployment process, enabling teams to focus more on development and less on the logistics of releasing new updates.

Concepts related to AWS CodeDeploy

AWS CodeDeploy exam questions

Real practice exam questions on AWS CodeDeploy, with the correct answer and its explanation. Answer them with every option in the exam simulator.

MLA-C02

An ML team deploys a Python inference application and its model files to Amazon EC2 instances by using AWS CodeDeploy. A CI/CD pipeline successfully uploads each revision bundle to an Amazon S3 bucket and creates a deployment. However, deployments fail during DownloadBundle, before any AppSpec lifecycle scripts run. The CodeDeploy agent is running on every instance, and its logs show an S3 AccessDenied error when downloading the revision bundle. The bucket uses SSE-S3 encryption. Network connectivity is working, and no bucket policies, service control policies, or other explicit denies restrict access.

Which change should the ML engineer make to allow the instances to download revisions with the least privilege?

Show answerCORRECT ANSWER

Grant the IAM role in the EC2 instances' instance profile s3:GetObject permission on the S3 object prefix containing the revision bundles.

The CodeDeploy agent uses the EC2 instance profile's credentials to retrieve revision bundles from S3. Granting that role read access to only the revision prefix resolves the download failure without granting unnecessary access. SSE-S3 does not require additional AWS KMS permissions.

SAP-C03

A company deploys an Amazon ECS service on AWS Fargate behind an Application Load Balancer by using AWS CodeDeploy blue/green deployments. The deployment group already monitors application error-rate alarms and automatically rolls back when an alarm enters ALARM. The original task set remains available throughout traffic shifting.

The company's release policy now requires production traffic to move to the replacement task set in equal increments of 20 percentage points, with 3 minutes between successive increases, until the replacement receives all production traffic. The pipeline must use managed traffic shifting without scripts that modify listener weights.

Which change should a solutions architect make?

Show answerCORRECT ANSWER

Create a custom CodeDeploy deployment configuration for the ECS compute platform with linearPercentage set to 20 and linearInterval set to 3. Configure the deployment group to use this configuration.

CodeDeploy supports custom linear deployment configurations for Amazon ECS. These settings increase the replacement task set's traffic share by 20 percentage points at 3-minute intervals. The deployment group's existing alarm monitoring and automatic rollback settings remain applicable.

SOA-C03

A company runs an HTTP application as an Amazon ECS service on AWS Fargate. The service uses the CODE_DEPLOY deployment controller and a Network Load Balancer with two target groups. Releases currently shift all production traffic to the replacement task set at once.

The company now requires each release to shift approximately 10% of production traffic to the replacement task set every minute until the replacement receives all traffic. The existing task set must serve the remaining traffic during the transition. The company can replace the load balancer and must use managed deployment capabilities without custom traffic-routing automation.

Which solution meets these requirements?

Show answerCORRECT ANSWER

Replace the Network Load Balancer with an Application Load Balancer. Configure the CodeDeploy deployment group with its production listener, two target groups, and a linear deployment configuration that shifts 10% of traffic every minute.

CodeDeploy supports linear traffic shifting for ECS blue/green deployments behind an Application Load Balancer. The two target groups serve the original and replacement task sets, and CodeDeploy adjusts production traffic in the configured increments while the original task set serves the remainder.

Practice AWS CodeDeploy in a full exam

Questions on AWS CodeDeploy in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

Learn AWS CodeDeploy in lessons

16 short lessons on AWS CodeDeploy in 6 certification courses.

and 10 more lessons

Open the lessons

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.