Class EcsEc2LaunchTarget
Configuration for running an ECS task on EC2.
Inheritance
System.Object
EcsEc2LaunchTarget
Implements
Namespace: Amazon.CDK.AWS.StepFunctions.Tasks
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class EcsEc2LaunchTarget : DeputyBase, IEcsLaunchTarget
Syntax (vb)
Public Class EcsEc2LaunchTarget
Inherits DeputyBase
Implements IEcsLaunchTarget
Remarks
See: https://docs.aws.amazon.com/AmazonECS/latest/userguide/launch_types.html#launch-type-ec2
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
EcsEc2LaunchTarget(IEcsEc2LaunchTargetOptions) | |
EcsEc2LaunchTarget(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
EcsEc2LaunchTarget(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
Bind(EcsRunTask, ILaunchTargetBindOptions) | Called when the EC2 launch type is configured on RunTask. |
Constructors
EcsEc2LaunchTarget(IEcsEc2LaunchTargetOptions)
public EcsEc2LaunchTarget(IEcsEc2LaunchTargetOptions options = null)
Parameters
- options IEcsEc2LaunchTargetOptions
EcsEc2LaunchTarget(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected EcsEc2LaunchTarget(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
EcsEc2LaunchTarget(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected EcsEc2LaunchTarget(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
Bind(EcsRunTask, ILaunchTargetBindOptions)
Called when the EC2 launch type is configured on RunTask.
public virtual IEcsLaunchTargetConfig Bind(EcsRunTask task, ILaunchTargetBindOptions launchTargetOptions)
Parameters
- task EcsRunTask
- launchTargetOptions ILaunchTargetBindOptions
Returns