The "serverless" movement in web development has picked up a lot of steam in recent months. AWS Lambda now supports 6 languages and late last year announced support for Ruby:
They also support custom runtimes so you can run anything you like. I tried it out recently and got a Crystal function deployed, but it was difficult to say the least.
First, I had to run it through the Serverless framework. If you're unfamiliar with it (as I was), you have to run it on Linux. It also requires a whole lot of integration with AWS, including CloudFormation, IAM, and all kinds of other services on AWS. Because of this, their intro video instructs you to give it administrator privileges. When you're just starting out and you have nothing on your AWS account, this isn't such a big deal, but this is horrible advice for your a company account with existing infrastructure. Never give any tool you don't control all the keys to the kingdom.
In the end, partly because I refused to give it full admin privileges, it took me about 4 hours to deploy a single Crystal function to AWS Lambda — CloudFormation rollbacks take foreeeeeever when it doesn't succeed due to insufficient privileges and I couldn't find anything to point out exactly what privileges it needs. If you already use Lambda and Serverless or you have an Operations or Infrastructure team that understands these things, I'm sure this would go much more smoothly, but I didn't have that for this particular task. I was starting it from scratch.
Then I found FaaStRuby which just announced support for Crystal. Within 10 minutes I went from nothing to having a Crystal function available at an API endpoint.
Getting FaaStRuby up and running is pretty quick:
gem install faastruby
faastruby create-workspace your-workspace-name
-
faastruby new your-function-name --runtime crystal:0.27.0
- For Ruby functions, you can omit the
--runtime
flag since it's the default
- For Ruby functions, you can omit the
cd your-function-name
- Replace the code in the generated
src/handler.cr
with your own code- You may want to write some real specs or delete the generated ones. The ones they generate will likely fail and FaaStRuby doesn't deploy unless specs pass — this is a good thing.
faastruby deploy-to your-workspace-name
That's all it takes to get going — no registration forms, no payment details to mess with, just install a Ruby gem, run some CLI commands, write a couple lines of code, and hit your function at https://api.tor1.faastruby.io/your-workspace-name/your-function-name. It's pretty slick!
It still seems to be an early-stage service, so it doesn't have all the nice things that AWS Lambda has, but if all you're trying to do is deploy a cloud function quickly in Ruby or Crystal, it'll do what you need without all the ceremony that comes with using AWS.
Top comments (0)