Deploy Project

Database Prerequisite

To deploy to AWS Lambda, you’ll need to create a database that AWS Lambda can access. I suggest creating an RDS database for testing. Creating a database is outside of the scope of this guide, but here are some links that can help:

Once you have an RDS database, create a .env.development file and configure a DATABASE_URL environment variable.

.env.development

DATABASE_URL="mysql2://user:pass@db-1.ckbnyxs6b4a8.us-west-2.rds.amazonaws.com/demo_development?pool=5"

Tip: You can also store the DATABASE_URL value more securely in an SSM Parameter on the AWS account or use jets credentials:edit store in an encrypted file. We’re keeping things simple this guide.

Once this is set up we deploy to AWS Lambda.

Deploy

Let’s go ahead and deploy the project to AWS Lambda.

$ jets deploy

Here’s jets deploy command with some output:

❯ jets deploy
Deploying to Lambda demo-dev app...
Building CloudFormation templates
Deploying CloudFormation stack with jets app!
09:50:35PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack demo-dev User Initiated
...
09:51:58PM CREATE_COMPLETE AWS::CloudFormation::Stack JetsPreheatJob
09:52:00PM UPDATE_COMPLETE_CLEANUP_IN_PROGRESS AWS::CloudFormation::Stack demo-dev
09:52:00PM UPDATE_COMPLETE AWS::CloudFormation::Stack demo-dev
Stack success status: UPDATE_COMPLETE
Time took: 1m 26s
Prewarming application.
API Gateway Endpoint: https://2bmdurd1ra.execute-api.us-west-2.amazonaws.com/dev/

How Deployment Works

  1. Jets bundles up your code to a zip file and uploads it s3 for deployment.
  2. Jets uses precompiled gems for the deployment package from Jets Pro.
  3. Jets analyzes your source code to generate CloudFormation templates. CloudFormation deploys the resources like AWS Lambda functions.

Jets Pro

The Jets Framework itself is open source and free to use. Jets Pro is an paid service that provides additional features. By default, Jets Pro is used anonymously but is rate-limited. You can disable it. However, you must create and manage a Custom Lambda Layer for precompiled gems. You won’t also get access to a dashboard, release history, and the ability to rollback releases.

Next, we’ll review the deployed project.