Created
March 14, 2017 18:26
-
-
Save radcliff/e2628be9063ce6de0f7d40936fc84bee to your computer and use it in GitHub Desktop.
Rumbda basics (tl;dr)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exec = require('child_process').exec; | |
exports.handler = function(event, context, callback) { | |
const child = exec('./ruby_wrapper ' + "'" + JSON.stringify(event) + "'", (error, stdout, stderr) => { | |
callback(null, JSON.parse(stdout)); | |
}); | |
child.stdout.on('data', console.log); | |
child.stderr.on('data', console.error); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example usage: | |
# require 'httparty' | |
# response = HTTParty.get('https://raw.githubusercontent.com/kleaver/rumbda/master/example/main.rb') | |
# puts "Access environment variables via ENV: #{ENV['AWS_REGION']}" | |
# eg. access the `event` that triggered the Lambda execution — | |
# puts "Access the event via JSON.parse(ARGV.first): #{JSON.parse(ARGV.first)}" | |
require 'json' | |
print JSON.generate({"hello"=>"world"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Figure out where this script is located. | |
SELFDIR="`dirname \"$0\"`" | |
SELFDIR="`cd \"$SELFDIR\" && pwd`" | |
# Tell Bundler where the Gemfile and gems are. | |
export BUNDLE_GEMFILE="$SELFDIR/vendor/Gemfile" | |
unset BUNDLE_IGNORE_CONFIG | |
# Run the actual app using the bundled Ruby interpreter, with Bundler activated. | |
exec "$SELFDIR/ruby/bin/ruby" -rbundler/setup "$SELFDIR/source/main.rb" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment