rr3tt / rumbda

Run ruby scripts on aws lambda.
MIT License
105 stars 18 forks source link

Allow Rumbda Lambda to return JSON for API Gateway #4

Closed bradleyjames closed 7 years ago

bradleyjames commented 7 years ago

I think this is passive.

API Gateway expects JSON to be returned from a Lambda. This, no matter how hackish, accomplishes that. The nodejs side of things passes a key in the event object to tell the ruby side of things where to write its JSON. It's ugly but passive to the current way of doing things. Also puts still behaves as before on the ruby side which was important.

I also updated to using callback rather than context.done() which is deprecated in Lambda's node v4.3 and v6.10 APIs.

rr3tt commented 7 years ago

Tested using this ruby script:

require 'json'

test = {
  foo: 'bar',
  test: [1, 2, 3]
}

File.open(ENV['RUMBDA_RESULT_JSON_FILENAME'], 'w') do |f|
  f.write(test.to_json)
end

def main
  puts 'hello'
end

main