aws-cdk-lib.aws_ecs.Compatibility

enum Compatibility

LanguageType name
.NETAmazon.CDK.AWS.ECS.Compatibility
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#Compatibility
Javasoftware.amazon.awscdk.services.ecs.Compatibility
Pythonaws_cdk.aws_ecs.Compatibility
TypeScript (source)aws-cdk-lib » aws_ecs » Compatibility

The task launch type compatibility requirement.

Example

const vpc = ec2.Vpc.fromLookup(this, 'Vpc', {
  isDefault: true,
});

const cluster = new ecs.Cluster(this, 'Ec2Cluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
  instanceType: new ec2.InstanceType('t2.micro'),
  vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
});

const taskDefinition = new ecs.TaskDefinition(this, 'TD', {
  compatibility: ecs.Compatibility.EC2,
});

taskDefinition.addContainer('TheContainer', {
  image: ecs.ContainerImage.fromRegistry('foo/bar'),
  memoryLimitMiB: 256,
});

const runTask = new tasks.EcsRunTask(this, 'Run', {
  integrationPattern: sfn.IntegrationPattern.RUN_JOB,
  cluster,
  taskDefinition,
  launchTarget: new tasks.EcsEc2LaunchTarget({
    placementStrategies: [
      ecs.PlacementStrategy.spreadAcrossInstances(),
      ecs.PlacementStrategy.packedByCpu(),
      ecs.PlacementStrategy.randomly(),
    ],
    placementConstraints: [
      ecs.PlacementConstraint.memberOf('blieptuut'),
    ],
  }),
  propagatedTagSource: ecs.PropagatedTagSource.TASK_DEFINITION,
});

Members

NameDescription
EC2The task should specify the EC2 launch type.
FARGATEThe task should specify the Fargate launch type.
EC2_AND_FARGATEThe task can specify either the EC2 or Fargate launch types.
EXTERNALThe task should specify the External launch type.

EC2

The task should specify the EC2 launch type.


FARGATE

The task should specify the Fargate launch type.


EC2_AND_FARGATE

The task can specify either the EC2 or Fargate launch types.


EXTERNAL

The task should specify the External launch type.