Skip to content

Commit

Permalink
Merge branch 'master' into benisrae/oidc-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel authored May 6, 2020
2 parents 254388b + 2923c44 commit 82a7666
Show file tree
Hide file tree
Showing 24 changed files with 140 additions and 59 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudtrail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@aws-cdk/aws-sns": "0.0.0",
"@aws-cdk/aws-sqs": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codecommit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@aws-cdk/assert": "0.0.0",
"@aws-cdk/aws-sns": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-codepipeline-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@
},
"keywords": [
"aws",
"aws-clib",
"aws-cloudlib",
"cdk",
"cloudlib",
"constructs",
"codepipeline",
"pipeline"
],
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-codepipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@
},
"keywords": [
"aws",
"aws-clib",
"aws-cloudlib",
"cdk",
"cloudlib",
"constructs",
"codepipeline",
"pipeline"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@types/jest": "^25.2.1",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"aws-sdk-mock": "^5.1.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,18 @@ 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,
launchType: props.deploymentController?.type === DeploymentControllerType.EXTERNAL ? undefined : props.launchType,
healthCheckGracePeriodSeconds: this.evaluateHealthGracePeriod(props.healthCheckGracePeriod),
/* role: never specified, supplanted by Service Linked Role */
networkConfiguration: Lazy.anyValue({ produce: () => this.networkConfiguration }, { omitEmptyArray: true }),
serviceRegistries: Lazy.anyValue({ produce: () => this.serviceRegistries }, { omitEmptyArray: true }),
...additionalProps,
});

if (props.deploymentController?.type === DeploymentControllerType.EXTERNAL) {
this.node.addWarning('taskDefinition and launchType are blanked out when using external deployment controller.');
}

this.serviceArn = this.getResourceArnAttribute(this.resource.ref, {
service: 'ecs',
resource: 'service',
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import { Construct, Lazy, Resource, Stack } from '@aws-cdk/core';
import { BaseService, BaseServiceOptions, IBaseService, IService, LaunchType, PropagatedTagSource } from '../base/base-service';
import { BaseService, BaseServiceOptions, DeploymentControllerType, IBaseService, IService, LaunchType, PropagatedTagSource } from '../base/base-service';
import { fromServiceAtrributes } from '../base/from-service-attributes';
import { NetworkMode, TaskDefinition } from '../base/task-definition';
import { ICluster } from '../cluster';
Expand Down Expand Up @@ -154,8 +154,8 @@ export class Ec2Service extends BaseService implements IEc2Service {
throw new Error('Maximum percent must be 100 for daemon mode.');
}

if (props.daemon && props.minHealthyPercent !== undefined && props.minHealthyPercent !== 0) {
throw new Error('Minimum healthy percent must be 0 for daemon mode.');
if (props.minHealthyPercent !== undefined && props.maxHealthyPercent !== undefined && props.minHealthyPercent >= props.maxHealthyPercent) {
throw new Error('Minimum healthy percent must be less than maximum healthy percent.');
}

if (!props.taskDefinition.isEc2Compatible) {
Expand All @@ -181,7 +181,7 @@ export class Ec2Service extends BaseService implements IEc2Service {
},
{
cluster: props.cluster.clusterName,
taskDefinition: props.taskDefinition.taskDefinitionArn,
taskDefinition: props.deploymentController?.type === DeploymentControllerType.EXTERNAL ? undefined : props.taskDefinition.taskDefinitionArn,
placementConstraints: Lazy.anyValue({ produce: () => this.constraints }, { omitEmptyArray: true }),
placementStrategies: Lazy.anyValue({ produce: () => this.strategies }, { omitEmptyArray: true }),
schedulingStrategy: props.daemon ? 'DAEMON' : 'REPLICA',
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import { BaseService, BaseServiceOptions, IBaseService, IService, LaunchType, PropagatedTagSource } from '../base/base-service';
import { BaseService, BaseServiceOptions, DeploymentControllerType, IBaseService, IService, LaunchType, PropagatedTagSource } from '../base/base-service';
import { fromServiceAtrributes } from '../base/from-service-attributes';
import { TaskDefinition } from '../base/task-definition';
import { ICluster } from '../cluster';
Expand Down Expand Up @@ -139,7 +139,7 @@ export class FargateService extends BaseService implements IFargateService {
enableECSManagedTags: props.enableECSManagedTags,
}, {
cluster: props.cluster.clusterName,
taskDefinition: props.taskDefinition.taskDefinitionArn,
taskDefinition: props.deploymentController?.type === DeploymentControllerType.EXTERNAL ? undefined : props.taskDefinition.taskDefinitionArn,
platformVersion: props.platformVersion,
}, props.taskDefinition);

Expand Down
48 changes: 44 additions & 4 deletions packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as cloudmap from '@aws-cdk/aws-servicediscovery';
import * as cdk from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as ecs from '../../lib';
import { LaunchType, PropagatedTagSource } from '../../lib/base/base-service';
import { DeploymentControllerType, LaunchType, PropagatedTagSource } from '../../lib/base/base-service';
import { PlacementConstraint, PlacementStrategy } from '../../lib/placement';

export = {
Expand Down Expand Up @@ -262,6 +262,45 @@ export = {
test.done();
},

'ignore task definition and launch type if deployment controller is set to be EXTERNAL'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', { instanceType: new ec2.InstanceType('t2.micro') });
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef');

taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
memoryLimitMiB: 512,
});

const service = new ecs.Ec2Service(stack, 'Ec2Service', {
cluster,
taskDefinition,
deploymentController: {
type: DeploymentControllerType.EXTERNAL,
},
});

// THEN
test.deepEqual(service.node.metadata[0].data, 'taskDefinition and launchType are blanked out when using external deployment controller.');
expect(stack).to(haveResource('AWS::ECS::Service', {
Cluster: {
Ref: 'EcsCluster97242B84',
},
DeploymentConfiguration: {
MaximumPercent: 200,
MinimumHealthyPercent: 50,
},
DesiredCount: 1,
SchedulingStrategy: 'REPLICA',
EnableECSManagedTags: false,
}));

test.done();
},

'errors if daemon and desiredCount both specified'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down Expand Up @@ -312,7 +351,7 @@ export = {
test.done();
},

'errors if daemon and minimum not 0'(test: Test) {
'errors if minimum not less than maximum'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'MyVpc', {});
Expand All @@ -330,9 +369,10 @@ export = {
cluster,
taskDefinition,
daemon: true,
minHealthyPercent: 50,
minHealthyPercent: 100,
maxHealthyPercent: 100,
});
}, /Minimum healthy percent must be 0 for daemon mode./);
}, /Minimum healthy percent must be less than maximum healthy percent./);

test.done();
},
Expand Down
62 changes: 61 additions & 1 deletion packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as cloudmap from '@aws-cdk/aws-servicediscovery';
import * as cdk from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as ecs from '../../lib';
import { LaunchType } from '../../lib/base/base-service';
import { DeploymentControllerType, LaunchType } from '../../lib/base/base-service';

export = {
'When creating a Fargate Service': {
Expand Down Expand Up @@ -301,6 +301,66 @@ export = {
test.done();
},

'ignore task definition and launch type if deployment controller is set to be EXTERNAL'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'MyVpc', {});
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');

taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
});

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

// THEN
test.deepEqual(service.node.metadata[0].data, 'taskDefinition and launchType are blanked out when using external deployment controller.');
expect(stack).to(haveResource('AWS::ECS::Service', {
Cluster: {
Ref: 'EcsCluster97242B84',
},
DeploymentConfiguration: {
MaximumPercent: 200,
MinimumHealthyPercent: 50,
},
DeploymentController: {
Type: 'EXTERNAL',
},
DesiredCount: 1,
EnableECSManagedTags: false,
NetworkConfiguration: {
AwsvpcConfiguration: {
AssignPublicIp: 'DISABLED',
SecurityGroups: [
{
'Fn::GetAtt': [
'FargateServiceSecurityGroup0A0E79CB',
'GroupId',
],
},
],
Subnets: [
{
Ref: 'MyVpcPrivateSubnet1Subnet5057CF7E',
},
{
Ref: 'MyVpcPrivateSubnet2Subnet0040C983',
},
],
},
},
}));

test.done();
},

'errors when no container specified on task definition'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"keywords": [
"aws",
"cdk",
"cloudlib",
"aws-cloudlib",
"aws-clib"
"constructs",
"elasticloadbalancing",
"elb"
],
"author": {
"name": "Amazon Web Services",
Expand Down
6 changes: 2 additions & 4 deletions packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
"keywords": [
"aws",
"cdk",
"cloudlib",
"aws-cloudlib",
"aws-clib",
"constructs",
"cloudwatch",
"events"
],
Expand All @@ -86,7 +84,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@aws-cdk/aws-codecommit": "0.0.0",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"aws-sdk-mock": "^5.1.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"keywords": [
"aws",
"cdk",
"cloudlib",
"aws-cloudlib",
"aws-clib"
"constructs",
"cloudwatch",
"events"
],
"author": {
"name": "Amazon Web Services",
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-iam/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
"keywords": [
"aws",
"cdk",
"cloudlib",
"aws-cloudlib",
"aws-clib",
"constructs",
"iam"
],
"author": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@types/lodash": "^4.14.150",
"@types/nodeunit": "^0.0.30",
"@types/sinon": "^9.0.0",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"aws-sdk-mock": "^5.1.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-route53/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-sqs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@aws-cdk/assert": "0.0.0",
"@aws-cdk/aws-s3": "0.0.0",
"@types/nodeunit": "^0.0.30",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/custom-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@types/aws-lambda": "^8.10.39",
"@types/fs-extra": "^8.1.0",
"@types/sinon": "^9.0.0",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"aws-sdk-mock": "^5.1.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"@aws-cdk/region-info": "0.0.0",
"archiver": "^4.0.1",
"aws-sdk": "^2.668.0",
"aws-sdk": "^2.669.0",
"camelcase": "^6.0.0",
"cdk-assets": "0.0.0",
"colors": "^1.4.0",
Expand Down
Loading

0 comments on commit 82a7666

Please sign in to comment.