interface EcsEc2LaunchTargetOptions
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.StepFunctions.Tasks.EcsEc2LaunchTargetOptions |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctionstasks#EcsEc2LaunchTargetOptions |
Java | software.amazon.awscdk.services.stepfunctions.tasks.EcsEc2LaunchTargetOptions |
Python | aws_cdk.aws_stepfunctions_tasks.EcsEc2LaunchTargetOptions |
TypeScript (source) | aws-cdk-lib » aws_stepfunctions_tasks » EcsEc2LaunchTargetOptions |
Options to run an ECS task on EC2 in StepFunctions and ECS.
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,
});
Properties
| Name | Type | Description |
|---|---|---|
| capacity | Capacity | The capacity provider options to use for the task. |
| placement | Placement[] | Placement constraints. |
| placement | Placement[] | Placement strategies. |
capacityProviderOptions?
Type:
Capacity
(optional, default: 'EC2' LaunchType running tasks on Amazon EC2 instances registered to
your cluster is used without the capacity provider strategy.)
The capacity provider options to use for the task.
This property allows you to set the capacity provider strategy for the task.
If you want to set the capacity provider strategy for the task, specify
CapacityProviderOptions.custom().
If you want to use the cluster's default capacity provider strategy, specify
CapacityProviderOptions.default().
placementConstraints?
Type:
Placement[]
(optional, default: None)
Placement constraints.
placementStrategies?
Type:
Placement[]
(optional, default: None)
Placement strategies.

.NET
Go
Java
Python
TypeScript (