Class: AWSCDK::ECSPatterns::ScheduledTaskBase

Inherits:
Constructs::Construct
  • Object
show all
Defined in:
ecs_patterns/scheduled_task_base.rb

Overview

The base class for ScheduledEc2Task and ScheduledFargateTask tasks.

Direct Known Subclasses

ScheduledEC2Task, ScheduledFargateTask

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ ScheduledTaskBase

Constructs a new instance of the ScheduledTaskBase class.

Parameters:



13
14
15
16
17
18
19
# File 'ecs_patterns/scheduled_task_base.rb', line 13

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::ECSPatterns::ScheduledTaskBaseProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzX3BhdHRlcm5zLlNjaGVkdWxlZFRhc2tCYXNlUHJvcHMifQ==")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.jsii_overridable_methodsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'ecs_patterns/scheduled_task_base.rb', line 21

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :cluster => { kind: :property, name: "cluster", is_optional: false },
    :desired_task_count => { kind: :property, name: "desiredTaskCount", is_optional: false },
    :event_rule => { kind: :property, name: "eventRule", is_optional: false },
    :subnet_selection => { kind: :property, name: "subnetSelection", is_optional: false },
    :propagate_tags => { kind: :property, name: "propagateTags", is_optional: true },
    :tags => { kind: :property, name: "tags", is_optional: true },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :add_task_as_target => { kind: :method, name: "addTaskAsTarget", is_optional: false },
    :add_task_definition_to_event_target => { kind: :method, name: "addTaskDefinitionToEventTarget", is_optional: false },
    :create_aws_log_driver => { kind: :method, name: "createAWSLogDriver", is_optional: false },
    :get_default_cluster => { kind: :method, name: "getDefaultCluster", is_optional: false },
  }
end

Instance Method Details

#add_task_as_target(ecs_task_target) ⇒ void

This method returns an undefined value.

Adds task as a target of the scheduled event rule.

Parameters:



126
127
128
129
# File 'ecs_patterns/scheduled_task_base.rb', line 126

def add_task_as_target(ecs_task_target)
  Jsii::Type.check_type(ecs_task_target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzX3RhcmdldHMuRWNzVGFzayJ9")), "ecsTaskTarget")
  jsii_call_method("addTaskAsTarget", [ecs_task_target])
end

#add_task_definition_to_event_target(task_definition) ⇒ AWSCDK::EventsTargets::ECSTask

Create an ECS task using the task definition provided and add it to the scheduled event rule.

Parameters:

Returns:



135
136
137
138
# File 'ecs_patterns/scheduled_task_base.rb', line 135

def add_task_definition_to_event_target(task_definition)
  Jsii::Type.check_type(task_definition, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlRhc2tEZWZpbml0aW9uIn0=")), "taskDefinition")
  jsii_call_method("addTaskDefinitionToEventTarget", [task_definition])
end

#clusterAWSCDK::ECS::ICluster

The name of the cluster that hosts the service.



49
50
51
# File 'ecs_patterns/scheduled_task_base.rb', line 49

def cluster()
  jsii_get_property("cluster")
end

#create_aws_log_driver(prefix) ⇒ AWSCDK::ECS::AWSLogDriver

Create an AWS Log Driver with the provided streamPrefix.

Parameters:

  • prefix (String)

    the Cloudwatch logging prefix.

Returns:



144
145
146
147
# File 'ecs_patterns/scheduled_task_base.rb', line 144

def create_aws_log_driver(prefix)
  Jsii::Type.check_type(prefix, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "prefix")
  jsii_call_method("createAWSLogDriver", [prefix])
end

#desired_task_countNumeric

The desired number of instantiations of the task definition to keep running on the service.

The minimum value is 1

Returns:

  • (Numeric)


58
59
60
# File 'ecs_patterns/scheduled_task_base.rb', line 58

def desired_task_count()
  jsii_get_property("desiredTaskCount")
end

#event_ruleAWSCDK::Events::Rule

The CloudWatch Events rule for the service.



65
66
67
# File 'ecs_patterns/scheduled_task_base.rb', line 65

def event_rule()
  jsii_get_property("eventRule")
end

#get_default_cluster(scope, vpc = nil) ⇒ AWSCDK::ECS::Cluster

Returns the default cluster.

Parameters:

Returns:



154
155
156
157
158
# File 'ecs_patterns/scheduled_task_base.rb', line 154

def get_default_cluster(scope, vpc = nil)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(vpc, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklWcGMifQ==")), "vpc") unless vpc.nil?
  jsii_call_method("getDefaultCluster", [scope, vpc])
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


42
43
44
# File 'ecs_patterns/scheduled_task_base.rb', line 42

def node()
  jsii_get_property("node")
end

#propagate_tagsAWSCDK::ECS::PropagatedTagSource?

Note:

Default: - Tags will not be propagated

Specifies whether to propagate the tags from the task definition to the task.

If no value is specified, the tags are not propagated.



85
86
87
# File 'ecs_patterns/scheduled_task_base.rb', line 85

def propagate_tags()
  jsii_get_property("propagateTags")
end

#subnet_selectionAWSCDK::EC2::SubnetSelection

Note:

Default: Private subnets

In what subnets to place the task's ENIs.

(Only applicable in case the TaskDefinition is configured for AwsVpc networking)



75
76
77
# File 'ecs_patterns/scheduled_task_base.rb', line 75

def subnet_selection()
  jsii_get_property("subnetSelection")
end

#tagsArray<AWSCDK::EventsTargets::Tag>?

Note:

Default: - No tags are applied to the task

The metadata that you apply to the task to help you categorize and organize them.

Each tag consists of a key and an optional value, both of which you define.

Returns:



95
96
97
# File 'ecs_patterns/scheduled_task_base.rb', line 95

def tags()
  jsii_get_property("tags")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


102
103
104
# File 'ecs_patterns/scheduled_task_base.rb', line 102

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



115
116
117
118
119
120
# File 'ecs_patterns/scheduled_task_base.rb', line 115

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end