PlacementStrategy

class aws_cdk.aws_ecs.PlacementStrategy

Bases: object

The placement strategies to use for tasks in the service. For more information, see Amazon ECS Task Placement Strategies.

Tasks will preferentially be placed on instances that match these rules.

Methods

to_json()

Return the placement JSON.

Return type

List[PlacementStrategyProperty]

Static Methods

classmethod packed_by(resource)

Places tasks on the container instances with the least available capacity of the specified resource.

Parameters

resource (BinPackResource) –

Return type

PlacementStrategy

classmethod packed_by_cpu()

Places tasks on container instances with the least available amount of CPU capacity.

This minimizes the number of instances in use.

Return type

PlacementStrategy

classmethod packed_by_memory()

Places tasks on container instances with the least available amount of memory capacity.

This minimizes the number of instances in use.

Return type

PlacementStrategy

classmethod randomly()

Places tasks randomly.

Return type

PlacementStrategy

classmethod spread_across(*fields)

Places tasks evenly based on the specified value.

You can use one of the built-in attributes found on BuiltInAttributes or supply your own custom instance attributes. If more than one attribute is supplied, spreading is done in order.

Parameters

fields (str) –

default :default: attributes instanceId

Return type

PlacementStrategy

classmethod spread_across_instances()

Places tasks evenly across all container instances in the cluster.

Return type

PlacementStrategy