Module: WolfCore::LambdaFunctionDataSource
- Defined in:
- lib/wolf_core/infrastructure/lambda_function_data_source.rb
Class Method Summary collapse
Class Method Details
.client ⇒ Object
24 25 26 |
# File 'lib/wolf_core/infrastructure/lambda_function_data_source.rb', line 24 def client @@client end |
.init ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wolf_core/infrastructure/lambda_function_data_source.rb', line 5 def init endpoint = ENV.fetch('AWS_LAMBDA_FUNCTION_ENDPOINT', nil) client_config = { access_key_id: ENV.fetch('AWS_KEY_ID', nil), secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', nil), } if endpoint.present? client_config[:endpoint] = endpoint else client_config[:region] = ENV.fetch('AWS_REGION', nil) end client_config = client_config.compact return if client_config.empty? @@client = Aws::Lambda::Client.new(client_config) end |
.invoke(function_name:, payload:) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/wolf_core/infrastructure/lambda_function_data_source.rb', line 28 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 |