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 rails-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
rails-dev-JetsController-*
. - There is a stack that manages a PrewarmEvent; it starts with
rails-dev-JetsPrewarmEvent-*
Lambda Resources
If you look at CloudFormation stack rails-dev-JetsController-*
Resources tab, you’ll see the Lambda Function.
Clicking on the Physical ID link takes you to the Lambda console. Since we use the package type image, instead of seeing the AWS console inline editor, we see the Image URI that points to the ECR repo.
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"
}
}
Note: The x-forwarded-proto
and x-forwarded-port
is required for Rails. Otherwise, Rails will think it’s a plain HTTP request and try redirecting to an https URL. The Rails config.force_ssl
and ActionDispatch::SSL middleware does this.
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://57jv6mkzj3su2buias5uuop6uy0ogvqr.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.