EcsEc2LaunchTargetOptions
- class aws_cdk.aws_stepfunctions_tasks.EcsEc2LaunchTargetOptions(*, capacity_provider_options=None, placement_constraints=None, placement_strategies=None)
Bases:
objectOptions to run an ECS task on EC2 in StepFunctions and ECS.
- Parameters:
capacity_provider_options (
Optional[CapacityProviderOptions]) – The capacity provider options to use for the task. This property allows you to set the capacity provider strategy for the task. If you want to set the capacity provider strategy for the task, specifyCapacityProviderOptions.custom(). If you want to use the cluster’s default capacity provider strategy, specifyCapacityProviderOptions.default(). Default: - ‘EC2’ LaunchType running tasks on Amazon EC2 instances registered to your cluster is used without the capacity provider strategy.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
- capacity_provider_options
The capacity provider options to use for the task.
This property allows you to set the capacity provider strategy for the task.
If you want to set the capacity provider strategy for the task, specify
CapacityProviderOptions.custom().If you want to use the cluster’s default capacity provider strategy, specify
CapacityProviderOptions.default().- Default:
‘EC2’ LaunchType running tasks on Amazon EC2 instances registered to
your cluster is used without the capacity provider strategy.
- placement_constraints
Placement constraints.
- Default:
None
- placement_strategies
Placement strategies.
- Default:
None