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...
...
Deploying CloudFormation stack with jets app!
Waiting for stack to complete
05:14:35PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack demo-dev User Initiated
05:14:37PM CREATE_IN_PROGRESS AWS::Lambda::LayerVersion GemLayer
05:14:37PM CREATE_IN_PROGRESS AWS::IAM::Role IamRole
05:14:37PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiGateway
05:14:38PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiGateway Resource creation Initiated
05:14:38PM CREATE_IN_PROGRESS AWS::IAM::Role IamRole Resource creation Initiated
05:14:46PM CREATE_IN_PROGRESS AWS::Lambda::LayerVersion GemLayer Resource creation Initiated
05:14:46PM CREATE_COMPLETE AWS::Lambda::LayerVersion GemLayer
05:14:49PM CREATE_COMPLETE AWS::CloudFormation::Stack ApiGateway
05:14:49PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiResources1
05:14:50PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiResources1 Resource creation Initiated
05:14:56PM CREATE_COMPLETE AWS::IAM::Role IamRole
05:14:56PM CREATE_IN_PROGRESS AWS::IAM::Policy IamPolicy
05:14:57PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPreheatJob
05:14:57PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack JetsController
05:14:58PM CREATE_IN_PROGRESS AWS::IAM::Policy IamPolicy Resource creation Initiated
05:14:58PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPreheatJob Resource creation Initiated
05:14:58PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack JetsController Resource creation Initiated
05:15:00PM CREATE_COMPLETE AWS::CloudFormation::Stack ApiResources1
05:15:13PM CREATE_COMPLETE AWS::IAM::Policy IamPolicy
05:15:19PM CREATE_COMPLETE AWS::CloudFormation::Stack JetsController
05:15:20PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiMethods1
05:15:21PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiMethods1 Resource creation Initiated
05:15:31PM CREATE_COMPLETE AWS::CloudFormation::Stack ApiMethods1
05:15:32PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiDeployment20231029171433
05:15:33PM CREATE_IN_PROGRESS AWS::CloudFormation::Stack ApiDeployment20231029171433 Resource creation Initiated
05:15:43PM CREATE_COMPLETE AWS::CloudFormation::Stack ApiDeployment20231029171433
05:15:59PM CREATE_COMPLETE AWS::CloudFormation::Stack JetsPreheatJob
05:16:00PM UPDATE_COMPLETE_CLEANUP_IN_PROGRESS AWS::CloudFormation::Stack demo-dev
05:16:00PM UPDATE_COMPLETE AWS::CloudFormation::Stack demo-dev
Stack success status: UPDATE_COMPLETE
Time took: 1m 26s
Prewarming application.
API Gateway Endpoint: https://spsfc098x8.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.