Class: AWSCDK::ECS::PlacementStrategy

Inherits:
Jsii::Object
  • Object
show all
Defined in:
ecs/placement_strategy.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PlacementStrategy

Returns a new instance of PlacementStrategy.

Raises:

  • (NoMethodError)


10
11
12
# File 'ecs/placement_strategy.rb', line 10

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.aws_ecs.PlacementStrategy does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.jsii_overridable_methodsObject



14
15
16
17
18
# File 'ecs/placement_strategy.rb', line 14

def self.jsii_overridable_methods
  {
    :to_json => { kind: :method, name: "toJson", is_optional: false },
  }
end

.packed_by(resource) ⇒ AWSCDK::ECS::PlacementStrategy

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

Parameters:

Returns:

  • (AWSCDK::ECS::PlacementStrategy)


24
25
26
27
# File 'ecs/placement_strategy.rb', line 24

def self.packed_by(resource)
  Jsii::Type.check_type(resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkJpblBhY2tSZXNvdXJjZSJ9")), "resource")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.PlacementStrategy", "packedBy", [resource])
end

.packed_by_cpuAWSCDK::ECS::PlacementStrategy

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

This minimizes the number of instances in use.

Returns:

  • (AWSCDK::ECS::PlacementStrategy)


34
35
36
# File 'ecs/placement_strategy.rb', line 34

def self.packed_by_cpu()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.PlacementStrategy", "packedByCpu", [])
end

.packed_by_memoryAWSCDK::ECS::PlacementStrategy

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

This minimizes the number of instances in use.

Returns:

  • (AWSCDK::ECS::PlacementStrategy)


43
44
45
# File 'ecs/placement_strategy.rb', line 43

def self.packed_by_memory()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.PlacementStrategy", "packedByMemory", [])
end

.randomlyAWSCDK::ECS::PlacementStrategy

Places tasks randomly.

Returns:

  • (AWSCDK::ECS::PlacementStrategy)


50
51
52
# File 'ecs/placement_strategy.rb', line 50

def self.randomly()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.PlacementStrategy", "randomly", [])
end

.spread_across(*fields) ⇒ AWSCDK::ECS::PlacementStrategy

Note:

Default: attributes instanceId

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 (Array<String>)

Returns:

  • (AWSCDK::ECS::PlacementStrategy)


63
64
65
66
67
68
# File 'ecs/placement_strategy.rb', line 63

def self.spread_across(*fields)
  fields.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fields[#{index}]")
  end
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.PlacementStrategy", "spreadAcross", [*fields])
end

.spread_across_instancesAWSCDK::ECS::PlacementStrategy

Places tasks evenly across all container instances in the cluster.

Returns:

  • (AWSCDK::ECS::PlacementStrategy)


73
74
75
# File 'ecs/placement_strategy.rb', line 73

def self.spread_across_instances()
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.PlacementStrategy", "spreadAcrossInstances", [])
end

Instance Method Details

#to_jsonArray<AWSCDK::ECS::CfnService::PlacementStrategyProperty>

Return the placement JSON.



80
81
82
# File 'ecs/placement_strategy.rb', line 80

def to_json()
  jsii_call_method("toJson", [])
end