Skip to content

Instantly share code, notes, and snippets.

@radcliff
Created March 14, 2017 18:26
Show Gist options
  • Save radcliff/e2628be9063ce6de0f7d40936fc84bee to your computer and use it in GitHub Desktop.
Save radcliff/e2628be9063ce6de0f7d40936fc84bee to your computer and use it in GitHub Desktop.
Rumbda basics (tl;dr)
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);
};
# 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"})
#!/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