@@ -6,7 +6,7 @@ import * as cloudmap from '@aws-cdk/aws-servicediscovery';
6
6
import * as cdk from '@aws-cdk/core' ;
7
7
import { Test } from 'nodeunit' ;
8
8
import * as ecs from '../../lib' ;
9
- import { LaunchType , PropagatedTagSource } from '../../lib/base/base-service' ;
9
+ import { DeploymentControllerType , LaunchType , PropagatedTagSource } from '../../lib/base/base-service' ;
10
10
import { PlacementConstraint , PlacementStrategy } from '../../lib/placement' ;
11
11
12
12
export = {
@@ -262,6 +262,45 @@ export = {
262
262
test . done ( ) ;
263
263
} ,
264
264
265
+ 'ignore task definition and launch type if deployment controller is set to be EXTERNAL' ( test : Test ) {
266
+ // GIVEN
267
+ const stack = new cdk . Stack ( ) ;
268
+ const vpc = new ec2 . Vpc ( stack , 'MyVpc' , { } ) ;
269
+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' , { vpc } ) ;
270
+ cluster . addCapacity ( 'DefaultAutoScalingGroup' , { instanceType : new ec2 . InstanceType ( 't2.micro' ) } ) ;
271
+ const taskDefinition = new ecs . Ec2TaskDefinition ( stack , 'Ec2TaskDef' ) ;
272
+
273
+ taskDefinition . addContainer ( 'web' , {
274
+ image : ecs . ContainerImage . fromRegistry ( 'amazon/amazon-ecs-sample' ) ,
275
+ memoryLimitMiB : 512 ,
276
+ } ) ;
277
+
278
+ const service = new ecs . Ec2Service ( stack , 'Ec2Service' , {
279
+ cluster,
280
+ taskDefinition,
281
+ deploymentController : {
282
+ type : DeploymentControllerType . EXTERNAL ,
283
+ } ,
284
+ } ) ;
285
+
286
+ // THEN
287
+ test . deepEqual ( service . node . metadata [ 0 ] . data , 'taskDefinition and launchType are blanked out when using external deployment controller.' ) ;
288
+ expect ( stack ) . to ( haveResource ( 'AWS::ECS::Service' , {
289
+ Cluster : {
290
+ Ref : 'EcsCluster97242B84' ,
291
+ } ,
292
+ DeploymentConfiguration : {
293
+ MaximumPercent : 200 ,
294
+ MinimumHealthyPercent : 50 ,
295
+ } ,
296
+ DesiredCount : 1 ,
297
+ SchedulingStrategy : 'REPLICA' ,
298
+ EnableECSManagedTags : false ,
299
+ } ) ) ;
300
+
301
+ test . done ( ) ;
302
+ } ,
303
+
265
304
'errors if daemon and desiredCount both specified' ( test : Test ) {
266
305
// GIVEN
267
306
const stack = new cdk . Stack ( ) ;
@@ -312,7 +351,7 @@ export = {
312
351
test . done ( ) ;
313
352
} ,
314
353
315
- 'errors if daemon and minimum not 0 ' ( test : Test ) {
354
+ 'errors if minimum not less than maximum ' ( test : Test ) {
316
355
// GIVEN
317
356
const stack = new cdk . Stack ( ) ;
318
357
const vpc = new ec2 . Vpc ( stack , 'MyVpc' , { } ) ;
@@ -330,9 +369,10 @@ export = {
330
369
cluster,
331
370
taskDefinition,
332
371
daemon : true ,
333
- minHealthyPercent : 50 ,
372
+ minHealthyPercent : 100 ,
373
+ maxHealthyPercent : 100 ,
334
374
} ) ;
335
- } , / M i n i m u m h e a l t h y p e r c e n t m u s t b e 0 f o r d a e m o n m o d e ./ ) ;
375
+ } , / M i n i m u m h e a l t h y p e r c e n t m u s t b e l e s s t h a n m a x i m u m h e a l t h y p e r c e n t ./ ) ;
336
376
337
377
test . done ( ) ;
338
378
} ,
0 commit comments