@@ -7,7 +7,7 @@ import { addConstructMetadata, MethodMetadata } from '../../../core/lib/metadata
77import  {  propertyInjectable  }  from  '../../../core/lib/prop-injectable' ; 
88import  {  IAlternateTarget  }  from  '../alternate-target-configuration' ; 
99import  {  ContainerDefinition ,  ContainerDefinitionOptions ,  PortMapping ,  Protocol  }  from  '../container-definition' ; 
10- import  {  CfnTaskDefinition  }  from  '../ecs.generated' ; 
10+ import  {  CfnTaskDefinition ,   CfnTaskDefinitionProps  }  from  '../ecs.generated' ; 
1111import  {  FirelensLogRouter ,  FirelensLogRouterDefinitionOptions ,  FirelensLogRouterType ,  obtainDefaultFluentBitECRImage  }  from  '../firelens-log-router' ; 
1212import  {  AwsLogDriver  }  from  '../log-drivers/aws-log-driver' ; 
1313import  {  PlacementConstraint  }  from  '../placement' ; 
@@ -506,7 +506,7 @@ export class TaskDefinition extends TaskDefinitionBase {
506506    this . _cpu  =  props . cpu ; 
507507    this . _memory  =  props . memoryMiB ; 
508508
509-     const   taskDef   =   new   CfnTaskDefinition ( this ,   'Resource' ,  { 
509+     let   taskDefProps :  CfnTaskDefinitionProps   =  { 
510510      containerDefinitions : Lazy . any ( {  produce : ( )  =>  this . renderContainers ( )  } ,  {  omitEmptyArray : true  } ) , 
511511      volumes : Lazy . any ( {  produce : ( )  =>  this . renderVolumes ( )  } ,  {  omitEmptyArray : true  } ) , 
512512      executionRoleArn : Lazy . string ( {  produce : ( )  =>  this . executionRole  &&  this . executionRole . roleArn  } ) , 
@@ -527,10 +527,6 @@ export class TaskDefinition extends TaskDefinitionBase {
527527      memory : props . memoryMiB , 
528528      ipcMode : props . ipcMode , 
529529      pidMode : this . pidMode , 
530-       inferenceAccelerators : Lazy . any ( { 
531-         produce : ( )  => 
532-           ! isFargateCompatible ( this . compatibility )  ? this . renderInferenceAccelerators ( )  : undefined , 
533-       } ,  {  omitEmptyArray : true  } ) , 
534530      ephemeralStorage : this . ephemeralStorageGiB  ? { 
535531        sizeInGiB : this . ephemeralStorageGiB , 
536532      }  : undefined , 
@@ -539,7 +535,19 @@ export class TaskDefinition extends TaskDefinitionBase {
539535        operatingSystemFamily : this . runtimePlatform ?. operatingSystemFamily ?. _operatingSystemFamily , 
540536      }  : undefined , 
541537      enableFaultInjection : props . enableFaultInjection , 
542-     } ) ; 
538+     } ; 
539+ 
540+     if  ( props . inferenceAccelerators )  { 
541+       taskDefProps  =  { 
542+         ...taskDefProps , 
543+         inferenceAccelerators : Lazy . any ( { 
544+           produce : ( )  => 
545+             this . renderInferenceAccelerators ( ) , 
546+         } ) , 
547+       } ; 
548+     } 
549+ 
550+     const  taskDef  =  new  CfnTaskDefinition ( this ,  'Resource' ,  taskDefProps ) ; 
543551
544552    if  ( props . placementConstraints )  { 
545553      props . placementConstraints . forEach ( pc  =>  this . addPlacementConstraint ( pc ) ) ; 
0 commit comments