EcsEc2LaunchTarget
- class aws_cdk.aws_stepfunctions_tasks.EcsEc2LaunchTarget(*, placement_constraints=None, placement_strategies=None)
Bases:
object
Configuration for running an ECS task on EC2.
- See:
- ExampleMetadata:
infused
Example:
vpc = ec2.Vpc.from_lookup(self, "Vpc", is_default=True ) cluster = ecs.Cluster(self, "Ec2Cluster", vpc=vpc) cluster.add_capacity("DefaultAutoScalingGroup", instance_type=ec2.InstanceType("t2.micro"), vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC) ) task_definition = ecs.TaskDefinition(self, "TD", compatibility=ecs.Compatibility.EC2 ) task_definition.add_container("TheContainer", image=ecs.ContainerImage.from_registry("foo/bar"), memory_limit_mi_b=256 ) run_task = tasks.EcsRunTask(self, "Run", integration_pattern=sfn.IntegrationPattern.RUN_JOB, cluster=cluster, task_definition=task_definition, launch_target=tasks.EcsEc2LaunchTarget( placement_strategies=[ ecs.PlacementStrategy.spread_across_instances(), ecs.PlacementStrategy.packed_by_cpu(), ecs.PlacementStrategy.randomly() ], placement_constraints=[ ecs.PlacementConstraint.member_of("blieptuut") ] ), propagated_tag_source=ecs.PropagatedTagSource.TASK_DEFINITION )
- Parameters:
placement_constraints (
Optional
[Sequence
[PlacementConstraint
]]) – Placement constraints. Default: - Noneplacement_strategies (
Optional
[Sequence
[PlacementStrategy
]]) – Placement strategies. Default: - None
Methods
- bind(_task, *, task_definition, cluster=None)
Called when the EC2 launch type is configured on RunTask.
- Parameters:
_task (
EcsRunTask
) –task_definition (
ITaskDefinition
) – Task definition to run Docker containers in Amazon ECS.cluster (
Optional
[ICluster
]) – A regional grouping of one or more container instances on which you can run tasks and services. Default: - No cluster
- Return type: