# AWS CodeDeploy Construct Library

## Introduction

AWS CodeDeploy is a deployment service that automates application deployments to
Amazon EC2 instances, on-premises instances, serverless Lambda functions, or
Amazon ECS services.

The CDK currently supports Amazon EC2, on-premise, AWS Lambda, and Amazon ECS applications.

## EC2/on-premise Applications

To create a new CodeDeploy Application that deploys to EC2/on-premise instances:

```ts
const application = new codedeploy.ServerApplication(this, 'CodeDeployApplication', {
  applicationName: 'MyApplication', // optional property
});
```

To import an already existing Application:

```ts
const application = codedeploy.ServerApplication.fromServerApplicationName(
  this,
  'ExistingCodeDeployApplication',
  'MyExistingApplication',
);
```

## EC2/on-premise Deployment Groups

To create a new CodeDeploy Deployment Group that deploys to EC2/on-premise instances:

```ts
import * as autoscaling from 'aws-cdk-lib/aws-autoscaling';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';

declare const application: codedeploy.ServerApplication;
declare const asg: autoscaling.AutoScalingGroup;
declare const alarm: cloudwatch.Alarm;
const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'CodeDeployDeploymentGroup', {
  application,
  deploymentGroupName: 'MyDeploymentGroup',
  autoScalingGroups: [asg],
  // adds User Data that installs the CodeDeploy agent on your auto-scaling groups hosts
  // default: true
  installAgent: true,
  // adds EC2 instances matching tags
  ec2InstanceTags: new codedeploy.InstanceTagSet(
    {
      // any instance with tags satisfying
      // key1=v1 or key1=v2 or key2 (any value) or value v3 (any key)
      // will match this group
      'key1': ['v1', 'v2'],
      'key2': [],
      '': ['v3'],
    },
  ),
  // adds on-premise instances matching tags
  onPremiseInstanceTags: new codedeploy.InstanceTagSet(
    // only instances with tags (key1=v1 or key1=v2) AND key2=v3 will match this set
    {
      'key1': ['v1', 'v2'],
    },
    {
      'key2': ['v3'],
    },
  ),
  // CloudWatch alarms
  alarms: [alarm],
  // whether to ignore failure to fetch the status of alarms from CloudWatch
  // default: false
  ignorePollAlarmsFailure: false,
  // whether to skip the step of checking CloudWatch alarms during the deployment process
  // default: false
  ignoreAlarmConfiguration: false,
  // auto-rollback configuration
  autoRollback: {
    failedDeployment: true, // default: true
    stoppedDeployment: true, // default: false
    deploymentInAlarm: true, // default: true if you provided any alarms, false otherwise
  },
  // whether the deployment group was configured to have CodeDeploy install a termination hook into an Auto Scaling group
  // default: false
  terminationHook: true,
});
```

All properties are optional - if you don't provide an Application,
one will be automatically created.

To import an already existing Deployment Group:

```ts
declare const application: codedeploy.ServerApplication;
const deploymentGroup = codedeploy.ServerDeploymentGroup.fromServerDeploymentGroupAttributes(
  this,
  'ExistingCodeDeployDeploymentGroup', {
    application,
    deploymentGroupName: 'MyExistingDeploymentGroup',
  },
);
```

### Load balancers

You can [specify a load balancer](https://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-elastic-load-balancing.html)
with the `loadBalancer` property when creating a Deployment Group.

[`LoadBalancer`](/v2/docs/aws-cdk-lib.aws_codedeploy.LoadBalancer) is an abstract class with static factory methods that allow you to create instances of it from various sources.

With Classic Elastic Load Balancer, you provide it directly:

```ts
import * as elb from 'aws-cdk-lib/aws-elasticloadbalancing';

declare const lb: elb.LoadBalancer;
lb.addListener({
  externalPort: 80,
});

const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
  loadBalancer: codedeploy.LoadBalancer.classic(lb),
});
```

With Application Load Balancer or Network Load Balancer,
you provide a Target Group as the load balancer:

```ts
declare const alb: elbv2.ApplicationLoadBalancer;
const listener = alb.addListener('Listener', { port: 80 });
const targetGroup = listener.addTargets('Fleet', { port: 80 });

const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
  loadBalancer: codedeploy.LoadBalancer.application(targetGroup),
});
```

The `loadBalancer` property has been deprecated. To provide multiple Elastic Load Balancers as target groups use the `loadBalancers` parameter:

```ts
import * as elb from 'aws-cdk-lib/aws-elasticloadbalancing';
import * as elb2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';

declare const clb: elb.LoadBalancer;
declare const alb: elb2.ApplicationLoadBalancer;
declare const nlb: elb2.NetworkLoadBalancer;

const albListener = alb.addListener('ALBListener', { port: 80 });
const albTargetGroup = albListener.addTargets('ALBFleet', { port: 80 });

const nlbListener = nlb.addListener('NLBListener', { port: 80 });
const nlbTargetGroup = nlbListener.addTargets('NLBFleet', { port: 80 });

const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
  loadBalancers: [
    codedeploy.LoadBalancer.classic(clb),
    codedeploy.LoadBalancer.application(albTargetGroup),
    codedeploy.LoadBalancer.network(nlbTargetGroup),
  ]
});
```

## EC2/on-premise Deployment Configurations

You can also pass a Deployment Configuration when creating the Deployment Group:

```ts
const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'CodeDeployDeploymentGroup', {
  deploymentConfig: codedeploy.ServerDeploymentConfig.ALL_AT_ONCE,
});
```

The default Deployment Configuration is `ServerDeploymentConfig.ONE_AT_A_TIME`.

You can also create a custom Deployment Configuration:

```ts
const deploymentConfig = new codedeploy.ServerDeploymentConfig(this, 'DeploymentConfiguration', {
  deploymentConfigName: 'MyDeploymentConfiguration', // optional property
  // one of these is required, but both cannot be specified at the same time
  minimumHealthyHosts: codedeploy.MinimumHealthyHosts.count(2),
  // minimumHealthyHosts: codedeploy.MinimumHealthyHosts.percentage(75),
});
```

Or import an existing one:

```ts
const deploymentConfig = codedeploy.ServerDeploymentConfig.fromServerDeploymentConfigName(
  this,
  'ExistingDeploymentConfiguration',
  'MyExistingDeploymentConfiguration',
);
```

### Zonal Configuration

CodeDeploy can deploy your application to one Availability Zone at a time, within an AWS Region by configuring [zonal configuration](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations-create.html#zonal-config).

To create a new deployment configuration with zonal configuration:

```ts
const deploymentConfig = new codedeploy.ServerDeploymentConfig(this, 'DeploymentConfiguration', {
  minimumHealthyHosts: codedeploy.MinimumHealthyHosts.count(2),
  zonalConfig: {
    monitorDuration: Duration.minutes(30),
    firstZoneMonitorDuration: Duration.minutes(60),
    minimumHealthyHostsPerZone: codedeploy.MinimumHealthyHostsPerZone.count(1),
  },
});
```

**Note**: Zonal configuration is only configurable for EC2/on-premise deployments.

## Lambda Applications

To create a new CodeDeploy Application that deploys to a Lambda function:

```ts
const application = new codedeploy.LambdaApplication(this, 'CodeDeployApplication', {
  applicationName: 'MyApplication', // optional property
});
```

To import an already existing Application:

```ts
const application = codedeploy.LambdaApplication.fromLambdaApplicationName(
  this,
  'ExistingCodeDeployApplication',
  'MyExistingApplication',
);
```

## Lambda Deployment Groups

To enable traffic shifting deployments for Lambda functions, CodeDeploy uses Lambda Aliases, which can balance incoming traffic between two different versions of your function.
Before deployment, the alias sends 100% of invokes to the version used in production.
When you publish a new version of the function to your stack, CodeDeploy will send a small percentage of traffic to the new version, monitor, and validate before shifting 100% of traffic to the new version.

To create a new CodeDeploy Deployment Group that deploys to a Lambda function:

```ts
declare const myApplication: codedeploy.LambdaApplication;
declare const func: lambda.Function;
const version = func.currentVersion;
const version1Alias = new lambda.Alias(this, 'alias', {
  aliasName: 'prod',
  version,
});

const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  application: myApplication, // optional property: one will be created for you if not provided
  alias: version1Alias,
  deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
});
```

In order to deploy a new version of this function:

1. Reference the version with the latest changes `const version = func.currentVersion`.
2. Re-deploy the stack (this will trigger a deployment).
3. Monitor the CodeDeploy deployment as traffic shifts between the versions.

### Lambda Deployment Rollbacks and Alarms

CodeDeploy will roll back if the deployment fails. You can optionally trigger a rollback when one or more alarms are in a failed state:

```ts
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';

declare const alias: lambda.Alias;
const alarm = new cloudwatch.Alarm(this, 'Errors', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: alias.metricErrors(),
});
const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  alias,
  deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
  alarms: [
    // pass some alarms when constructing the deployment group
    alarm,
  ],
});

// or add alarms to an existing group
declare const blueGreenAlias: lambda.Alias;
deploymentGroup.addAlarm(new cloudwatch.Alarm(this, 'BlueGreenErrors', {
  comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
  threshold: 1,
  evaluationPeriods: 1,
  metric: blueGreenAlias.metricErrors(),
}));
```

### Pre and Post Hooks

CodeDeploy allows you to run an arbitrary Lambda function before traffic shifting actually starts (PreTraffic Hook) and after it completes (PostTraffic Hook).
With either hook, you have the opportunity to run logic that determines whether the deployment must succeed or fail.
For example, with PreTraffic hook you could run integration tests against the newly created Lambda version (but not serving traffic). With PostTraffic hook, you could run end-to-end validation checks.

```ts
declare const warmUpUserCache: lambda.Function;
declare const endToEndValidation: lambda.Function;
declare const alias: lambda.Alias;

// pass a hook whe creating the deployment group
const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  alias: alias,
  deploymentConfig: codedeploy.LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
  preHook: warmUpUserCache,
});

// or configure one on an existing deployment group
deploymentGroup.addPostHook(endToEndValidation);
```

### Import an existing Lambda Deployment Group

To import an already existing Deployment Group:

```ts
declare const application: codedeploy.LambdaApplication;
const deploymentGroup = codedeploy.LambdaDeploymentGroup.fromLambdaDeploymentGroupAttributes(this, 'ExistingCodeDeployDeploymentGroup', {
  application,
  deploymentGroupName: 'MyExistingDeploymentGroup',
});
```

## Lambda Deployment Configurations

CodeDeploy for Lambda comes with predefined configurations for traffic shifting.
The predefined configurations are available as LambdaDeploymentConfig constants.

```ts
const config = codedeploy.LambdaDeploymentConfig.CANARY_10PERCENT_30MINUTES;

declare const application: codedeploy.LambdaApplication;
declare const alias: lambda.Alias;
const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  application,
  alias,
  deploymentConfig: config,
});
```

If you want to specify your own strategy,
you can do so with the LambdaDeploymentConfig construct,
letting you specify precisely how fast a new function version is deployed.

```ts
const config = new codedeploy.LambdaDeploymentConfig(this, 'CustomConfig', {
  trafficRouting: new codedeploy.TimeBasedCanaryTrafficRouting({
    interval: Duration.minutes(15),
    percentage: 5,
  }),
});

declare const application: codedeploy.LambdaApplication;
declare const alias: lambda.Alias;
const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  application,
  alias,
  deploymentConfig: config,
});
```

You can specify a custom name for your deployment config, but if you do you will not be able to update the interval/percentage through CDK.

```ts
const config = new codedeploy.LambdaDeploymentConfig(this, 'CustomConfig', {
  trafficRouting: new codedeploy.TimeBasedCanaryTrafficRouting({
    interval: Duration.minutes(15),
    percentage: 5,
  }),
  deploymentConfigName: 'MyDeploymentConfig',
});
```

To import an already existing Deployment Config:

```ts
const deploymentConfig = codedeploy.LambdaDeploymentConfig.fromLambdaDeploymentConfigName(
  this,
  'ExistingDeploymentConfiguration',
  'MyExistingDeploymentConfiguration',
);
```

## ECS Applications

To create a new CodeDeploy Application that deploys an ECS service:

```ts
const application = new codedeploy.EcsApplication(this, 'CodeDeployApplication', {
  applicationName: 'MyApplication', // optional property
});
```

To import an already existing Application:

```ts
const application = codedeploy.EcsApplication.fromEcsApplicationName(
  this,
  'ExistingCodeDeployApplication',
  'MyExistingApplication',
);
```

## ECS Deployment Groups

CodeDeploy can be used to deploy to load-balanced ECS services.
CodeDeploy performs ECS blue-green deployments by managing ECS task sets and load balancer
target groups.  During a blue-green deployment, one task set and target group runs the
original version of your ECS task definition ('blue') and another task set and target group
runs the new version of your ECS task definition ('green').

CodeDeploy orchestrates traffic shifting during ECS blue-green deployments by using
a load balancer listener to balance incoming traffic between the 'blue' and 'green' task sets/target groups
running two different versions of your ECS task definition.
Before deployment, the load balancer listener sends 100% of requests to the 'blue' target group.
When you publish a new version of the task definition and start a CodeDeploy deployment,
CodeDeploy can send a small percentage of traffic to the new 'green' task set behind the 'green' target group,
monitor, and validate before shifting 100% of traffic to the new version.

To create a new CodeDeploy Deployment Group that deploys to an ECS service:

```ts
declare const myApplication: codedeploy.EcsApplication;
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.FargateTaskDefinition;
declare const blueTargetGroup: elbv2.ITargetGroup;
declare const greenTargetGroup: elbv2.ITargetGroup;
declare const listener: elbv2.IApplicationListener;

const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  deploymentController: {
    type: ecs.DeploymentControllerType.CODE_DEPLOY,
  },
});

new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
  service,
  blueGreenDeploymentConfig: {
    blueTargetGroup,
    greenTargetGroup,
    listener,
  },
  deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
```

In order to deploy a new task definition version to the ECS service,
deploy the changes directly through CodeDeploy using the CodeDeploy APIs or console.
When the `CODE_DEPLOY` deployment controller is used, the ECS service cannot be
deployed with a new task definition version through CloudFormation.

For more information on the behavior of CodeDeploy blue-green deployments for ECS, see
[What happens during an Amazon ECS deployment](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-steps-ecs.html#deployment-steps-what-happens)
in the CodeDeploy user guide.

Note: If you wish to deploy updates to your ECS service through CDK and CloudFormation instead of directly through CodeDeploy,
using the [`CfnCodeDeployBlueGreenHook`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnCodeDeployBlueGreenHook.html)
construct is the recommended approach instead of using the [`EcsDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentGroup) construct.  For a comparison
of ECS blue-green deployments through CodeDeploy (using [`EcsDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentGroup)) and through CloudFormation (using `CfnCodeDeployBlueGreenHook`),
see [Create an Amazon ECS blue/green deployment through AWS CloudFormation](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployments-create-ecs-cfn.html#differences-ecs-bg-cfn)
in the CloudFormation user guide.

### ECS Deployment Rollbacks and Alarms

CodeDeploy will automatically roll back if a deployment fails.
You can optionally trigger an automatic rollback when one or more alarms are in a failed state during a deployment, or if the deployment stops.

In this example, CodeDeploy will monitor and roll back on alarms set for the
number of unhealthy ECS tasks in each of the blue and green target groups,
as well as alarms set for the number HTTP 5xx responses seen in each of the blue
and green target groups.

```ts
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';

declare const service: ecs.FargateService;
declare const blueTargetGroup: elbv2.ApplicationTargetGroup;
declare const greenTargetGroup: elbv2.ApplicationTargetGroup;
declare const listener: elbv2.IApplicationListener;

// Alarm on the number of unhealthy ECS tasks in each target group
const blueUnhealthyHosts = new cloudwatch.Alarm(this, 'BlueUnhealthyHosts', {
  alarmName: Stack.of(this).stackName + '-Unhealthy-Hosts-Blue',
  metric: blueTargetGroup.metricUnhealthyHostCount(),
  threshold: 1,
  evaluationPeriods: 2,
});

const greenUnhealthyHosts = new cloudwatch.Alarm(this, 'GreenUnhealthyHosts', {
  alarmName: Stack.of(this).stackName + '-Unhealthy-Hosts-Green',
  metric: greenTargetGroup.metricUnhealthyHostCount(),
  threshold: 1,
  evaluationPeriods: 2,
});

// Alarm on the number of HTTP 5xx responses returned by each target group
const blueApiFailure = new cloudwatch.Alarm(this, 'Blue5xx', {
  alarmName: Stack.of(this).stackName + '-Http-5xx-Blue',
  metric: blueTargetGroup.metricHttpCodeTarget(
    elbv2.HttpCodeTarget.TARGET_5XX_COUNT,
    { period: Duration.minutes(1) },
  ),
  threshold: 1,
  evaluationPeriods: 1,
});

const greenApiFailure = new cloudwatch.Alarm(this, 'Green5xx', {
  alarmName: Stack.of(this).stackName + '-Http-5xx-Green',
  metric: greenTargetGroup.metricHttpCodeTarget(
    elbv2.HttpCodeTarget.TARGET_5XX_COUNT,
    { period: Duration.minutes(1) },
  ),
  threshold: 1,
  evaluationPeriods: 1,
});

new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
  // CodeDeploy will monitor these alarms during a deployment and automatically roll back
  alarms: [blueUnhealthyHosts, greenUnhealthyHosts, blueApiFailure, greenApiFailure],
  autoRollback: {
    // CodeDeploy will automatically roll back if a deployment is stopped
    stoppedDeployment: true,
  },
  service,
  blueGreenDeploymentConfig: {
    blueTargetGroup,
    greenTargetGroup,
    listener,
  },
  deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
```

### Deployment validation and manual deployment approval

CodeDeploy blue-green deployments provide an opportunity to validate the new task definition version running on
the 'green' ECS task set prior to shifting any production traffic to the new version.  A second 'test' listener
serving traffic on a different port be added to the load balancer. For example, the test listener can serve
test traffic on port 9001 while the main listener serves production traffic on port 443.
During a blue-green deployment, CodeDeploy can then shift 100% of test traffic over to the 'green'
task set/target group prior to shifting any production traffic during the deployment.

```ts
declare const myApplication: codedeploy.EcsApplication;
declare const service: ecs.FargateService;
declare const blueTargetGroup: elbv2.ITargetGroup;
declare const greenTargetGroup: elbv2.ITargetGroup;
declare const listener: elbv2.IApplicationListener;
declare const testListener: elbv2.IApplicationListener;

new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
  service,
  blueGreenDeploymentConfig: {
    blueTargetGroup,
    greenTargetGroup,
    listener,
    testListener,
  },
  deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
```

Automated validation steps can run during the CodeDeploy deployment after shifting test traffic and before
shifting production traffic.  CodeDeploy supports registering Lambda functions as lifecycle hooks for
an ECS deployment.  These Lambda functions can run automated validation steps against the test traffic
port, for example in response to the `AfterAllowTestTraffic` lifecycle hook.  For more information about
how to specify the Lambda functions to run for each CodeDeploy lifecycle hook in an ECS deployment, see the
[AppSpec 'hooks' for an Amazon ECS deployment](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html#appspec-hooks-ecs)
section in the CodeDeploy user guide.

After provisioning the 'green' ECS task set and re-routing test traffic during a blue-green deployment,
CodeDeploy can wait for approval before continuing the deployment and re-routing production traffic.
During this approval wait time, you can complete additional validation steps prior to exposing the new
'green' task set to production traffic, such as manual testing through the test listener port or
running automated integration test suites.

To approve the deployment, validation steps use the CodeDeploy
[ContinueDeployment API(https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ContinueDeployment.html).
If the ContinueDeployment API is not called within the approval wait time period, CodeDeploy will stop the
deployment and can automatically roll back the deployment.

```ts
declare const service: ecs.FargateService;
declare const blueTargetGroup: elbv2.ITargetGroup;
declare const greenTargetGroup: elbv2.ITargetGroup;
declare const listener: elbv2.IApplicationListener;
declare const testListener: elbv2.IApplicationListener;

new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
  autoRollback: {
    // CodeDeploy will automatically roll back if the 8-hour approval period times out and the deployment stops
    stoppedDeployment: true,
  },
  service,
  blueGreenDeploymentConfig: {
    // The deployment will wait for approval for up to 8 hours before stopping the deployment
    deploymentApprovalWaitTime: Duration.hours(8),
    blueTargetGroup,
    greenTargetGroup,
    listener,
    testListener,
  },
  deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
```

### Deployment bake time

You can specify how long CodeDeploy waits before it terminates the original 'blue' ECS task set when a blue-green deployment
is complete in order to let the deployment "bake" a while. During this bake time, CodeDeploy will continue to monitor any
CloudWatch alarms specified for the deployment group and will automatically roll back if those alarms go into a failed state.

```ts
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';

declare const service: ecs.FargateService;
declare const blueTargetGroup: elbv2.ITargetGroup;
declare const greenTargetGroup: elbv2.ITargetGroup;
declare const listener: elbv2.IApplicationListener;
declare const blueUnhealthyHosts: cloudwatch.Alarm;
declare const greenUnhealthyHosts: cloudwatch.Alarm;
declare const blueApiFailure: cloudwatch.Alarm;
declare const greenApiFailure: cloudwatch.Alarm;

new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
  service,
  blueGreenDeploymentConfig: {
    blueTargetGroup,
    greenTargetGroup,
    listener,
    // CodeDeploy will wait for 30 minutes after completing the blue-green deployment before it terminates the blue tasks
    terminationWaitTime: Duration.minutes(30),
  },
  // CodeDeploy will continue to monitor these alarms during the 30-minute bake time and will automatically
  // roll back if they go into a failed state at any point during the deployment.
  alarms: [blueUnhealthyHosts, greenUnhealthyHosts, blueApiFailure, greenApiFailure],
  deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
```

### Import an existing ECS Deployment Group

To import an already existing Deployment Group:

```ts
declare const application: codedeploy.EcsApplication;
const deploymentGroup = codedeploy.EcsDeploymentGroup.fromEcsDeploymentGroupAttributes(this, 'ExistingCodeDeployDeploymentGroup', {
  application,
  deploymentGroupName: 'MyExistingDeploymentGroup',
});
```

## ECS Deployment Configurations

CodeDeploy for ECS comes with predefined configurations for traffic shifting.
The predefined configurations are available as LambdaDeploymentConfig constants.

```ts
const config = codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES;
```

If you want to specify your own strategy,
you can do so with the EcsDeploymentConfig construct,
letting you specify precisely how fast an ECS service is deployed.

```ts
new codedeploy.EcsDeploymentConfig(this, 'CustomConfig', {
  trafficRouting: new codedeploy.TimeBasedCanaryTrafficRouting({
    interval: Duration.minutes(15),
    percentage: 5,
  }),
});
```

You can specify a custom name for your deployment config, but if you do you will not be able to update the interval/percentage through CDK.

```ts
const config = new codedeploy.EcsDeploymentConfig(this, 'CustomConfig', {
  trafficRouting: new codedeploy.TimeBasedCanaryTrafficRouting({
    interval: Duration.minutes(15),
    percentage: 5,
  }),
  deploymentConfigName: 'MyDeploymentConfig',
});
```

Or import an existing one:

```ts
const deploymentConfig = codedeploy.EcsDeploymentConfig.fromEcsDeploymentConfigName(
  this,
  'ExistingDeploymentConfiguration',
  'MyExistingDeploymentConfiguration',
);
```

## ECS Deployments

[![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg)](https://constructs.dev/packages/@cdklabs/cdk-ecs-codedeploy)

An experimental construct is available on the Construct Hub called [@cdklabs/cdk-ecs-codedeploy](https://constructs.dev/packages/@cdklabs/cdk-ecs-codedeploy) that manages ECS CodeDeploy deployments.

```ts
declare const deploymentGroup: codedeploy.IEcsDeploymentGroup;
declare const taskDefinition: ecs.ITaskDefinition;

new EcsDeployment({
  deploymentGroup,
  targetService: {
    taskDefinition,
    containerName: 'mycontainer',
    containerPort: 80,
  },
});
```

The deployment will use the AutoRollbackConfig for the EcsDeploymentGroup unless it is overridden in the deployment:

```ts
declare const deploymentGroup: codedeploy.IEcsDeploymentGroup;
declare const taskDefinition: ecs.ITaskDefinition;

new EcsDeployment({
  deploymentGroup,
  targetService: {
    taskDefinition,
    containerName: 'mycontainer',
    containerPort: 80,
  },
  autoRollback: {
    failedDeployment: true,
    deploymentInAlarm: true,
    stoppedDeployment: false,
  },
});
```

By default, the CodeDeploy Deployment will timeout after 30 minutes. The timeout value can be overridden:

```ts
declare const deploymentGroup: codedeploy.IEcsDeploymentGroup;
declare const taskDefinition: ecs.ITaskDefinition;

new EcsDeployment({
  deploymentGroup,
  targetService: {
    taskDefinition,
    containerName: 'mycontainer',
    containerPort: 80,
  },
  timeout: Duration.minutes(60),
});
```

## Types

| Name | Kind | Summary |
| --- | --- | --- |
| [`BaseDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.BaseDeploymentConfig) | Construct (L2) | The base class for ServerDeploymentConfig, EcsDeploymentConfig, and LambdaDeploymentConfig deployment configurations. |
| [`CustomLambdaDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.CustomLambdaDeploymentConfig) | Construct (L2) | A custom Deployment Configuration for a Lambda Deployment Group. |
| [`EcsApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsApplication) | Construct (L2) | A CodeDeploy Application that deploys to an Amazon ECS service. |
| [`EcsDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentConfig) | Construct (L2) | A custom Deployment Configuration for an ECS Deployment Group. |
| [`EcsDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentGroup) | Construct (L2) | A CodeDeploy deployment group that orchestrates ECS blue-green deployments. |
| [`LambdaApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaApplication) | Construct (L2) | A CodeDeploy Application that deploys to an AWS Lambda function. |
| [`LambdaDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaDeploymentConfig) | Construct (L2) | A custom Deployment Configuration for a Lambda Deployment Group. |
| [`LambdaDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaDeploymentGroup) | Construct (L2) |  |
| [`ServerApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerApplication) | Construct (L2) | A CodeDeploy Application that deploys to EC2/on-premise instances. |
| [`ServerDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerDeploymentConfig) | Construct (L2) | A custom Deployment Configuration for an EC2/on-premise Deployment Group. |
| [`ServerDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerDeploymentGroup) | Construct (L2) | A CodeDeploy Deployment Group that deploys to EC2/on-premise instances. |
| [`CfnApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnApplication) | Construct (L1) | The `AWS::CodeDeploy::Application` resource creates an AWS CodeDeploy application. |
| [`CfnDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig) | Construct (L1) | The `AWS::CodeDeploy::DeploymentConfig` resource creates a set of deployment rules, deployment success conditions, and deployment failure conditions that AWS CodeDeploy uses during a deployment. |
| [`CfnDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup) | Construct (L1) | The `AWS::CodeDeploy::DeploymentGroup` resource creates an AWS CodeDeploy deployment group that specifies which instances your application revisions are deployed to, along with other deployment options. |
| [`AllAtOnceTrafficRouting`](/v2/docs/aws-cdk-lib.aws_codedeploy.AllAtOnceTrafficRouting) | Class | Define a traffic routing config of type 'AllAtOnce'. |
| [`AutoRollbackConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.AutoRollbackConfig) | Struct | The configuration for automatically rolling back deployments in a given Deployment Group. |
| [`BaseDeploymentConfigOptions`](/v2/docs/aws-cdk-lib.aws_codedeploy.BaseDeploymentConfigOptions) | Struct | Construction properties of `BaseDeploymentConfig`. |
| [`BaseDeploymentConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.BaseDeploymentConfigProps) | Struct | Complete base deployment config properties that are required to be supplied by the implementation of the BaseDeploymentConfig class. |
| [`BaseTrafficShiftingConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.BaseTrafficShiftingConfigProps) | Struct | Common properties of traffic shifting routing configurations. |
| [`CanaryTrafficRoutingConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.CanaryTrafficRoutingConfig) | Struct | Represents the configuration specific to canary traffic shifting. |
| [`CfnApplicationProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnApplicationProps) | Struct | Properties for defining a `CfnApplication`. |
| [`CfnDeploymentConfig.MinimumHealthyHostsPerZoneProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig.MinimumHealthyHostsPerZoneProperty) | Struct | Information about the minimum number of healthy instances per Availability Zone. |
| [`CfnDeploymentConfig.MinimumHealthyHostsProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig.MinimumHealthyHostsProperty) | Struct | `MinimumHealthyHosts` is a property of the [DeploymentConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentconfig.html) resource that defines how many instances must remain healthy during an AWS CodeDeploy deployment. |
| [`CfnDeploymentConfig.TimeBasedCanaryProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig.TimeBasedCanaryProperty) | Struct | A configuration that shifts traffic from one version of a Lambda function or Amazon ECS task set to another in two increments. |
| [`CfnDeploymentConfig.TimeBasedLinearProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig.TimeBasedLinearProperty) | Struct | A configuration that shifts traffic from one version of a Lambda function or ECS task set to another in equal increments, with an equal number of minutes between each increment. |
| [`CfnDeploymentConfig.TrafficRoutingConfigProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig.TrafficRoutingConfigProperty) | Struct | The configuration that specifies how traffic is shifted from one version of a Lambda function to another version during an AWS Lambda deployment, or from one Amazon ECS task set to another during an Amazon ECS deployment. |
| [`CfnDeploymentConfig.ZonalConfigProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfig.ZonalConfigProperty) | Struct | Configure the `ZonalConfig` object if you want AWS CodeDeploy to deploy your application to one [Availability Zone](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-availability-zones) at a time, within an AWS Region. By deploying to one Availability Zone at a time, you can expose your deployment to a progressively larger audience as confidence in the deployment's performance and viability grows. If you don't configure the `ZonalConfig` object, CodeDeploy deploys your application to a random selection of hosts across a Region. |
| [`CfnDeploymentConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentConfigProps) | Struct | Properties for defining a `CfnDeploymentConfig`. |
| [`CfnDeploymentGroup.AlarmConfigurationProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.AlarmConfigurationProperty) | Struct | The `AlarmConfiguration` property type configures CloudWatch alarms for an AWS CodeDeploy deployment group. |
| [`CfnDeploymentGroup.AlarmProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.AlarmProperty) | Struct | The `Alarm` property type specifies a CloudWatch alarm to use for an AWS CodeDeploy deployment group. |
| [`CfnDeploymentGroup.AutoRollbackConfigurationProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.AutoRollbackConfigurationProperty) | Struct | The `AutoRollbackConfiguration` property type configures automatic rollback for an AWS CodeDeploy deployment group when a deployment is not completed successfully. |
| [`CfnDeploymentGroup.BlueGreenDeploymentConfigurationProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.BlueGreenDeploymentConfigurationProperty) | Struct | Information about blue/green deployment options for a deployment group. |
| [`CfnDeploymentGroup.BlueInstanceTerminationOptionProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.BlueInstanceTerminationOptionProperty) | Struct | Information about whether instances in the original environment are terminated when a blue/green deployment is successful. |
| [`CfnDeploymentGroup.DeploymentProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.DeploymentProperty) | Struct | `Deployment` is a property of the [DeploymentGroup](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html) resource that specifies an AWS CodeDeploy application revision to be deployed to instances in the deployment group. If you specify an application revision, your target revision is deployed as soon as the provisioning process is complete. |
| [`CfnDeploymentGroup.DeploymentReadyOptionProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.DeploymentReadyOptionProperty) | Struct | Information about how traffic is rerouted to instances in a replacement environment in a blue/green deployment. |
| [`CfnDeploymentGroup.DeploymentStyleProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.DeploymentStyleProperty) | Struct | Information about the type of deployment, either in-place or blue/green, you want to run and whether to route deployment traffic behind a load balancer. |
| [`CfnDeploymentGroup.EC2TagFilterProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.EC2TagFilterProperty) | Struct | Information about an Amazon EC2 tag filter. |
| [`CfnDeploymentGroup.EC2TagSetListObjectProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.EC2TagSetListObjectProperty) | Struct | The `EC2TagSet` property type specifies information about groups of tags applied to Amazon EC2 instances. |
| [`CfnDeploymentGroup.EC2TagSetProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.EC2TagSetProperty) | Struct | The `EC2TagSet` property type specifies information about groups of tags applied to Amazon EC2 instances. |
| [`CfnDeploymentGroup.ECSServiceProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.ECSServiceProperty) | Struct | Contains the service and cluster names used to identify an Amazon ECS deployment's target. |
| [`CfnDeploymentGroup.ELBInfoProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.ELBInfoProperty) | Struct | The `ELBInfo` property type specifies information about the Elastic Load Balancing load balancer used for an CodeDeploy deployment group. |
| [`CfnDeploymentGroup.GitHubLocationProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.GitHubLocationProperty) | Struct | `GitHubLocation` is a property of the [CodeDeploy DeploymentGroup Revision](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codedeploy-deploymentgroup-deployment-revision.html) property that specifies the location of an application revision that is stored in GitHub. |
| [`CfnDeploymentGroup.GreenFleetProvisioningOptionProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.GreenFleetProvisioningOptionProperty) | Struct | Information about the instances that belong to the replacement environment in a blue/green deployment. |
| [`CfnDeploymentGroup.LoadBalancerInfoProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.LoadBalancerInfoProperty) | Struct | The `LoadBalancerInfo` property type specifies information about the load balancer or target group used for an AWS CodeDeploy deployment group. |
| [`CfnDeploymentGroup.OnPremisesTagSetListObjectProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.OnPremisesTagSetListObjectProperty) | Struct | The `OnPremisesTagSetListObject` property type specifies lists of on-premises instance tag groups. |
| [`CfnDeploymentGroup.OnPremisesTagSetProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.OnPremisesTagSetProperty) | Struct | The `OnPremisesTagSet` property type specifies a list containing other lists of on-premises instance tag groups. |
| [`CfnDeploymentGroup.RevisionLocationProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.RevisionLocationProperty) | Struct | `RevisionLocation` is a property that defines the location of the CodeDeploy application revision to deploy. |
| [`CfnDeploymentGroup.S3LocationProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.S3LocationProperty) | Struct | `S3Location` is a property of the [CodeDeploy DeploymentGroup Revision](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codedeploy-deploymentgroup-deployment-revision.html) property that specifies the location of an application revision that is stored in Amazon Simple Storage Service ( Amazon S3 ). |
| [`CfnDeploymentGroup.TagFilterProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.TagFilterProperty) | Struct | `TagFilter` is a property type of the [AWS::CodeDeploy::DeploymentGroup](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html) resource that specifies which on-premises instances to associate with the deployment group. To register on-premise instances with AWS CodeDeploy , see [Configure Existing On-Premises Instances by Using AWS CodeDeploy](https://docs.aws.amazon.com/codedeploy/latest/userguide/instances-on-premises.html) in the *AWS CodeDeploy User Guide* . |
| [`CfnDeploymentGroup.TargetGroupInfoProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.TargetGroupInfoProperty) | Struct | The `TargetGroupInfo` property type specifies information about a target group in Elastic Load Balancing to use in a deployment. |
| [`CfnDeploymentGroup.TargetGroupPairInfoProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.TargetGroupPairInfoProperty) | Struct | Information about two target groups and how traffic is routed during an Amazon ECS deployment. |
| [`CfnDeploymentGroup.TrafficRouteProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.TrafficRouteProperty) | Struct | Information about a listener. |
| [`CfnDeploymentGroup.TriggerConfigProperty`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.TriggerConfigProperty) | Struct | Information about notification triggers for the deployment group. |
| [`CfnDeploymentGroupProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroupProps) | Struct | Properties for defining a `CfnDeploymentGroup`. |
| [`ComputePlatform`](/v2/docs/aws-cdk-lib.aws_codedeploy.ComputePlatform) | Enum | The compute platform of a deployment configuration. |
| [`CustomLambdaDeploymentConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.CustomLambdaDeploymentConfigProps) | Struct | Properties of a reference to a CodeDeploy Lambda Deployment Configuration. |
| [`CustomLambdaDeploymentConfigType`](/v2/docs/aws-cdk-lib.aws_codedeploy.CustomLambdaDeploymentConfigType) | Enum | Lambda Deployment config type. |
| [`EcsApplicationProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsApplicationProps) | Struct | Construction properties for `EcsApplication`. |
| [`EcsBlueGreenDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsBlueGreenDeploymentConfig) | Struct | Specify how the deployment behaves and how traffic is routed to the ECS service during a blue-green ECS deployment. |
| [`EcsDeploymentConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentConfigProps) | Struct | Construction properties of `EcsDeploymentConfig`. |
| [`EcsDeploymentGroupAttributes`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentGroupAttributes) | Struct | Properties of a reference to a CodeDeploy ECS Deployment Group. |
| [`EcsDeploymentGroupProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.EcsDeploymentGroupProps) | Struct | Construction properties for `EcsDeploymentGroup`. |
| [`IBaseDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.IBaseDeploymentConfig) | Interface | The base class for ServerDeploymentConfig, EcsDeploymentConfig, and LambdaDeploymentConfig deployment configurations. |
| [`IBindableDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.IBindableDeploymentConfig) | Interface | A DeploymentConfig that can specialize itself based on the target group it will be used for. |
| [`IEcsApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.IEcsApplication) | Interface | Represents a reference to a CodeDeploy Application deploying to Amazon ECS. |
| [`IEcsDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.IEcsDeploymentConfig) | Interface | The Deployment Configuration of an ECS Deployment Group. |
| [`IEcsDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.IEcsDeploymentGroup) | Interface | Interface for an ECS deployment group. |
| [`ILambdaApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.ILambdaApplication) | Interface | Represents a reference to a CodeDeploy Application deploying to AWS Lambda. |
| [`ILambdaDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.ILambdaDeploymentConfig) | Interface | The Deployment Configuration of a Lambda Deployment Group. |
| [`ILambdaDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.ILambdaDeploymentGroup) | Interface | Interface for a Lambda deployment groups. |
| [`InstanceTagSet`](/v2/docs/aws-cdk-lib.aws_codedeploy.InstanceTagSet) | Class | Represents a set of instance tag groups. |
| [`IServerApplication`](/v2/docs/aws-cdk-lib.aws_codedeploy.IServerApplication) | Interface | Represents a reference to a CodeDeploy Application deploying to EC2/on-premise instances. |
| [`IServerDeploymentConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.IServerDeploymentConfig) | Interface | The Deployment Configuration of an EC2/on-premise Deployment Group. |
| [`IServerDeploymentGroup`](/v2/docs/aws-cdk-lib.aws_codedeploy.IServerDeploymentGroup) | Interface |  |
| [`LambdaApplicationProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaApplicationProps) | Struct | Construction properties for `LambdaApplication`. |
| [`LambdaDeploymentConfigImportProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaDeploymentConfigImportProps) | Struct | Properties of a reference to a CodeDeploy Lambda Deployment Configuration. |
| [`LambdaDeploymentConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaDeploymentConfigProps) | Struct | Construction properties of `LambdaDeploymentConfig`. |
| [`LambdaDeploymentGroupAttributes`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaDeploymentGroupAttributes) | Struct | Properties of a reference to a CodeDeploy Lambda Deployment Group. |
| [`LambdaDeploymentGroupProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.LambdaDeploymentGroupProps) | Struct | Construction properties for `LambdaDeploymentGroup`. |
| [`LinearTrafficRoutingConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.LinearTrafficRoutingConfig) | Struct | Represents the configuration specific to linear traffic shifting. |
| [`LoadBalancer`](/v2/docs/aws-cdk-lib.aws_codedeploy.LoadBalancer) | Class | An interface of an abstract load balancer, as needed by CodeDeploy. |
| [`LoadBalancerGeneration`](/v2/docs/aws-cdk-lib.aws_codedeploy.LoadBalancerGeneration) | Enum | The generations of AWS load balancing solutions. |
| [`MinimumHealthyHosts`](/v2/docs/aws-cdk-lib.aws_codedeploy.MinimumHealthyHosts) | Class | Minimum number of healthy hosts for a server deployment. |
| [`MinimumHealthyHostsPerZone`](/v2/docs/aws-cdk-lib.aws_codedeploy.MinimumHealthyHostsPerZone) | Class | Minimum number of healthy hosts per availability zone for a server deployment. |
| [`ServerApplicationProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerApplicationProps) | Struct | Construction properties for `ServerApplication`. |
| [`ServerDeploymentConfigProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerDeploymentConfigProps) | Struct | Construction properties of `ServerDeploymentConfig`. |
| [`ServerDeploymentGroupAttributes`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerDeploymentGroupAttributes) | Struct | Properties of a reference to a CodeDeploy EC2/on-premise Deployment Group. |
| [`ServerDeploymentGroupProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.ServerDeploymentGroupProps) | Struct | Construction properties for `ServerDeploymentGroup`. |
| [`TimeBasedCanaryTrafficRouting`](/v2/docs/aws-cdk-lib.aws_codedeploy.TimeBasedCanaryTrafficRouting) | Class | Define a traffic routing config of type 'TimeBasedCanary'. |
| [`TimeBasedCanaryTrafficRoutingProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.TimeBasedCanaryTrafficRoutingProps) | Struct | Construction properties for `TimeBasedCanaryTrafficRouting`. |
| [`TimeBasedLinearTrafficRouting`](/v2/docs/aws-cdk-lib.aws_codedeploy.TimeBasedLinearTrafficRouting) | Class | Define a traffic routing config of type 'TimeBasedLinear'. |
| [`TimeBasedLinearTrafficRoutingProps`](/v2/docs/aws-cdk-lib.aws_codedeploy.TimeBasedLinearTrafficRoutingProps) | Struct | Construction properties for `TimeBasedLinearTrafficRouting`. |
| [`TrafficRouting`](/v2/docs/aws-cdk-lib.aws_codedeploy.TrafficRouting) | Class | Represents how traffic is shifted during a CodeDeploy deployment. |
| [`TrafficRoutingConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.TrafficRoutingConfig) | Struct | Represents the structure to pass into the underlying CfnDeploymentConfig class. |
| [`ZonalConfig`](/v2/docs/aws-cdk-lib.aws_codedeploy.ZonalConfig) | Struct | Configuration for CodeDeploy to deploy your application to one Availability Zone at a time within an AWS Region. |
