@Generated(value="jsii-pacmak/1.73.0 (build 6faeda3)",
date="2023-01-31T18:37:00.434Z")
public class PlacementConstraint
extends software.amazon.jsii.JsiiObject
Tasks will only be placed on instances that match these rules.
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()) .build();
Modifier | Constructor and Description |
---|---|
protected |
PlacementConstraint(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
PlacementConstraint(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
static PlacementConstraint |
distinctInstances()
Use distinctInstance to ensure that each task in a particular group is running on a different container instance.
|
static PlacementConstraint |
memberOf(java.lang.String... expressions)
Use memberOf to restrict the selection to a group of valid candidates specified by a query expression.
|
java.util.List<CfnService.PlacementConstraintProperty> |
toJson()
Return the placement JSON.
|
protected PlacementConstraint(software.amazon.jsii.JsiiObjectRef objRef)
protected PlacementConstraint(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public static PlacementConstraint distinctInstances()
public static PlacementConstraint memberOf(java.lang.String... expressions)
Multiple expressions can be specified. For more information, see Cluster Query Language.
You can specify multiple expressions in one call. The tasks will only be placed on instances matching all expressions.
expressions
- This parameter is required.public java.util.List<CfnService.PlacementConstraintProperty> toJson()