EcsEc2LaunchTargetOptions
- class aws_cdk.aws_stepfunctions_tasks.EcsEc2LaunchTargetOptions(*, placement_constraints=None, placement_strategies=None)
Bases:
object
Options to run an ECS task on EC2 in StepFunctions and ECS.
- Parameters:
placement_constraints (
Optional
[Sequence
[PlacementConstraint
]]) – Placement constraints. Default: - Noneplacement_strategies (
Optional
[Sequence
[PlacementStrategy
]]) – Placement strategies. Default: - None
- 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 )
Attributes
- placement_constraints
Placement constraints.
- Default:
None
- placement_strategies
Placement strategies.
- Default:
None