Brief Notes on AWS CodeDeploy
Tags: aws, devops, cicd
Published: 2024-03-21 19:04:04

Service that automates code deployments to any instance, including Amazon EC2 instances and instances running on-premises.

## Supported Platforms/Deployment Types:

- EC2/On-Premises: In-Place or Blue/Green Deployments
  - Describes instances of physical servers that can be Amazon EC2 cloud instances, on-premises servers, or both. Applications created using the EC2/On-Premises compute platform can be composed of executable files, configuration files, images, and more. o   -   - Deployments that use the EC2/On-Premises compute platform manage the way in which traffic is directed to instances by using an in-place or blue/green deployment type.

- AWS Lambda: Canary, Linear, All-At-Once Deployments
  - Applications created using the AWS Lambda compute platform can manage the way in which traffic is directed to the updated Lambda function versions during a deployment by choosing a canary, linear, or all-at-once configuration.

- Amazon ECS: Blue/Green Deployment
  - Used to deploy an Amazon ECS containerized application as a task set. 
  - CodeDeploy performs a blue/green deployment by installing an updated version of the containerized application as a new replacement task set. CodeDeploy reroutes production traffic from the original application, or task set, to the replacement task set. The original task set is terminated after a successful deployment.

## Deployment approach for EC2
- Deploys a revision to a set of instances.
- Deploys a new revision that consists of an application and AppSpec file. The AppSpec specifies how to deploy the application to the instances in a deployment group.

![URL](https://td-mainsite-cdn.tutorialsdojo.com/wp-content/uploads/2019/05/AWS-CodeDeploy-2.jpg)

## Deployment approach for Lambda
- Deploys a new version of a serverless Lambda function on a high-availability compute infrastructure.
- Shifts production traffic from one version of a Lambda function to a new version of the same function. The AppSpec file specifies which Lambda function version to deploy.

![url](https://td-mainsite-cdn.tutorialsdojo.com/wp-content/uploads/2019/05/AWS-CodeDeploy-3.jpg)

## Deployment approach for ECS
- Deploys an updated version of an Amazon ECS containerized application as a new, replacement task set. CodeDeploy reroutes production traffic from the task set with the original version to the new replacement task set with the updated version. When the deployment completes, the original task set is terminated.

![URL](https://td-mainsite-cdn.tutorialsdojo.com/wp-content/uploads/2019/05/AWS-CodeDeploy-4.jpg)

## App Spec File 

The application specification file (AppSpec file) is a YAML-formatted or JSON-formatted file used by CodeDeploy to manage a deployment. Note: the name of the AppSpec file for an EC2/On-Premises deployment must be appspec.yml. The name of the AppSpec file for an Amazon ECS or AWS Lambda deployment must be appspec.yml.

For ECS
- The container and port in replacement task set where your Application Load Balancer or Network Load Balancer reroutes traffic during a deployment. This is specified with the LoadBalancerInfo instruction in the AppSpec file.
- Amazon ECS task definition file. This is specified with its ARN in the TaskDefinition instruction in the AppSpec file.

For Lambda
- Lambda function version to deploy.
- Lambda functions to use as validation tests.

For EC2
- Which lifecycle event hooks to run in response to deployment lifecycle events.