@@ -462,7 +462,8 @@ export class TaskDefinition extends TaskDefinitionBase {
462462 props . volumes . forEach ( v => this . addVolume ( v ) ) ;
463463 }
464464
465- this . networkMode = props . networkMode ?? ( this . isFargateCompatible ? NetworkMode . AWS_VPC : NetworkMode . BRIDGE ) ;
465+ this . networkMode = props . networkMode ??
466+ ( this . isFargateCompatible || this . isManagedInstancesCompatible ? NetworkMode . AWS_VPC : NetworkMode . BRIDGE ) ;
466467 if ( this . isFargateCompatible && this . networkMode !== NetworkMode . AWS_VPC ) {
467468 throw new ValidationError ( `Fargate tasks can only have AwsVpc network mode, got: ${ this . networkMode } ` , this ) ;
468469 }
@@ -492,19 +493,29 @@ export class TaskDefinition extends TaskDefinitionBase {
492493 throw new ValidationError ( `Managed Instances tasks can only have AwsVpc or Host network mode, got: ${ this . networkMode } ` , this ) ;
493494 }
494495
495- // Managed Instances require both CPU and memory specifications
496- if ( ! props . cpu || ! props . memoryMiB ) {
497- throw new ValidationError ( `Managed Instances-compatible tasks require both CPU (${ props . cpu } ) and memory (${ props . memoryMiB } ) specifications` , this ) ;
498- }
499-
500496 // Managed Instances don't support inference accelerators
501497 if ( props . inferenceAccelerators && props . inferenceAccelerators . length > 0 ) {
502498 throw new ValidationError ( 'Cannot use inference accelerators on tasks that run on Managed Instances' , this ) ;
503499 }
504500
505- // Managed Instances don't support placement constraints
506- if ( props . placementConstraints && props . placementConstraints . length > 0 ) {
507- throw new ValidationError ( 'Cannot set placement constraints on tasks that run on Managed Instances' , this ) ;
501+ // Managed Instances don't support ephemeral storage
502+ if ( props . ephemeralStorageGiB ) {
503+ throw new ValidationError ( 'Ephemeral storage is not supported for tasks running on Managed Instances' , this ) ;
504+ }
505+
506+ // Managed Instances don't support IPC mode
507+ if ( props . ipcMode ) {
508+ throw new ValidationError ( 'IPC mode is not supported for tasks running on Managed Instances' , this ) ;
509+ }
510+
511+ // Managed Instances don't support proxy configuration
512+ if ( props . proxyConfiguration ) {
513+ throw new ValidationError ( 'Proxy configuration is not supported for tasks running on Managed Instances' , this ) ;
514+ }
515+
516+ // Managed Instances only support LINUX operating system family
517+ if ( props . runtimePlatform ?. operatingSystemFamily && ! props . runtimePlatform . operatingSystemFamily . isLinux ( ) ) {
518+ throw new ValidationError ( `Managed Instances tasks only support LINUX operating system family, got: ${ props . runtimePlatform . operatingSystemFamily . _operatingSystemFamily } ` , this ) ;
508519 }
509520 }
510521
@@ -556,7 +567,7 @@ export class TaskDefinition extends TaskDefinitionBase {
556567 networkMode : this . renderNetworkMode ( this . networkMode ) ,
557568 placementConstraints : Lazy . any ( {
558569 produce : ( ) =>
559- ! isFargateCompatible ( this . compatibility ) ? this . placementConstraints : undefined ,
570+ ! isFargateCompatible ( this . compatibility ) && ! isManagedInstancesCompatible ( this . compatibility ) ? this . placementConstraints : undefined ,
560571 } , { omitEmptyArray : true } ) ,
561572 proxyConfiguration : props . proxyConfiguration ? props . proxyConfiguration . bind ( this . stack , this ) : undefined ,
562573 cpu : props . cpu ,
@@ -566,7 +577,7 @@ export class TaskDefinition extends TaskDefinitionBase {
566577 ephemeralStorage : this . ephemeralStorageGiB ? {
567578 sizeInGiB : this . ephemeralStorageGiB ,
568579 } : undefined ,
569- runtimePlatform : this . isFargateCompatible && this . runtimePlatform ? {
580+ runtimePlatform : ( this . isFargateCompatible || this . isManagedInstancesCompatible ) && this . runtimePlatform ? {
570581 cpuArchitecture : this . runtimePlatform ?. cpuArchitecture ?. _cpuArchitecture ,
571582 operatingSystemFamily : this . runtimePlatform ?. operatingSystemFamily ?. _operatingSystemFamily ,
572583 } : undefined ,
@@ -751,6 +762,10 @@ export class TaskDefinition extends TaskDefinitionBase {
751762
752763 private validateVolume ( volume : Volume ) : void {
753764 if ( volume . configuredAtLaunch !== true ) {
765+ // Validate DockerVolumeConfiguration is not used with Managed Instances
766+ if ( this . isManagedInstancesCompatible && volume . dockerVolumeConfiguration ) {
767+ throw new ValidationError ( `DockerVolumeConfiguration is not supported for tasks running on Managed Instances. Volume '${ volume . name } ' cannot use dockerVolumeConfiguration` , this ) ;
768+ }
754769 return ;
755770 }
756771
0 commit comments