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.

Change CloudWatch Event Rule

Instead of clicking Test, we’ll manually change the CloudWatch Event Rule to ensure it works properly. A quick way to find the CloudWatch Event Rule is from the CloudFormation stack.

You can click on the Physical ID of the CloudWatch Event Rule, and it’ll take you to the EventBridge console.

The code we deploy sets a rate of 10 hours. Let’s change it to 1 minute.

You can leave the other settings the same, click Next a few times, and click on Update Rule to save the changes.

Jets Logs

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

❯ jets logs -f -n cool_event-handle
Tailing logs for /aws/lambda/events-dev-cool_event-handle
Do something with event {"version":"0","id":"da26e5b9-b309-7453-27ec-f06151d6c714","detail-type":"Scheduled Event","source":"aws.events","account":"536766270177","time":"2024-05-22T22:27:52Z","region":"us-west-2","resources":["arn:aws:events:us-west-2:536766270177:rule/events-dev-CoolEvent-SP6VXAKRGCRJ-HandleEventsRule-9N43Z0vWJNpz"],"detail":{}}

We specify the -n option for the jets logs command. You can use jets functions to list available functions.

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.


class CoolEvent < ApplicationEvent
  rate "2 minutes"
  def handle
    puts "debug 2"
    puts "Do something with event #{JSON.dump(event)}"

Deploy again

❯ jets deploy -y
Packaging code for deploy: events-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:
Running: jets-remote deploy
#14 [build  7/13] RUN bundle install
Built docker image: events-dev-build-18a17437
Building CloudFormation templates
Built CloudFormation templates at /tmp/jets/events-dev/templates
Deploying app: events-dev
Waiting for stack to complete
09:07:02PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack events-dev User Initiated
09:08:04PM UPDATE_COMPLETE AWS::CloudFormation::Stack events-dev
Stack success status: UPDATE_COMPLETE
Release 2: https://www.rubyonjets.com/projects/events/releases/release-rNYWfkTivZkKcnFl

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.