Review Deploy
Let’s review what has been deployed.
CloudFormation Console
Jets leverages CloudFormation for deployment, so check the CloudFormation console. You should see something like this:
Jets creates a main parent sinatra-dev
stack that in turn creates a few nested CloudFormation stacks. This solves the CloudFormation quotas and limits. Here’s a summary:
- There is a stack that manages the controller requests, it starts with
sinatra-dev-JetsController-*
. - There is a stack that manages a PrewarmEvent; it starts with
sinatra-dev-JetsPrewarmEvent-*
Lambda Resources
If you look at CloudFormation stack sinatra-dev-JetsController-*
Resources tab, you’ll see the Lambda Function.
Clicking on the Physical ID link takes you to the Lambda console. You can see the Lambda handler code there.
The Lambda function handler shim is generated as part of jets deploy
. The handler is Lambda’s “point of entry” and provides the interface it expects. The Jets.shim.handler
ultimately calls the sinatra app. You can open app.rb
and see the code we created earlier.
Test Lambda Function
Let’s test the Lambda function manually with the Lambda Console built-in Test functionality. For the event, you need a payload that mimics what Lambda URL would send to the Lambda function. Here’s a minimal example:
{
"version": "2.0",
"rawPath": "/",
"headers": {
"host": "dummy.lambda-url.us-west-2.on.aws",
"x-forwarded-proto": "https",
"x-forwarded-port": "443"
}
}
After you click Test, you’ll see an “Executing function: succeeded” message with a link to the logs.
Clicking on the logs link takes you to the CloudWatch Logs Console. It shows all the Log Streams for the Log Group for the Lambda Function. Clicking Search Log Group and filtering by 1m or 30m is an easy way to see the logs.
Testing with the Lambda console is a pain because we need to figure out the event payload structure. See Debug Event Payloads for more example payloads.
Testing with a Browser
It’s more traditional to test with a browser. You can use the jets url
command to get the endpoint.
❯ jets url
Lambda Url https://aodietp35hnzkz7xpjx27cdxlu0zzzld.lambda-url.us-west-2.on.aws
You can open up the browser and test it just like you did with Local Testing
Next, we’ll make some updates and do more testing.