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();
 
  • Method Details

    • getCapacityProviderOptions

      @Stability(Stable) @Nullable default CapacityProviderOptions 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

      @Stability(Stable) @Nullable default List<PlacementConstraint> getPlacementConstraints()
      Placement constraints.

      Default: - None

    • getPlacementStrategies

      @Stability(Stable) @Nullable default List<PlacementStrategy> getPlacementStrategies()
      Placement strategies.

      Default: - None

    • builder

      @Stability(Stable) static EcsEc2LaunchTargetOptions.Builder builder()
      Returns:
      a EcsEc2LaunchTargetOptions.Builder of EcsEc2LaunchTargetOptions