Class: LambdaWhenever::TargetLambda

Inherits:
Object
  • Object
show all
Defined in:
lib/lambda_whenever/target_lambda.rb

Overview

The TargetLambda class represents a Lambda function as a target for scheduling.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arn:, task:) ⇒ TargetLambda

Returns a new instance of TargetLambda.



17
18
19
20
21
# File 'lib/lambda_whenever/target_lambda.rb', line 17

def initialize(arn:, task:)
  @arn = arn
  @task = task
  @input = input_json
end

Instance Attribute Details

#arnObject (readonly)

Returns the value of attribute arn.



6
7
8
# File 'lib/lambda_whenever/target_lambda.rb', line 6

def arn
  @arn
end

#inputObject (readonly)

Returns the value of attribute input.



6
7
8
# File 'lib/lambda_whenever/target_lambda.rb', line 6

def input
  @input
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/lambda_whenever/target_lambda.rb', line 6

def name
  @name
end

#role_arnObject (readonly)

Returns the value of attribute role_arn.



6
7
8
# File 'lib/lambda_whenever/target_lambda.rb', line 6

def role_arn
  @role_arn
end

#taskObject (readonly)

Returns the value of attribute task.



6
7
8
# File 'lib/lambda_whenever/target_lambda.rb', line 6

def task
  @task
end

Class Method Details

.fetch_arn(function_name, client) ⇒ Object



9
10
11
12
13
14
# File 'lib/lambda_whenever/target_lambda.rb', line 9

def fetch_arn(function_name, client)
  response = client.get_function({
                                   function_name: function_name
                                 })
  response.configuration.function_arn
end

Instance Method Details

#input_jsonObject



24
25
26
27
28
29
30
31
32
# File 'lib/lambda_whenever/target_lambda.rb', line 24

def input_json
  {
    execution_id: "<aws.scheduler.execution-id>",
    scheduled_time: "<aws.scheduler.scheduled-time>",
    schedule_arn: "<aws.scheduler.schedule-arn>",
    attempt_number: "<aws.scheduler.attempt-number>",
    commands: task.commands
  }.to_json
end