Class EcsEc2LaunchTargetOptions
Options to run an ECS task on EC2 in StepFunctions and ECS.
Inheritance
System.Object
EcsEc2LaunchTargetOptions
Implements
Namespace: Amazon.CDK.AWS.StepFunctions.Tasks
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class EcsEc2LaunchTargetOptions : Object, IEcsEc2LaunchTargetOptions
Syntax (vb)
Public Class EcsEc2LaunchTargetOptions
Inherits Object
Implements IEcsEc2LaunchTargetOptions
Remarks
ExampleMetadata: infused
Examples
var vpc = Vpc.FromLookup(this, "Vpc", new VpcLookupOptions {
IsDefault = true
});
var cluster = new Cluster(this, "Ec2Cluster", new ClusterProps { Vpc = vpc });
cluster.AddCapacity("DefaultAutoScalingGroup", new AddCapacityOptions {
InstanceType = new InstanceType("t2.micro"),
VpcSubnets = new SubnetSelection { SubnetType = SubnetType.PUBLIC }
});
var taskDefinition = new TaskDefinition(this, "TD", new TaskDefinitionProps {
Compatibility = Compatibility.EC2
});
taskDefinition.AddContainer("TheContainer", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("foo/bar"),
MemoryLimitMiB = 256
});
var runTask = new EcsRunTask(this, "Run", new EcsRunTaskProps {
IntegrationPattern = IntegrationPattern.RUN_JOB,
Cluster = cluster,
TaskDefinition = taskDefinition,
LaunchTarget = new EcsEc2LaunchTarget(new EcsEc2LaunchTargetOptions {
PlacementStrategies = new [] { PlacementStrategy.SpreadAcrossInstances(), PlacementStrategy.PackedByCpu(), PlacementStrategy.Randomly() },
PlacementConstraints = new [] { PlacementConstraint.MemberOf("blieptuut") }
}),
PropagatedTagSource = PropagatedTagSource.TASK_DEFINITION
});
Synopsis
Constructors
EcsEc2LaunchTargetOptions() |
Properties
PlacementConstraints | Placement constraints. |
PlacementStrategies | Placement strategies. |
Constructors
EcsEc2LaunchTargetOptions()
public EcsEc2LaunchTargetOptions()
Properties
PlacementConstraints
Placement constraints.
public PlacementConstraint[] PlacementConstraints { get; set; }
Property Value
Remarks
Default: - None
PlacementStrategies
Placement strategies.
public PlacementStrategy[] PlacementStrategies { get; set; }
Property Value
Remarks
Default: - None