Interface EcsEc2LaunchTargetOptions
- All Superinterfaces:
software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
EcsEc2LaunchTargetOptions.Jsii$Proxy
@Generated(value="jsii-pacmak/1.125.0 (build fdbe357)",
date="2026-01-09T10:20:27.718Z")
@Stability(Stable)
public interface EcsEc2LaunchTargetOptions
extends software.amazon.jsii.JsiiSerializable
Options to run an ECS task on EC2 in StepFunctions and ECS.
Example:
IVpc vpc = Vpc.fromLookup(this, "Vpc", VpcLookupOptions.builder()
.isDefault(true)
.build());
Cluster cluster = Cluster.Builder.create(this, "Ec2Cluster").vpc(vpc).build();
cluster.addCapacity("DefaultAutoScalingGroup", AddCapacityOptions.builder()
.instanceType(new InstanceType("t2.micro"))
.vpcSubnets(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build())
.build());
TaskDefinition taskDefinition = TaskDefinition.Builder.create(this, "TD")
.compatibility(Compatibility.EC2)
.build();
taskDefinition.addContainer("TheContainer", ContainerDefinitionOptions.builder()
.image(ContainerImage.fromRegistry("foo/bar"))
.memoryLimitMiB(256)
.build());
EcsRunTask runTask = EcsRunTask.Builder.create(this, "Run")
.integrationPattern(IntegrationPattern.RUN_JOB)
.cluster(cluster)
.taskDefinition(taskDefinition)
.launchTarget(EcsEc2LaunchTarget.Builder.create()
.placementStrategies(List.of(PlacementStrategy.spreadAcrossInstances(), PlacementStrategy.packedByCpu(), PlacementStrategy.randomly()))
.placementConstraints(List.of(PlacementConstraint.memberOf("blieptuut")))
.build())
.propagatedTagSource(PropagatedTagSource.TASK_DEFINITION)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA builder forEcsEc2LaunchTargetOptionsstatic final classAn implementation forEcsEc2LaunchTargetOptions -
Method Summary
Modifier and TypeMethodDescriptionbuilder()default CapacityProviderOptionsThe capacity provider options to use for the task.default List<PlacementConstraint> Placement constraints.default List<PlacementStrategy> Placement strategies.Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getCapacityProviderOptions
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().Default: - 'EC2' LaunchType running tasks on Amazon EC2 instances registered to your cluster is used without the capacity provider strategy.
-
getPlacementConstraints
Placement constraints.Default: - None
-
getPlacementStrategies
Placement strategies.Default: - None
-
builder
- Returns:
- a
EcsEc2LaunchTargetOptions.BuilderofEcsEc2LaunchTargetOptions
-