Namespace Amazon.CDK.AWS.CodeDeploy
AWS CodeDeploy Construct Library
Table of Contents
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:
var application = new ServerApplication(this, "CodeDeployApplication", new ServerApplicationProps {
ApplicationName = "MyApplication"
});
To import an already existing Application:
var application = ServerApplication.FromServerApplicationName(this, "ExistingCodeDeployApplication", "MyExistingApplication");
EC2/on-premise Deployment Groups
To create a new CodeDeploy Deployment Group that deploys to EC2/on-premise instances:
using Amazon.CDK.AWS.AutoScaling;
using Amazon.CDK.AWS.CloudWatch;
ServerApplication application;
AutoScalingGroup asg;
Alarm alarm;
var deploymentGroup = new ServerDeploymentGroup(this, "CodeDeployDeploymentGroup", new ServerDeploymentGroupProps {
Application = application,
DeploymentGroupName = "MyDeploymentGroup",
AutoScalingGroups = new [] { 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 InstanceTagSet(new Dictionary<string, string[]> {
// any instance with tags satisfying
// key1=v1 or key1=v2 or key2 (any value) or value v3 (any key)
// will match this group
{ "key1", new [] { "v1", "v2" } },
{ "key2", new [] { } },
{ "", new [] { "v3" } }
}),
// adds on-premise instances matching tags
OnPremiseInstanceTags = new InstanceTagSet(new Dictionary<string, string[]> {
{ "key1", new [] { "v1", "v2" } }
}, new Dictionary<string, string[]> {
{ "key2", new [] { "v3" } }
}),
// CloudWatch alarms
Alarms = new [] { 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 = new AutoRollbackConfig {
FailedDeployment = true, // default: true
StoppedDeployment = true, // default: false
DeploymentInAlarm = true
},
// 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:
ServerApplication application;
var deploymentGroup = ServerDeploymentGroup.FromServerDeploymentGroupAttributes(this, "ExistingCodeDeployDeploymentGroup", new ServerDeploymentGroupAttributes {
Application = application,
DeploymentGroupName = "MyExistingDeploymentGroup"
});
Load balancers
You can specify a load balancer
with the loadBalancer
property when creating a Deployment Group.
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:
using Amazon.CDK.AWS.ElasticLoadBalancing;
LoadBalancer lb;
lb.AddListener(new LoadBalancerListener {
ExternalPort = 80
});
var deploymentGroup = new ServerDeploymentGroup(this, "DeploymentGroup", new ServerDeploymentGroupProps {
LoadBalancer = LoadBalancer.Classic(lb)
});
With Application Load Balancer or Network Load Balancer, you provide a Target Group as the load balancer:
ApplicationLoadBalancer alb;
var listener = alb.AddListener("Listener", new BaseApplicationListenerProps { Port = 80 });
var targetGroup = listener.AddTargets("Fleet", new AddApplicationTargetsProps { Port = 80 });
var deploymentGroup = new ServerDeploymentGroup(this, "DeploymentGroup", new ServerDeploymentGroupProps {
LoadBalancer = LoadBalancer.Application(targetGroup)
});
The loadBalancer
property has been deprecated. To provide multiple Elastic Load Balancers as target groups use the loadBalancers
parameter:
using Amazon.CDK.AWS.ElasticLoadBalancing;
using Amazon.CDK.AWS.ElasticLoadBalancingV2;
LoadBalancer clb;
ApplicationLoadBalancer alb;
NetworkLoadBalancer nlb;
var albListener = alb.AddListener("ALBListener", new BaseApplicationListenerProps { Port = 80 });
var albTargetGroup = albListener.AddTargets("ALBFleet", new AddApplicationTargetsProps { Port = 80 });
var nlbListener = nlb.AddListener("NLBListener", new BaseNetworkListenerProps { Port = 80 });
var nlbTargetGroup = nlbListener.AddTargets("NLBFleet", new AddNetworkTargetsProps { Port = 80 });
var deploymentGroup = new ServerDeploymentGroup(this, "DeploymentGroup", new ServerDeploymentGroupProps {
LoadBalancers = new [] { LoadBalancer.Classic(clb), LoadBalancer.Application(albTargetGroup), LoadBalancer.Network(nlbTargetGroup) }
});
EC2/on-premise Deployment Configurations
You can also pass a Deployment Configuration when creating the Deployment Group:
var deploymentGroup = new ServerDeploymentGroup(this, "CodeDeployDeploymentGroup", new ServerDeploymentGroupProps {
DeploymentConfig = ServerDeploymentConfig.ALL_AT_ONCE
});
The default Deployment Configuration is ServerDeploymentConfig.ONE_AT_A_TIME
.
You can also create a custom Deployment Configuration:
var deploymentConfig = new ServerDeploymentConfig(this, "DeploymentConfiguration", new ServerDeploymentConfigProps {
DeploymentConfigName = "MyDeploymentConfiguration", // optional property
// one of these is required, but both cannot be specified at the same time
MinimumHealthyHosts = MinimumHealthyHosts.Count(2)
});
Or import an existing one:
var deploymentConfig = 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.
To create a new deployment configuration with zonal configuration:
var deploymentConfig = new ServerDeploymentConfig(this, "DeploymentConfiguration", new ServerDeploymentConfigProps {
MinimumHealthyHosts = MinimumHealthyHosts.Count(2),
ZonalConfig = new ZonalConfig {
MonitorDuration = Duration.Minutes(30),
FirstZoneMonitorDuration = Duration.Minutes(60),
MinimumHealthyHostsPerZone = 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:
var application = new LambdaApplication(this, "CodeDeployApplication", new LambdaApplicationProps {
ApplicationName = "MyApplication"
});
To import an already existing Application:
var application = 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:
LambdaApplication myApplication;
Function func;
var version = func.CurrentVersion;
var version1Alias = new Alias(this, "alias", new AliasProps {
AliasName = "prod",
Version = version
});
var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
Application = myApplication, // optional property: one will be created for you if not provided
Alias = version1Alias,
DeploymentConfig = LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE
});
In order to deploy a new version of this function:
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:
using Amazon.CDK.AWS.CloudWatch;
Alias alias;
// or add alarms to an existing group
Alias blueGreenAlias;
var alarm = new Alarm(this, "Errors", new AlarmProps {
ComparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD,
Threshold = 1,
EvaluationPeriods = 1,
Metric = alias.MetricErrors()
});
var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
Alias = alias,
DeploymentConfig = LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
Alarms = new [] { alarm }
});
deploymentGroup.AddAlarm(new Alarm(this, "BlueGreenErrors", new AlarmProps {
ComparisonOperator = 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.
Function warmUpUserCache;
Function endToEndValidation;
Alias alias;
// pass a hook whe creating the deployment group
var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
Alias = alias,
DeploymentConfig = 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:
LambdaApplication application;
var deploymentGroup = LambdaDeploymentGroup.FromLambdaDeploymentGroupAttributes(this, "ExistingCodeDeployDeploymentGroup", new LambdaDeploymentGroupAttributes {
Application = application,
DeploymentGroupName = "MyExistingDeploymentGroup"
});
Lambda Deployment Configurations
CodeDeploy for Lambda comes with predefined configurations for traffic shifting. The predefined configurations are available as LambdaDeploymentConfig constants.
LambdaApplication application;
Alias alias;
var config = LambdaDeploymentConfig.CANARY_10PERCENT_30MINUTES;
var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
Application = application,
Alias = 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.
LambdaApplication application;
Alias alias;
var config = new LambdaDeploymentConfig(this, "CustomConfig", new LambdaDeploymentConfigProps {
TrafficRouting = new TimeBasedCanaryTrafficRouting(new TimeBasedCanaryTrafficRoutingProps {
Interval = Duration.Minutes(15),
Percentage = 5
})
});
var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
Application = application,
Alias = 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.
var config = new LambdaDeploymentConfig(this, "CustomConfig", new LambdaDeploymentConfigProps {
TrafficRouting = new TimeBasedCanaryTrafficRouting(new TimeBasedCanaryTrafficRoutingProps {
Interval = Duration.Minutes(15),
Percentage = 5
}),
DeploymentConfigName = "MyDeploymentConfig"
});
To import an already existing Deployment Config:
var deploymentConfig = LambdaDeploymentConfig.FromLambdaDeploymentConfigName(this, "ExistingDeploymentConfiguration", "MyExistingDeploymentConfiguration");
ECS Applications
To create a new CodeDeploy Application that deploys an ECS service:
var application = new EcsApplication(this, "CodeDeployApplication", new EcsApplicationProps {
ApplicationName = "MyApplication"
});
To import an already existing Application:
var application = 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:
EcsApplication myApplication;
Cluster cluster;
FargateTaskDefinition taskDefinition;
ITargetGroup blueTargetGroup;
ITargetGroup greenTargetGroup;
IApplicationListener listener;
var service = new FargateService(this, "Service", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
DeploymentController = new DeploymentController {
Type = DeploymentControllerType.CODE_DEPLOY
}
});
new EcsDeploymentGroup(this, "BlueGreenDG", new EcsDeploymentGroupProps {
Service = service,
BlueGreenDeploymentConfig = new EcsBlueGreenDeploymentConfig {
BlueTargetGroup = blueTargetGroup,
GreenTargetGroup = greenTargetGroup,
Listener = listener
},
DeploymentConfig = 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 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
construct is the recommended approach instead of using the EcsDeploymentGroup
construct. For a comparison
of ECS blue-green deployments through CodeDeploy (using EcsDeploymentGroup
) and through CloudFormation (using CfnCodeDeployBlueGreenHook
),
see Create an Amazon ECS blue/green deployment through AWS CloudFormation
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.
using Amazon.CDK.AWS.CloudWatch;
FargateService service;
ApplicationTargetGroup blueTargetGroup;
ApplicationTargetGroup greenTargetGroup;
IApplicationListener listener;
// Alarm on the number of unhealthy ECS tasks in each target group
var blueUnhealthyHosts = new Alarm(this, "BlueUnhealthyHosts", new AlarmProps {
AlarmName = Stack.Of(this).StackName + "-Unhealthy-Hosts-Blue",
Metric = blueTargetGroup.MetricUnhealthyHostCount(),
Threshold = 1,
EvaluationPeriods = 2
});
var greenUnhealthyHosts = new Alarm(this, "GreenUnhealthyHosts", new AlarmProps {
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
var blueApiFailure = new Alarm(this, "Blue5xx", new AlarmProps {
AlarmName = Stack.Of(this).StackName + "-Http-5xx-Blue",
Metric = blueTargetGroup.MetricHttpCodeTarget(HttpCodeTarget.TARGET_5XX_COUNT, new MetricOptions { Period = Duration.Minutes(1) }),
Threshold = 1,
EvaluationPeriods = 1
});
var greenApiFailure = new Alarm(this, "Green5xx", new AlarmProps {
AlarmName = Stack.Of(this).StackName + "-Http-5xx-Green",
Metric = greenTargetGroup.MetricHttpCodeTarget(HttpCodeTarget.TARGET_5XX_COUNT, new MetricOptions { Period = Duration.Minutes(1) }),
Threshold = 1,
EvaluationPeriods = 1
});
new EcsDeploymentGroup(this, "BlueGreenDG", new EcsDeploymentGroupProps {
// CodeDeploy will monitor these alarms during a deployment and automatically roll back
Alarms = new [] { blueUnhealthyHosts, greenUnhealthyHosts, blueApiFailure, greenApiFailure },
AutoRollback = new AutoRollbackConfig {
// CodeDeploy will automatically roll back if a deployment is stopped
StoppedDeployment = true
},
Service = service,
BlueGreenDeploymentConfig = new EcsBlueGreenDeploymentConfig {
BlueTargetGroup = blueTargetGroup,
GreenTargetGroup = greenTargetGroup,
Listener = listener
},
DeploymentConfig = 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.
EcsApplication myApplication;
FargateService service;
ITargetGroup blueTargetGroup;
ITargetGroup greenTargetGroup;
IApplicationListener listener;
IApplicationListener testListener;
new EcsDeploymentGroup(this, "BlueGreenDG", new EcsDeploymentGroupProps {
Service = service,
BlueGreenDeploymentConfig = new EcsBlueGreenDeploymentConfig {
BlueTargetGroup = blueTargetGroup,
GreenTargetGroup = greenTargetGroup,
Listener = listener,
TestListener = testListener
},
DeploymentConfig = 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
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.
FargateService service;
ITargetGroup blueTargetGroup;
ITargetGroup greenTargetGroup;
IApplicationListener listener;
IApplicationListener testListener;
new EcsDeploymentGroup(this, "BlueGreenDG", new EcsDeploymentGroupProps {
AutoRollback = new AutoRollbackConfig {
// CodeDeploy will automatically roll back if the 8-hour approval period times out and the deployment stops
StoppedDeployment = true
},
Service = service,
BlueGreenDeploymentConfig = new EcsBlueGreenDeploymentConfig {
// The deployment will wait for approval for up to 8 hours before stopping the deployment
DeploymentApprovalWaitTime = Duration.Hours(8),
BlueTargetGroup = blueTargetGroup,
GreenTargetGroup = greenTargetGroup,
Listener = listener,
TestListener = testListener
},
DeploymentConfig = 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.
using Amazon.CDK.AWS.CloudWatch;
FargateService service;
ITargetGroup blueTargetGroup;
ITargetGroup greenTargetGroup;
IApplicationListener listener;
Alarm blueUnhealthyHosts;
Alarm greenUnhealthyHosts;
Alarm blueApiFailure;
Alarm greenApiFailure;
new EcsDeploymentGroup(this, "BlueGreenDG", new EcsDeploymentGroupProps {
Service = service,
BlueGreenDeploymentConfig = new EcsBlueGreenDeploymentConfig {
BlueTargetGroup = blueTargetGroup,
GreenTargetGroup = greenTargetGroup,
Listener = 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 = new [] { blueUnhealthyHosts, greenUnhealthyHosts, blueApiFailure, greenApiFailure },
DeploymentConfig = EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES
});
Import an existing ECS Deployment Group
To import an already existing Deployment Group:
EcsApplication application;
var deploymentGroup = EcsDeploymentGroup.FromEcsDeploymentGroupAttributes(this, "ExistingCodeDeployDeploymentGroup", new EcsDeploymentGroupAttributes {
Application = application,
DeploymentGroupName = "MyExistingDeploymentGroup"
});
ECS Deployment Configurations
CodeDeploy for ECS comes with predefined configurations for traffic shifting. The predefined configurations are available as LambdaDeploymentConfig constants.
var config = 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.
new EcsDeploymentConfig(this, "CustomConfig", new EcsDeploymentConfigProps {
TrafficRouting = new TimeBasedCanaryTrafficRouting(new TimeBasedCanaryTrafficRoutingProps {
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.
var config = new EcsDeploymentConfig(this, "CustomConfig", new EcsDeploymentConfigProps {
TrafficRouting = new TimeBasedCanaryTrafficRouting(new TimeBasedCanaryTrafficRoutingProps {
Interval = Duration.Minutes(15),
Percentage = 5
}),
DeploymentConfigName = "MyDeploymentConfig"
});
Or import an existing one:
var deploymentConfig = EcsDeploymentConfig.FromEcsDeploymentConfigName(this, "ExistingDeploymentConfiguration", "MyExistingDeploymentConfiguration");
ECS Deployments
An experimental construct is available on the Construct Hub called @cdklabs/cdk-ecs-codedeploy that manages ECS CodeDeploy deployments.
IEcsDeploymentGroup deploymentGroup;
ITaskDefinition taskDefinition;
new EcsDeployment(new Dictionary<string, object> {
{ "deploymentGroup", deploymentGroup },
{ "targetService", new Struct {
TaskDefinition = taskDefinition,
ContainerName = "mycontainer",
ContainerPort = 80
} }
});
The deployment will use the AutoRollbackConfig for the EcsDeploymentGroup unless it is overridden in the deployment:
IEcsDeploymentGroup deploymentGroup;
ITaskDefinition taskDefinition;
new EcsDeployment(new Dictionary<string, object> {
{ "deploymentGroup", deploymentGroup },
{ "targetService", new Struct {
TaskDefinition = taskDefinition,
ContainerName = "mycontainer",
ContainerPort = 80
} },
{ "autoRollback", new Struct {
FailedDeployment = true,
DeploymentInAlarm = true,
StoppedDeployment = false
} }
});
By default, the CodeDeploy Deployment will timeout after 30 minutes. The timeout value can be overridden:
IEcsDeploymentGroup deploymentGroup;
ITaskDefinition taskDefinition;
new EcsDeployment(new Dictionary<string, object> {
{ "deploymentGroup", deploymentGroup },
{ "targetService", new Struct {
TaskDefinition = taskDefinition,
ContainerName = "mycontainer",
ContainerPort = 80
} },
{ "timeout", Duration.Minutes(60) }
});
Classes
AllAtOnceTrafficRouting | Define a traffic routing config of type 'AllAtOnce'. |
AutoRollbackConfig | The configuration for automatically rolling back deployments in a given Deployment Group. |
BaseDeploymentConfig | The base class for ServerDeploymentConfig, EcsDeploymentConfig, and LambdaDeploymentConfig deployment configurations. |
BaseDeploymentConfigOptions | Construction properties of |
BaseDeploymentConfigProps | Complete base deployment config properties that are required to be supplied by the implementation of the BaseDeploymentConfig class. |
BaseTrafficShiftingConfigProps | Common properties of traffic shifting routing configurations. |
CanaryTrafficRoutingConfig | Represents the configuration specific to canary traffic shifting. |
CfnApplication | The |
CfnApplicationProps | Properties for defining a |
CfnDeploymentConfig | The |
CfnDeploymentConfig.MinimumHealthyHostsPerZoneProperty | Information about the minimum number of healthy instances per Availability Zone. |
CfnDeploymentConfig.MinimumHealthyHostsProperty |
|
CfnDeploymentConfig.TimeBasedCanaryProperty | A configuration that shifts traffic from one version of a Lambda function or Amazon ECS task set to another in two increments. |
CfnDeploymentConfig.TimeBasedLinearProperty | 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 | 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 | Configure the |
CfnDeploymentConfigProps | Properties for defining a |
CfnDeploymentGroup | The |
CfnDeploymentGroup.AlarmConfigurationProperty | The |
CfnDeploymentGroup.AlarmProperty | The |
CfnDeploymentGroup.AutoRollbackConfigurationProperty | The |
CfnDeploymentGroup.BlueGreenDeploymentConfigurationProperty | Information about blue/green deployment options for a deployment group. |
CfnDeploymentGroup.BlueInstanceTerminationOptionProperty | Information about whether instances in the original environment are terminated when a blue/green deployment is successful. |
CfnDeploymentGroup.DeploymentProperty |
|
CfnDeploymentGroup.DeploymentReadyOptionProperty | Information about how traffic is rerouted to instances in a replacement environment in a blue/green deployment. |
CfnDeploymentGroup.DeploymentStyleProperty | 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 | Information about an Amazon EC2 tag filter. |
CfnDeploymentGroup.EC2TagSetListObjectProperty | The |
CfnDeploymentGroup.EC2TagSetProperty | The |
CfnDeploymentGroup.ECSServiceProperty | Contains the service and cluster names used to identify an Amazon ECS deployment's target. |
CfnDeploymentGroup.ELBInfoProperty | The |
CfnDeploymentGroup.GitHubLocationProperty |
|
CfnDeploymentGroup.GreenFleetProvisioningOptionProperty | Information about the instances that belong to the replacement environment in a blue/green deployment. |
CfnDeploymentGroup.LoadBalancerInfoProperty | The |
CfnDeploymentGroup.OnPremisesTagSetListObjectProperty | The |
CfnDeploymentGroup.OnPremisesTagSetProperty | The |
CfnDeploymentGroup.RevisionLocationProperty |
|
CfnDeploymentGroup.S3LocationProperty |
|
CfnDeploymentGroup.TagFilterProperty |
|
CfnDeploymentGroup.TargetGroupInfoProperty | The |
CfnDeploymentGroup.TargetGroupPairInfoProperty | Information about two target groups and how traffic is routed during an Amazon ECS deployment. |
CfnDeploymentGroup.TrafficRouteProperty | Information about a listener. |
CfnDeploymentGroup.TriggerConfigProperty | Information about notification triggers for the deployment group. |
CfnDeploymentGroupProps | Properties for defining a |
ComputePlatform | The compute platform of a deployment configuration. |
CustomLambdaDeploymentConfig | (deprecated) A custom Deployment Configuration for a Lambda Deployment Group. |
CustomLambdaDeploymentConfigProps | (deprecated) Properties of a reference to a CodeDeploy Lambda Deployment Configuration. |
CustomLambdaDeploymentConfigType | (deprecated) Lambda Deployment config type. |
EcsApplication | A CodeDeploy Application that deploys to an Amazon ECS service. |
EcsApplicationProps | Construction properties for |
EcsBlueGreenDeploymentConfig | Specify how the deployment behaves and how traffic is routed to the ECS service during a blue-green ECS deployment. |
EcsDeploymentConfig | A custom Deployment Configuration for an ECS Deployment Group. |
EcsDeploymentConfigProps | Construction properties of |
EcsDeploymentGroup | A CodeDeploy deployment group that orchestrates ECS blue-green deployments. |
EcsDeploymentGroupAttributes | Properties of a reference to a CodeDeploy ECS Deployment Group. |
EcsDeploymentGroupProps | Construction properties for |
InstanceTagSet | Represents a set of instance tag groups. |
LambdaApplication | A CodeDeploy Application that deploys to an AWS Lambda function. |
LambdaApplicationProps | Construction properties for |
LambdaDeploymentConfig | A custom Deployment Configuration for a Lambda Deployment Group. |
LambdaDeploymentConfigImportProps | Properties of a reference to a CodeDeploy Lambda Deployment Configuration. |
LambdaDeploymentConfigProps | Construction properties of |
LambdaDeploymentGroup | |
LambdaDeploymentGroupAttributes | Properties of a reference to a CodeDeploy Lambda Deployment Group. |
LambdaDeploymentGroupProps | Construction properties for |
LinearTrafficRoutingConfig | Represents the configuration specific to linear traffic shifting. |
LoadBalancer | An interface of an abstract load balancer, as needed by CodeDeploy. |
LoadBalancerGeneration | The generations of AWS load balancing solutions. |
MinimumHealthyHosts | Minimum number of healthy hosts for a server deployment. |
MinimumHealthyHostsPerZone | Minimum number of healthy hosts per availability zone for a server deployment. |
ServerApplication | A CodeDeploy Application that deploys to EC2/on-premise instances. |
ServerApplicationProps | Construction properties for |
ServerDeploymentConfig | A custom Deployment Configuration for an EC2/on-premise Deployment Group. |
ServerDeploymentConfigProps | Construction properties of |
ServerDeploymentGroup | A CodeDeploy Deployment Group that deploys to EC2/on-premise instances. |
ServerDeploymentGroupAttributes | Properties of a reference to a CodeDeploy EC2/on-premise Deployment Group. |
ServerDeploymentGroupProps | Construction properties for |
TimeBasedCanaryTrafficRouting | Define a traffic routing config of type 'TimeBasedCanary'. |
TimeBasedCanaryTrafficRoutingProps | Construction properties for |
TimeBasedLinearTrafficRouting | Define a traffic routing config of type 'TimeBasedLinear'. |
TimeBasedLinearTrafficRoutingProps | Construction properties for |
TrafficRouting | Represents how traffic is shifted during a CodeDeploy deployment. |
TrafficRoutingConfig | Represents the structure to pass into the underlying CfnDeploymentConfig class. |
ZonalConfig | Configuration for CodeDeploy to deploy your application to one Availability Zone at a time within an AWS Region. |
Interfaces
CfnDeploymentConfig.IMinimumHealthyHostsPerZoneProperty | Information about the minimum number of healthy instances per Availability Zone. |
CfnDeploymentConfig.IMinimumHealthyHostsProperty |
|
CfnDeploymentConfig.ITimeBasedCanaryProperty | A configuration that shifts traffic from one version of a Lambda function or Amazon ECS task set to another in two increments. |
CfnDeploymentConfig.ITimeBasedLinearProperty | 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.ITrafficRoutingConfigProperty | 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.IZonalConfigProperty | Configure the |
CfnDeploymentGroup.IAlarmConfigurationProperty | The |
CfnDeploymentGroup.IAlarmProperty | The |
CfnDeploymentGroup.IAutoRollbackConfigurationProperty | The |
CfnDeploymentGroup.IBlueGreenDeploymentConfigurationProperty | Information about blue/green deployment options for a deployment group. |
CfnDeploymentGroup.IBlueInstanceTerminationOptionProperty | Information about whether instances in the original environment are terminated when a blue/green deployment is successful. |
CfnDeploymentGroup.IDeploymentProperty |
|
CfnDeploymentGroup.IDeploymentReadyOptionProperty | Information about how traffic is rerouted to instances in a replacement environment in a blue/green deployment. |
CfnDeploymentGroup.IDeploymentStyleProperty | 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.IEC2TagFilterProperty | Information about an Amazon EC2 tag filter. |
CfnDeploymentGroup.IEC2TagSetListObjectProperty | The |
CfnDeploymentGroup.IEC2TagSetProperty | The |
CfnDeploymentGroup.IECSServiceProperty | Contains the service and cluster names used to identify an Amazon ECS deployment's target. |
CfnDeploymentGroup.IELBInfoProperty | The |
CfnDeploymentGroup.IGitHubLocationProperty |
|
CfnDeploymentGroup.IGreenFleetProvisioningOptionProperty | Information about the instances that belong to the replacement environment in a blue/green deployment. |
CfnDeploymentGroup.ILoadBalancerInfoProperty | The |
CfnDeploymentGroup.IOnPremisesTagSetListObjectProperty | The |
CfnDeploymentGroup.IOnPremisesTagSetProperty | The |
CfnDeploymentGroup.IRevisionLocationProperty |
|
CfnDeploymentGroup.IS3LocationProperty |
|
CfnDeploymentGroup.ITagFilterProperty |
|
CfnDeploymentGroup.ITargetGroupInfoProperty | The |
CfnDeploymentGroup.ITargetGroupPairInfoProperty | Information about two target groups and how traffic is routed during an Amazon ECS deployment. |
CfnDeploymentGroup.ITrafficRouteProperty | Information about a listener. |
CfnDeploymentGroup.ITriggerConfigProperty | Information about notification triggers for the deployment group. |
IAutoRollbackConfig | The configuration for automatically rolling back deployments in a given Deployment Group. |
IBaseDeploymentConfig | The base class for ServerDeploymentConfig, EcsDeploymentConfig, and LambdaDeploymentConfig deployment configurations. |
IBaseDeploymentConfigOptions | Construction properties of |
IBaseDeploymentConfigProps | Complete base deployment config properties that are required to be supplied by the implementation of the BaseDeploymentConfig class. |
IBaseTrafficShiftingConfigProps | Common properties of traffic shifting routing configurations. |
ICanaryTrafficRoutingConfig | Represents the configuration specific to canary traffic shifting. |
ICfnApplicationProps | Properties for defining a |
ICfnDeploymentConfigProps | Properties for defining a |
ICfnDeploymentGroupProps | Properties for defining a |
ICustomLambdaDeploymentConfigProps | (deprecated) Properties of a reference to a CodeDeploy Lambda Deployment Configuration. |
IEcsApplication | Represents a reference to a CodeDeploy Application deploying to Amazon ECS. |
IEcsApplicationProps | Construction properties for |
IEcsBlueGreenDeploymentConfig | Specify how the deployment behaves and how traffic is routed to the ECS service during a blue-green ECS deployment. |
IEcsDeploymentConfig | The Deployment Configuration of an ECS Deployment Group. |
IEcsDeploymentConfigProps | Construction properties of |
IEcsDeploymentGroup | Interface for an ECS deployment group. |
IEcsDeploymentGroupAttributes | Properties of a reference to a CodeDeploy ECS Deployment Group. |
IEcsDeploymentGroupProps | Construction properties for |
ILambdaApplication | Represents a reference to a CodeDeploy Application deploying to AWS Lambda. |
ILambdaApplicationProps | Construction properties for |
ILambdaDeploymentConfig | The Deployment Configuration of a Lambda Deployment Group. |
ILambdaDeploymentConfigImportProps | Properties of a reference to a CodeDeploy Lambda Deployment Configuration. |
ILambdaDeploymentConfigProps | Construction properties of |
ILambdaDeploymentGroup | Interface for a Lambda deployment groups. |
ILambdaDeploymentGroupAttributes | Properties of a reference to a CodeDeploy Lambda Deployment Group. |
ILambdaDeploymentGroupProps | Construction properties for |
ILinearTrafficRoutingConfig | Represents the configuration specific to linear traffic shifting. |
IServerApplication | Represents a reference to a CodeDeploy Application deploying to EC2/on-premise instances. |
IServerApplicationProps | Construction properties for |
IServerDeploymentConfig | The Deployment Configuration of an EC2/on-premise Deployment Group. |
IServerDeploymentConfigProps | Construction properties of |
IServerDeploymentGroup | |
IServerDeploymentGroupAttributes | Properties of a reference to a CodeDeploy EC2/on-premise Deployment Group. |
IServerDeploymentGroupProps | Construction properties for |
ITimeBasedCanaryTrafficRoutingProps | Construction properties for |
ITimeBasedLinearTrafficRoutingProps | Construction properties for |
ITrafficRoutingConfig | Represents the structure to pass into the underlying CfnDeploymentConfig class. |
IZonalConfig | Configuration for CodeDeploy to deploy your application to one Availability Zone at a time within an AWS Region. |