Update Project

Let’s make some changes. Let’s start with manual changes. It’ll help you get to know how things work.

Change Lambda Function

The Lambda Console allows us to edit code directly with the browser. It allows us to test, debug, and learn quickly. We’ll add a puts "debug 1" statement.

You can click Deploy to deploy the changes.

Jets Logs

You can also use the jets logs command to tail the logs in your terminal.

❯ jets logs -f
Tailing logs for /aws/lambda/sinatra-dev-controller
debug 1
2024-05-22 21:04:22 +0000: hello from sinatra

The jets logs command will use the Log Group from the controller Lambda function, IE: /aws/lambda/sinatra-demo-dev-controller, so we do not have to specify the name as we did in the Jets Project Job Learn Guide.

Update Code and Deploy Changes

So far, we have been making manual changes. We should codify the changes. To help see the changes, let’s make some additional changes so that it’s easy to check.

app.rb

require "sinatra/base"
require "jets-sinatra"

class App < Sinatra::Base
  get "/" do
    puts "debug 2"
    text = "hello from sinatra"
    puts "#{Time.now}: #{text}"
    text
  end
end

Deploy again

❯ jets deploy -y
Packaging code for deploy: sinatra-dev
Started remote run for deploy
Ctrl-C will stop showing logs. Jets will continue to run remotely.
If you want to stop the remote process, use: jets stop
Console Log Url:
https://us-west-2.console.aws.amazon.com/codesuite/codebuild/projects/sinatra-dev-remote/build/sinatra-dev-remote%3Abc307021-b524-49fc-b594-af39c1fca62c/log
...
Running: jets-remote deploy
...
#14 [build  7/13] RUN bundle install
...
Built docker image: sinatra-dev-build-18a17437
Building CloudFormation templates
Built CloudFormation templates at /tmp/jets/sinatra-dev/templates
Deploying app: sinatra-dev
Waiting for stack to complete
09:07:02PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack sinatra-dev User Initiated
...
09:08:04PM UPDATE_COMPLETE AWS::CloudFormation::Stack sinatra-dev
Stack success status: UPDATE_COMPLETE
Release 2: https://www.rubyonjets.com/projects/sinatra/releases/release-rNYWfkTivZkKcnFl
Prewarming application
Lambda Url https://aodietp35hnzkz7xpjx27cdxlu0zzzld.lambda-url.us-west-2.on.aws

Once changes have been deployed, confirm Lambda Source code changes.

If you still have jets logs running in a terminal, you’ll see logs tailing as you’re testing.

Next, we’ll delete the project.