@@ -425,6 +425,215 @@ describe('create runner', () => {
425425 } ) ,
426426 } ) ;
427427 } ) ;
428+
429+ it ( 'overrides SubnetId when specified in ec2OverrideConfig' , async ( ) => {
430+ await createRunner ( {
431+ ...createRunnerConfig ( defaultRunnerConfig ) ,
432+ ec2OverrideConfig : {
433+ SubnetId : 'subnet-override' ,
434+ } ,
435+ } ) ;
436+
437+ expect ( mockEC2Client ) . toHaveReceivedCommandWith ( CreateFleetCommand , {
438+ LaunchTemplateConfigs : [
439+ {
440+ LaunchTemplateSpecification : {
441+ LaunchTemplateName : 'lt-1' ,
442+ Version : '$Default' ,
443+ } ,
444+ Overrides : [
445+ {
446+ InstanceType : 'm5.large' ,
447+ SubnetId : 'subnet-override' ,
448+ } ,
449+ {
450+ InstanceType : 'c5.large' ,
451+ SubnetId : 'subnet-override' ,
452+ } ,
453+ ] ,
454+ } ,
455+ ] ,
456+ SpotOptions : {
457+ AllocationStrategy : SpotAllocationStrategy . CAPACITY_OPTIMIZED ,
458+ } ,
459+ TagSpecifications : expect . any ( Array ) ,
460+ TargetCapacitySpecification : {
461+ DefaultTargetCapacityType : 'spot' ,
462+ TotalTargetCapacity : 1 ,
463+ } ,
464+ Type : 'instant' ,
465+ } ) ;
466+ } ) ;
467+
468+ it ( 'overrides InstanceType when specified in ec2OverrideConfig' , async ( ) => {
469+ await createRunner ( {
470+ ...createRunnerConfig ( defaultRunnerConfig ) ,
471+ ec2OverrideConfig : {
472+ InstanceType : 't3.xlarge' ,
473+ } ,
474+ } ) ;
475+
476+ expect ( mockEC2Client ) . toHaveReceivedCommandWith ( CreateFleetCommand , {
477+ LaunchTemplateConfigs : [
478+ {
479+ LaunchTemplateSpecification : {
480+ LaunchTemplateName : 'lt-1' ,
481+ Version : '$Default' ,
482+ } ,
483+ Overrides : [
484+ {
485+ InstanceType : 't3.xlarge' ,
486+ SubnetId : 'subnet-123' ,
487+ } ,
488+ {
489+ InstanceType : 't3.xlarge' ,
490+ SubnetId : 'subnet-456' ,
491+ } ,
492+ ] ,
493+ } ,
494+ ] ,
495+ SpotOptions : {
496+ AllocationStrategy : SpotAllocationStrategy . CAPACITY_OPTIMIZED ,
497+ } ,
498+ TagSpecifications : expect . any ( Array ) ,
499+ TargetCapacitySpecification : {
500+ DefaultTargetCapacityType : 'spot' ,
501+ TotalTargetCapacity : 1 ,
502+ } ,
503+ Type : 'instant' ,
504+ } ) ;
505+ } ) ;
506+
507+ it ( 'overrides ImageId when specified in ec2OverrideConfig' , async ( ) => {
508+ await createRunner ( {
509+ ...createRunnerConfig ( defaultRunnerConfig ) ,
510+ ec2OverrideConfig : {
511+ ImageId : 'ami-override-123' ,
512+ } ,
513+ } ) ;
514+
515+ expect ( mockEC2Client ) . toHaveReceivedCommandWith ( CreateFleetCommand , {
516+ LaunchTemplateConfigs : [
517+ {
518+ LaunchTemplateSpecification : {
519+ LaunchTemplateName : 'lt-1' ,
520+ Version : '$Default' ,
521+ } ,
522+ Overrides : [
523+ {
524+ InstanceType : 'm5.large' ,
525+ SubnetId : 'subnet-123' ,
526+ ImageId : 'ami-override-123' ,
527+ } ,
528+ {
529+ InstanceType : 'c5.large' ,
530+ SubnetId : 'subnet-123' ,
531+ ImageId : 'ami-override-123' ,
532+ } ,
533+ {
534+ InstanceType : 'm5.large' ,
535+ SubnetId : 'subnet-456' ,
536+ ImageId : 'ami-override-123' ,
537+ } ,
538+ {
539+ InstanceType : 'c5.large' ,
540+ SubnetId : 'subnet-456' ,
541+ ImageId : 'ami-override-123' ,
542+ } ,
543+ ] ,
544+ } ,
545+ ] ,
546+ SpotOptions : {
547+ AllocationStrategy : SpotAllocationStrategy . CAPACITY_OPTIMIZED ,
548+ } ,
549+ TagSpecifications : expect . any ( Array ) ,
550+ TargetCapacitySpecification : {
551+ DefaultTargetCapacityType : 'spot' ,
552+ TotalTargetCapacity : 1 ,
553+ } ,
554+ Type : 'instant' ,
555+ } ) ;
556+ } ) ;
557+
558+ it ( 'overrides all three fields (SubnetId, InstanceType, ImageId) when specified in ec2OverrideConfig' , async ( ) => {
559+ await createRunner ( {
560+ ...createRunnerConfig ( defaultRunnerConfig ) ,
561+ ec2OverrideConfig : {
562+ SubnetId : 'subnet-custom' ,
563+ InstanceType : 'c5.2xlarge' ,
564+ ImageId : 'ami-custom-456' ,
565+ } ,
566+ } ) ;
567+
568+ expect ( mockEC2Client ) . toHaveReceivedCommandWith ( CreateFleetCommand , {
569+ LaunchTemplateConfigs : [
570+ {
571+ LaunchTemplateSpecification : {
572+ LaunchTemplateName : 'lt-1' ,
573+ Version : '$Default' ,
574+ } ,
575+ Overrides : [
576+ {
577+ InstanceType : 'c5.2xlarge' ,
578+ SubnetId : 'subnet-custom' ,
579+ ImageId : 'ami-custom-456' ,
580+ } ,
581+ ] ,
582+ } ,
583+ ] ,
584+ SpotOptions : {
585+ AllocationStrategy : SpotAllocationStrategy . CAPACITY_OPTIMIZED ,
586+ } ,
587+ TagSpecifications : expect . any ( Array ) ,
588+ TargetCapacitySpecification : {
589+ DefaultTargetCapacityType : 'spot' ,
590+ TotalTargetCapacity : 1 ,
591+ } ,
592+ Type : 'instant' ,
593+ } ) ;
594+ } ) ;
595+
596+ it ( 'spreads additional ec2OverrideConfig properties to Overrides' , async ( ) => {
597+ await createRunner ( {
598+ ...createRunnerConfig ( defaultRunnerConfig ) ,
599+ ec2OverrideConfig : {
600+ SubnetId : 'subnet-override' ,
601+ InstanceType : 't3.medium' ,
602+ MaxPrice : '0.05' ,
603+ Priority : 1.5 ,
604+ WeightedCapacity : 2.0 ,
605+ } ,
606+ } ) ;
607+
608+ expect ( mockEC2Client ) . toHaveReceivedCommandWith ( CreateFleetCommand , {
609+ LaunchTemplateConfigs : [
610+ {
611+ LaunchTemplateSpecification : {
612+ LaunchTemplateName : 'lt-1' ,
613+ Version : '$Default' ,
614+ } ,
615+ Overrides : [
616+ {
617+ InstanceType : 't3.medium' ,
618+ SubnetId : 'subnet-override' ,
619+ MaxPrice : '0.05' ,
620+ Priority : 1.5 ,
621+ WeightedCapacity : 2.0 ,
622+ } ,
623+ ] ,
624+ } ,
625+ ] ,
626+ SpotOptions : {
627+ AllocationStrategy : SpotAllocationStrategy . CAPACITY_OPTIMIZED ,
628+ } ,
629+ TagSpecifications : expect . any ( Array ) ,
630+ TargetCapacitySpecification : {
631+ DefaultTargetCapacityType : 'spot' ,
632+ TotalTargetCapacity : 1 ,
633+ } ,
634+ Type : 'instant' ,
635+ } ) ;
636+ } ) ;
428637} ) ;
429638
430639describe ( 'create runner with errors' , ( ) => {
0 commit comments