Module: WolfCore::LambdaFunctionDataSource

Defined in:
lib/wolf_core/infrastructure/lambda_function_data_source.rb

Class Method Summary collapse

Class Method Details

.clientObject



19
20
21
# File 'lib/wolf_core/infrastructure/lambda_function_data_source.rb', line 19

def client
  @@client
end

.initObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/wolf_core/infrastructure/lambda_function_data_source.rb', line 5

def init
  client_config = {
    access_key_id: ENV.fetch('AWS_KEY_ID', nil),
    secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', nil),
    region: ENV.fetch('AWS_REGION', nil),
    endpoint: ENV.fetch('AWS_LAMBDA_FUNCTION_ENDPOINT', nil),
  }

  client_config = client_config.compact
  return if client_config.empty?

  @@client = Aws::Lambda::Client.new(client_config)
end

.invoke(function_name:, payload:) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/wolf_core/infrastructure/lambda_function_data_source.rb', line 23

def invoke(function_name:, payload:)
  parsed_payload = JSON.generate(payload)
  @@client.invoke({
    function_name: function_name,
    invocation_type: 'Event',
    log_type: 'Tail',
    payload: parsed_payload
  })
end