Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecs): Add support for deployment controller #5402

Merged
merged 3 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ export interface IService extends IResource {
readonly serviceArn: string;
}

/**
* The deployment controller to use for the service.
*/
export interface DeploymentController {
/**
* The deployment controller type to use.
*
* @default DeploymentControllerType.ECS
*/
readonly type?: DeploymentControllerType;
}

export interface EcsTarget {
/**
* The name of the container.
Expand Down Expand Up @@ -133,6 +145,14 @@ export interface BaseServiceOptions {
* @default false
*/
readonly enableECSManagedTags?: boolean;

/**
* Specifies which deployment controller to use for the service. For more information, see
* [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html)
*
* @default - Rolling update (ECS)
*/
readonly deploymentController?: DeploymentController;
}

/**
Expand Down Expand Up @@ -308,6 +328,7 @@ export abstract class BaseService extends Resource
},
propagateTags: props.propagateTags === PropagatedTagSource.NONE ? undefined : props.propagateTags,
enableEcsManagedTags: props.enableECSManagedTags === undefined ? false : props.enableECSManagedTags,
deploymentController: props.deploymentController,
launchType: props.launchType,
healthCheckGracePeriodSeconds: this.evaluateHealthGracePeriod(props.healthCheckGracePeriod),
/* role: never specified, supplanted by Service Linked Role */
Expand Down Expand Up @@ -736,6 +757,27 @@ export enum LaunchType {
FARGATE = 'FARGATE'
}

/**
* The deployment controller type to use for the service.
*/
export enum DeploymentControllerType {
/**
* The rolling update (ECS) deployment type involves replacing the current
* running version of the container with the latest version.
*/
ECS = "ECS",

/**
* The blue/green (CODE_DEPLOY) deployment type uses the blue/green deployment model powered by AWS CodeDeploy
*/
CODE_DEPLOY = "CODE_DEPLOY",

/**
* The external (EXTERNAL) deployment type enables you to use any third-party deployment controller
*/
EXTERNAL = "EXTERNAL"
}

/**
* Propagate tags from either service or task definition
*/
Expand Down
8 changes: 7 additions & 1 deletion packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import elbv2 = require("@aws-cdk/aws-elasticloadbalancingv2");
import cloudmap = require('@aws-cdk/aws-servicediscovery');
import cdk = require('@aws-cdk/core');
import { Test } from 'nodeunit';
import { BinPackResource, BuiltInAttributes, ContainerImage, DeploymentControllerType, NetworkMode } from '../../lib';
import ecs = require('../../lib');
import { BinPackResource, BuiltInAttributes, ContainerImage, NetworkMode } from '../../lib';
import { LaunchType, PropagatedTagSource } from '../../lib/base/base-service';
import { PlacementConstraint, PlacementStrategy } from '../../lib/placement';

Expand Down Expand Up @@ -155,6 +155,9 @@ export = {
healthCheckGracePeriod: cdk.Duration.seconds(60),
maxHealthyPercent: 150,
minHealthyPercent: 55,
deploymentController: {
type: DeploymentControllerType.CODE_DEPLOY
},
securityGroup: new ec2.SecurityGroup(stack, 'SecurityGroup1', {
allowAllOutbound: true,
description: 'Example',
Expand All @@ -180,6 +183,9 @@ export = {
MaximumPercent: 150,
MinimumHealthyPercent: 55
},
DeploymentController: {
Type: DeploymentControllerType.CODE_DEPLOY
},
DesiredCount: 2,
LaunchType: LaunchType.EC2,
NetworkConfiguration: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import elbv2 = require("@aws-cdk/aws-elasticloadbalancingv2");
import cloudmap = require('@aws-cdk/aws-servicediscovery');
import cdk = require('@aws-cdk/core');
import { Test } from 'nodeunit';
import { ContainerImage, DeploymentControllerType } from '../../lib';
import ecs = require('../../lib');
import { ContainerImage } from '../../lib';
import { LaunchType } from '../../lib/base/base-service';

export = {
Expand Down Expand Up @@ -181,6 +181,9 @@ export = {
healthCheckGracePeriod: cdk.Duration.seconds(60),
maxHealthyPercent: 150,
minHealthyPercent: 55,
deploymentController: {
type: DeploymentControllerType.CODE_DEPLOY
},
securityGroup: new ec2.SecurityGroup(stack, 'SecurityGroup1', {
allowAllOutbound: true,
description: 'Example',
Expand All @@ -205,6 +208,9 @@ export = {
MaximumPercent: 150,
MinimumHealthyPercent: 55
},
DeploymentController: {
Type: DeploymentControllerType.CODE_DEPLOY
},
DesiredCount: 2,
HealthCheckGracePeriodSeconds: 60,
LaunchType: LaunchType.FARGATE,
Expand Down