Class: AWSCDK::ECSPatterns::ScheduledEC2Task

Inherits:
ScheduledTaskBase
  • Object
show all
Defined in:
ecs_patterns/scheduled_ec2_task.rb

Overview

A scheduled EC2 task that will be initiated off of CloudWatch Events.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ ScheduledEC2Task

Constructs a new instance of the ScheduledEc2Task class.

Parameters:



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

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::ECSPatterns::ScheduledEC2TaskProps.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("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzX3BhdHRlcm5zLlNjaGVkdWxlZEVjMlRhc2tQcm9wcyJ9")), "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
38
39
# File 'ecs_patterns/scheduled_ec2_task.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 },
    :task => { kind: :property, name: "task", is_optional: false },
    :task_definition => { kind: :property, name: "taskDefinition", is_optional: false },
    :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:



142
143
144
145
# File 'ecs_patterns/scheduled_ec2_task.rb', line 142

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:



151
152
153
154
# File 'ecs_patterns/scheduled_ec2_task.rb', line 151

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.



51
52
53
# File 'ecs_patterns/scheduled_ec2_task.rb', line 51

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:



160
161
162
163
# File 'ecs_patterns/scheduled_ec2_task.rb', line 160

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)


60
61
62
# File 'ecs_patterns/scheduled_ec2_task.rb', line 60

def desired_task_count()
  jsii_get_property("desiredTaskCount")
end

#event_ruleAWSCDK::Events::Rule

The CloudWatch Events rule for the service.



67
68
69
# File 'ecs_patterns/scheduled_ec2_task.rb', line 67

def event_rule()
  jsii_get_property("eventRule")
end

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

Returns the default cluster.

Parameters:

Returns:



170
171
172
173
174
# File 'ecs_patterns/scheduled_ec2_task.rb', line 170

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)


44
45
46
# File 'ecs_patterns/scheduled_ec2_task.rb', line 44

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.



87
88
89
# File 'ecs_patterns/scheduled_ec2_task.rb', line 87

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)



77
78
79
# File 'ecs_patterns/scheduled_ec2_task.rb', line 77

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:



97
98
99
# File 'ecs_patterns/scheduled_ec2_task.rb', line 97

def tags()
  jsii_get_property("tags")
end

#taskAWSCDK::EventsTargets::ECSTask

The ECS task in this construct.



104
105
106
# File 'ecs_patterns/scheduled_ec2_task.rb', line 104

def task()
  jsii_get_property("task")
end

#task_definitionAWSCDK::ECS::EC2TaskDefinition

The EC2 task definition in this construct.



111
112
113
# File 'ecs_patterns/scheduled_ec2_task.rb', line 111

def task_definition()
  jsii_get_property("taskDefinition")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


118
119
120
# File 'ecs_patterns/scheduled_ec2_task.rb', line 118

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



131
132
133
134
135
136
# File 'ecs_patterns/scheduled_ec2_task.rb', line 131

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