Nuts and Bolts

Everyone has opinions and thoughts. Here are some of ours.

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. 🎉

EC2 A1 Instance with AWS Graviton Processor: Easy Way to Save 40%

AWS released A1 Instance Types at re:Invent 2018. Honestly, I didn’t think much about this announcement. I would see the ads for them when logging into the AWS console, and folks seem to be excited about them. So I started digging into what this whole A1 Instance type was all about. It didn’t take long to realize why it is a big deal. The A1 Instances will mean more server choices. More choices mean more competition, which is always better for consumers. This means faster, less expensive, and even better servers for us.

Jets Image Upload Carrierwave Tutorial: Binary Support

Jets, a Ruby Serverless Framework, makes use of API Gateway Binary Support to make uploading images and files from AWS Lambda a straightforward task. We’ll cover how to upload images or any file with Jets and Carrierwave in this tutorial guide. Note, please use Jets v1.3.1 and above for this tutorial guide as the jets new generator was updated for it. Here’s the Live Demo of this tutorial. The full source code is on Github: tongueroo/jets-example-upload.

Official AWS Ruby Support for Jets Serverless Framework

Ever since AWS released official Ruby support for AWS Lambda on Nov 29 at re:Invent, I’ve been super excited about switching Jets over to the official AWS version of Ruby. Happy to say that Jets is now on the official AWS Ruby runtime. Knew it was going to be interesting to learn about AWS Lambda Custom Runtimes and Lambda Layers as part of this Jets update.

Jets Tutorial: jets delete

This video tutorial demos the jets delete command. Since all the infrastructure is codified, deleting a Jets application is a straightforward process. What’s more interesting is that it is also easy to recreate the entire environment.

jets delete

For more info on the jets delete command, refer to its CLI reference.

Rails on AWS Lambda: jets import:rails --submodule

Update 12/21/2018: An improved way to run Rails on AWS Lambda is now supported that is effortless. This blog post covers it: Jets Afterburner: Serverless Rails on AWS Lambda in 5 Minutes. It is also documented here: Jets Rails Support. It is recommended you use Jets Afterburner for simple cases.

In the previous post: Jets Mega Mode: Run Rails on AWS Lambda, I covered how to get Rails running on AWS Lambda with Jets. In this video tutorial, I show you how to use the --submodule option for the same command we used to set things up previously: jets import:rails. Example:

jets import:rails http://github.com/tongueroo/demo-rails.git --submodule

Importing the Rails application as a submodule allows you to keep the Rails project in a separate repo. This allows you to manage the Rails project with a separate history and sync it with a Jets project when you want to. This is a useful setup if you are testing Jets Mega Mode Rails Support for an extended period of time.

Jets Mega Mode: Run Rails on AWS Lambda

Update 12/21/2018: An improved way to run Rails on AWS Lambda is now supported that is effortless. This blog post covers it: Jets Afterburner: Serverless Rails on AWS Lambda in 5 Minutes. It is also documented here: Jets Rails Support. It is recommended you use Jets Afterburner for simple cases.

Jets allows you to run Rails applications on AWS Lambda via Mega Mode. The name reminds me of a few things:

  • Mega Monolith: Rails applications can sometimes become a Majestic Monolith. Or sometimes it just becomes a Monolith 😁
  • Power Rangers Mega Mode: The Power Rangers can combine their Zords.
  • Mega Man: This superhero can change his arm to use different special weapons. One of the things that makes him Mega Man.

Mega Mode combines a Jets app and a Rack app together to allow you to run Rails on AWS Lambda with little effort. The docs for Rails Support are on the Ruby On Jets site. Here’s a Live Mega Mode Demo. We’ll go through an example of Mega Mode and get a Rails application running on AWS Lambda in this post.

Jets Simple AWS Lambda Ruby Function

Jets supports writing simple AWS Lambda functions with Ruby. You define them in the app/functions folder. A function looks like this:

app/functions/simple.rb:

def lambda_handler(event:, context:)
  puts "hello world"
end

Continuous Compliance AWS Config Rules Implementation with Jets Serverless Framework

In the previous post, AWS Config was introduced. We talked about how it can be used to obtain continuous compliance with your AWS account. In this post, we’ll implement a working example solution.

Continuous Compliance: AWS Config Rules Introduction

AWS is one of the greatest things since sliced bread. It empowers engineers to get things done quickly by enabling them to take control of the steering wheel and drive. With a simple AWS account, engineers can create resources, update security groups, and deploy their applications in rapid-fire fashion. The ease and power of AWS might make it seem like a security nightmare, but it’s actually the opposite. AWS provides the tools and controls to ensure everyone is following best practices, allows to you achieve a hardened security posture, and take compliance to a level that was never even thought possible before AWS: continuously.

Jets Tutorial Polymorphic Support Part 9: AWS Lambda Ruby

In this video tutorial, we cover Jets Polymorphic Support Ability. Jets allows you to write Lambda functions not just in Ruby but also in other languages like Node and Python. This can be useful if you have pre-existing Lambda code. You can re-use the code and and move on with life.

Jets Tutorial Different Environments Part 8: AWS Lambda Ruby

In this video, we continue the tutorials on the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We talk about the difference between Jets extra vs different environments. Different environments refer to development, staging, uat, production environments. Extra environments refer to instances of each of those environments. For example, development-1, development-2, development-3, etc.

Toronto Serverless Presentation: Jets Framework on AWS Lambda

Here’s the presentation I gave at the Serverless Meetup in Toronto on Jets: A Ruby Serverless Framework. We discuss how Ruby support at native speed was achieved. We learned a bit about how AWS Lambda works under the hood to understand how it works. 2 demos with a Jets application are also provide. We deploy it to Lambda with a single command.

Quick AWS Lambda Testing If Main Script Trick: Ruby, Python, Node, Bash

A quick way to test a Lambda function, is to add a little portion of code at the bottom of the script that tells it to run itself when it is the main script. The if statement means that the script will only run if it is ran directly vs being required as a library.

Jets Tutorial Extra Environments Part 7: AWS Lambda Ruby

In this video, we continue the tutorials on the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We talk about a Jets concept called extra environments. With one environment variable JETS_ENV_EXTRA, we can create as many additional instances of environments as we wish. This helps when multiple people are asking to use the development, staging, or uat environment but cannot because it is currently used by someone else or another feature. Usually, you end up having to wait until the environment free. With this Jets concept you can create as many environments as required.

Jets Tutorial Function Properties Part 6: AWS Lambda Ruby

In this video, we continue the tutorials on the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We’ll demonstrate how to customize the properties associated with the Lambda functions that Jets creates. There are 3 ways to set function properties with Jets: at the function level, class level or application level. We’ll also explore the AWS Lambda console and shows how the Lambda function properties connect with Jets.

Jets Tutorial IAM Policies Part 5: AWS Lambda Ruby

In this video, we continue the tutorials on the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We’ll demonstrate how to customize the IAM policies and roles associated with Jets Lambda functions. IAM policies are important because they handle securing access to your AWS resources so it’s worth learning them. Jets provides you with fine-grain control over the IAM permissions at the function, class, and application level.

Jets Tutorial Background Jobs Part 4: AWS Lambda Ruby

In this video, we continue the tutorials on the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We’ll cover background jobs in this video. Using background jobs is a typical pattern that offloads processing outside of the web request-response cycle. Users will not wait for web pages to load if it takes too long, so background jobs are an excellent technique to keep slower work outside of the request cycle.

Jets Tutorial Debugging Logs Part 3: AWS Lambda Ruby

In this video, we continue the tutorials on the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We’ll cover something that is pretty important to know as a software developer: debugging. With Jets it’s pretty straightforward to look at the debugging logs both locally and remotely. Locally, the logs show up with the local running server. Remotely, the logs show up in CloudWatch Logs: available both on the AWS CloudWatch Logs console and the AWS Lambda console.

Jets Tutorial Deploy to AWS Lambda Part 2: AWS Lambda Ruby

In this video tutorial, we continue how to get to started with the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We’ll explore the AWS Lambda Console and API Gateway to show how the AWS resources map back to Jets application code.

Jets Tutorial An Introductory CRUD App Part 1: AWS Lambda Ruby

In this video tutorial, we cover how get to started with the Jets Ruby Serverless Framework that adds Ruby support to AWS Lambda. We’ll build the quintessential CRUD application, and more we’ll importantly explore and edit it to understand how it works. Here’s the link to the Live CRUD Demo.

AWS Lambda Ruby Support at Native Speed with Jets

Update 2018/12/12: Official Ruby Support was announced at AWS re:Invent 2018 on Nov 29! Jets has switched over to it: Official AWS Ruby Support for Jets 🎉. This article is now out-of-date and kept around only for posterity.

AWS Lambda does not yet support Ruby. Though there are plenty of rumors that AWS is working on it. I’m pretty excited for the day when AWS releases official support for Ruby. Until that day arrives though, we must use a shim in order to add Ruby support to AWS Lambda. A shim is a function written in a natively AWS Lambda supported language that calls out to Ruby. Jets uses a node shim to add Ruby support to AWS Lambda. The neat thing is that Jets adds Ruby support to AWS Lambda at pretty much native speed.

Introducing Jets: The Ruby Serverless Framework

Update 2018/12/12: Official Ruby Support was announced at AWS re:Invent 2018 on Nov 29! Jets has switched over to it: Official AWS Ruby Support for Jets 🎉. This article has been updated to reflect official Ruby support, but video in the post is out-of-date and will be updated in time.

Ruby on Jets is a framework that allows you to build serverless applications in a beautiful language: Ruby. It includes everything needed to build and deploy applications to AWS Lambda. I love working with Rails, Ruby and AWS; and wanted to work with something similar in the serverless world. So I built Jets.

It is key to understand AWS Lambda and API Gateway to understand Jets conceptually. Jets maps your code to Lambda functions and API Gateway resources.

  • AWS Lambda provides Functions as a Service. It allows you to upload and run functions without worrying about the underlying infrastructure.
  • API Gateway is the routing layer for Lambda. It is used to route REST URL endpoints to Lambda functions.

How to Find the Current AWS EC2 Spot Market Price

Have you ever wondered how to find the current market spot price for an EC2 instance? When people first hear that spot instances can save you up 50%-90%, they tend to react in disbelief. This is natural and understandable, it just sounds too good to be true. Fortunately, there are many ways to confirm that the 50%-90% spot price savings is real. This article tries to lists the many ways in one place.

Spot Fleet Weighting and Pricing Explained

AWS docs explain How Spot Fleet Weighting Works under the “Spot Fleet Instance Weighting” section. I’ve read through the doc a few times now, and even so, when I come back to it months later, it still requires some mental wrangling to remember how it works. Been using some “mental” rules to understand how Spot Fleet Weighting works more quickly. Hopefully, you find these notes helpful also.

subscribe to Blog via RSS

More tools: