Skip to main content

Rails Support - Jets Afterburner

About 2 minRubycrashcourserubyjetsawsaws-lambdacloudwatch

Rails Support - Jets Afterburner ๊ด€๋ จ


Rails Support - Jets Afterburner

Jets Afterburner - Serverless Rails on AWS Lambda in 5 Minutes

In this post and video, weโ€™ll cover how to deploy a Rails application to AWS Lambda Serverless in a few minutes. With Jets Afterburner, you donโ€™t have to make any changes to your Rails application to get it on AWS Lambda. ๐ŸŽ‰


Commands

gem install jets # outside of Gemfile
git clone https://github.com/tongueroo/demo-rails
cd demo-rails
mkdir -p .jets/app
vim .jets/app/.env # add your env variables
jets deploy
#
# => Rails app detected: Enabling Jets Afterburner to deploy to AWS Lambda.
# ...
# Deploying CloudFormation stack with jets app!
# 05:05:11PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack demo-rails-dev User Initiated
# ...
# 05:06:48PM UPDATE_COMPLETE AWS::CloudFormation::Stack demo-rails-dev
# Stack success status: UPDATE_COMPLETE
# Time took for stack deployment: 1m 36s.
# Prewarming application.
# API Gateway Endpoint: https://jp65zxlwf8.execute-api.us-west-2.amazonaws.com/dev/
#

Thatโ€™s it! We have successfully deployed our Rails application to AWS Lambda. Hereโ€™s the Live Demoopen in new window from the tutorial. The full source code of the Rails project is on Github: tongueroo/demo-railsopen in new window. More info is available at: Jets Rails Support: Afterburner Modeopen in new window.


Extra Environments

An interesting benefit of running applications on AWS Lambda is that you only get charged for actual requests. So extra environments are likely in the AWS free tieropen in new window. You could do this:

JETS_ENV_EXTRA=2 jets deploy
JETS_ENV_EXTRA=3 jets deploy
...
JETS_ENV_EXTRA=8 jets deploy

You essentially get unlimited free environments, each of them taking a few minutes to provision.


Other Live Demos

More examples are in the tongueroo/jets-examplesopen in new window repo.


Considerations

Afterburner mode is pretty awesome but is not a panacea for all Rails applications. Each and every Rails application is different and likely makes assumptions that itโ€™s running on a traditional server not serverless. For example, the app might upload files or images to the filesystem. This doesnโ€™t work on AWS Lambda because the app doesnโ€™t have access to a persistent filesystem. The application would have to be reworked to use a distributed store like S3 instead.

Ruby serverless applications might also use native binary gems. Jets uses Lambda Gemsopen in new window to make for a seamless and much easier deploy process. Lambda Gemsopen in new window is currently in beta, and early signups will receive a special offer for their support.


More info


์ด์ฐฌํฌ (MarkiiimarK)
Never Stop Learning.